[Techtalk] Hosting multiple websites from one user on Apache

David Merrill david at lupercalia.net
Wed Jan 9 21:46:25 EST 2002


On Wed, Jan 09, 2002 at 06:16:14PM -0800, Amber wrote:
> Hey all, I have been poking around with this for a few days now, and haven't gotten it to work quite right yet. Does anyone know what has to be done in httpd.conf to get more than one site hosting off of a users directory? I am setting the document root as just another folder in my home directory, but that doesn't work. Is there a specific way I have to reference it? Or a specific location it has to be in? Would appreciate any suggestions.

The standard document root directive doesn't affect virtual hosting.
The Apache docs cover it so much better than I could, I won't give you
the details, but instead kindly recommend you rtfm. No offense
intended. It's at:

http://httpd.apache.org/docs/vhosts/index.html

There's no specific directory it has to be in, but the directory does
need to be readable by the user who is running apache, www-data on
Debian but also sometimes root (not recommended, however, for security
reasons) or httpd (on Red Hat 6.2, probably others).

Here is the relevant portion of my httpd.conf. Luckily in Debian it is
very well commented. This is for Apache 1.3 -- it might have changed
in Apache 2.0, which is currently in beta and not recommended for
production servers.


### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them.
# Please see the documentation at <URL:http://www.apache.org/docs/vhosts/>
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# If you want to use name-based virtual hosts you need to define at
# least one IP address (and port number) for them.
#
#NameVirtualHost 12.34.56.78:80
NameVirtualHost *

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
#
#<VirtualHost ip.address.of.host.some_domain.com>
#    ServerAdmin webmaster at host.some_domain.com
#    DocumentRoot /www/docs/host.some_domain.com
#    ServerName host.some_domain.com
#    ErrorLog logs/host.some_domain.com-error.log
#    CustomLog logs/host.some_domain.com-access.log common
#</VirtualHost>

<VirtualHost *>
    ServerName www.lupercalia.net
    DocumentRoot /var/www/lupercalia.net
    ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/
    ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/
    Alias /pipermail/ /var/lib/mailman/archives/public/
    ErrorDocument 404 /marvin404.html
    <Directory /var/www/lupercalia.net>
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *>
    ServerName db.linuxdoc.org
    DocumentRoot /var/www/gldp.org
    ServerAlias www.gldp.org
    ServerAlias gldp.org
    <Directory /var/www/gldp.org>
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/gldp.org/
    <Directory /usr/lib/cgi-bin/gldp.org/>
      AuthName "LDP Database"
      AuthType Basic
      AuthUserFile /var/www/htpasswd-gldp
      Require valid-user
      Satisfy All
    </Directory>
</VirtualHost>

<VirtualHost *>
    ServerName ldp.lupercalia.net
    DocumentRoot /var/www/ldp.lupercalia.net
    <Directory /var/www/ldp.lupercalia.net>
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *>
    ServerName www.ffa-cac.org
    DocumentRoot /var/www/ffa-cac.org
    ServerAlias ffa-cac.org *.ffa-cac.org
    <Directory /var/www/ffa-cac.org>
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *>
    ServerName www.scrollserver.org
    DocumentRoot /var/www/scrollserver.org
    ServerAlias scrollserver.org *.scrollserver.org
    <Directory /var/www/scrollserver.org>
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

#<VirtualHost _default_:*>
#</VirtualHost>


-- 
David C. Merrill                         http://www.lupercalia.net
Linux Documentation Project                   david at lupercalia.net
Collection Editor & Coordinator            http://www.linuxdoc.org

Bill [Gates] is just smarter than everyone else. There are probably more
smart people per square foot right here than anywhere else in the world,
but Bill is just smarter.
	--Executive Microsoft VP Mike Maples in The New Yorker, 01-10-94



More information about the Techtalk mailing list