fluidthoughts developers' guild

fluid funk

howto / config-vhost

Using vhosts (Virtual Hosts) with Apache

These are instructions to help you get started using your own vhost. This can be used for either sub-domains, or an entirely new domain name which points to your server.

log in as root, and modify config files:

su -l root
cd /usr/local/apache/conf	#this is where my config files are located, YMMV.
vi httpd.conf 	#edit this file 

You'll need to add in the below lines after this first one:

#NameVirtualHost *
NameVirtualHost xx.xx.xx.xx 	#your ip address here

Include conf/vhosts/vhost-name.conf	#add in your own includes:

save that file, and make sure a vhosts dir exists (for organization), and create a vhost file in there. This info can be followed as a template:

Sample vhost file:

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the VirtualHost command

#Listen 192.168.0.0:80

# VirtualHost: Allows the daemon to respond to requests for more than one
# server address, if your server machine is configured to accept IP packets
# for multiple addresses. This can be accomplished with the ifconfig 
# alias flag, or through kernel patches like VIF.

# Any httpd.conf or srm.conf directive may go into a VirtualHost command.
# See also the BindAddress entry.

<VirtualHost name.domain.tld> 
    ServerAdmin user@domain.tld 
    ServerName name.domain.tld
    DocumentRoot /home/httpd/html/ 

    ErrorLog logs/name/name.errs
    CustomLog logs/name/name.access common
    TransferLog logs/name/name.access

	ErrorDocument 403 /error-msgs/403.html 
	ErrorDocument 404 /error-msgs/404.html 
</VirtualHost>

test and restart server:

For better organization, you may notice that I specified my logs files to be written into a specific directory inside the logs directory. If I had not done this and added a long list of vhosts, then the logs directory could quickly become a pain to manage.

If you choose to go this route, be sure to create these directories before restarting your server, as configtest won't necessarily complain about it.

[root@name apache]# ./bin/apachectl configtest
Syntax OK
[root@name apache]# ./bin/apachectl restart   
./bin/apachectl restart: httpd restarted

 

$Id: config-vhost.html,v 1.3 2002/08/15 04:51:44 willn Exp $