Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UserDir has wrong DocumentRoot

Status
Not open for further replies.

ggggus

Programmer
Jul 5, 2003
114
0
0
Ok, I believe I've included the important parts of the apache config file (names have been changed to protect my security). here is the issue I'm having:

The domains seem to be working properly, but the UserDir is not... If I go to The initial page pulls up but includes from that file do not work because the document root is being set wrong... more specifically:
Code:
require_once($_SERVER['DOCUMENT_ROOT']."/includes/init.php");
Does not work becuase the document root is wrong. if I do a phpinfo() it shows apache having the document_root set to /home/test/public_html

What is wrong here with my config?

Code:
DocumentRoot "/var/[URL unfurl="true"]www/html"[/URL]

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/[URL unfurl="true"]www/html">[/URL]

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# [URL unfurl="true"]http://httpd.apache.org/docs-2.0/mod/core.html#options[/URL]
# for more information.
#
    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>


<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    UserDir disabled
    UserDir enabled test test2

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disable" line above, and uncomment
    # the following line instead:
    # 
    UserDir public_html

</IfModule>

<VirtualHost *:80>
SuexecUserGroup "#502" "#501"
ServerName foo.com
ServerAlias [URL unfurl="true"]www.foo.com[/URL]
DocumentRoot /home/test/public_html
ErrorLog /home/test/logs/error_log
CustomLog /home/test/logs/access_log common
ScriptAlias /cgi-bin/ /home/test/cgi-bin/
<Directory /home/test/public_html>
Options IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName ads.foo.com
ServerAlias [URL unfurl="true"]www.ads.foo.com[/URL]
DocumentRoot /home/test/domains/ads.foo.com/public_html
ErrorLog /home/test/domains/ads.foo.com/logs/error_log
CustomLog /home/test/domains/ads.foo.com/logs/access_log common
ScriptAlias /cgi-bin/ /home/test/domains/ads.foo.com/cgi-bin/
<Directory /home/test/domains/ads.foo.com/public_html>
Options IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
SuexecUserGroup "#503" "#502"
ServerName bar.com
ServerAlias [URL unfurl="true"]www.bar.com[/URL]
DocumentRoot /home/test2/public_html
ErrorLog /home/test2/logs/error_log
CustomLog /home/test2/logs/access_log common
ScriptAlias /cgi-bin/ /home/test2/cgi-bin/
<Directory /home/test2/public_html>
Options IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
</VirtualHost>

***************************************
J. Jacobs
 
You are mixing your virtual hosts with your UserDir. It looks like you want to disable UserDir for everybody but test and test2. Do not create vhost containers for these users. Instead you will define a directory container for the UserDir. For example, if the directory is named public_html the you would create a directory something like this:

<Directory /home/*/public_html>
Options MultiViews Indexes
Order allow,deny
Allow from all
</Directory>

This container needs to be defined globally. Generally, it's best to put it right after the UserDir directive and make sure it is not inside another container. This single definition applies to all user's directories. The pulic_html directory will be put in each users home directory when their account is created.
 
Is there a way to mix them?

I'm setting up a dedicated server, and moving a bunch of sites to the server from a bunch of hosts. What I want is to set up the virtual servers in anticipation of the change in DNS records, but get some testing in to make sure the sites are working before I change the DNS records. In order to do the testing I was hoping to use the /~username/ to test it out...

Is there another way to do this?
DocumentRoot is obviously important here for include/require_once calls made in the code of most of these sites.

***************************************
J. Jacobs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top