You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by bruce <be...@earthlink.net> on 2003/07/26 22:48:12 UTC

[users@httpd] DocumentRoot

Hi...

Somewhat new to Apache.... is it possible to have multiple DocumentRoot
directives within the Apache httpd.conf file. I'm pretty sure it should be..
but I haven't been able to find any examples as to how the config file
should be set up to accomplish this... A google search hasn't really shown
me how...

Help/pointers/assistance would be appreciated....

Thanks

Bruce Douglas
bedouglas@earthlink.net


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DocumentRoot

Posted by Brian Richardson <br...@cubik.ca>.
On July 26, 2003 14:48, bruce wrote:
> Hi...
>
> Somewhat new to Apache.... is it possible to have multiple DocumentRoot
> directives within the Apache httpd.conf file. I'm pretty sure it should
> be.. but I haven't been able to find any examples as to how the config file
> should be set up to accomplish this... A google search hasn't really shown
> me how...

You are either talking about VirtualHosts, or Aliases. Here is the way to set 
up a few different things:

1) You want to have different document roots for different server names (ie. 
www.company1.com and www.company2.com both resolve to the same web server, 
and you'd like to serve up different documents to them:

NameVirtualHost *
<VirtualHost _default_:*>
    ServerName www.company1.com
    ServerAdmin webmaster@company1.com
    DocumentRoot "/var/www/www.company1.com/htdocs"
</VirtualHost>
<VirtualHost *>
    ServerName www.company2.com
    ServerAdmin webmaster@company2.com
    DocumentRoot "/var/www/www.company2.com/htdocs"
</VirtualHost>

2) You want to put documents from different parts of the filesystem into 
virtual directories (ie. Maybe you have some documentation that resides in 
/usr/share/doc that you'd like to have available through your webserver)

Alias /program-doc/ /usr/share/doc/program/html

Or, you could simply symlink it into your htdocs directory, like this:

% cd /var/www/htdocs
% ln -s /usr/share/doc/program/html program-doc

And include the following directive:

<Directory /var/www/htdocs>
    Options +FollowSymLinks
</Directory>

HTH,
Brian

-- 
To think contrary to one's era is heroism.  But to speak against it is 
madness.
		-- Eugene Ionesco