Apache Virtual Hosts
Apache is an open source web server that is currently dominating the market because of it’s low cost (nothing) and ease of use and configuration. There is a large support database available from www.apache.org and the source is freely available from the same site. Apache also offers ease of use for Perl, PHP, JServ (Java Servlets) and CGI scripts.
There are two ways to do webhosting, IP Based Virtual Hosting which binds one IP address to a specific URL and Name-Based Virtual Hosting which allows multiple domain names to operate on one IP.
Hopefully, you have already realized that you need to have Apache installed before going any further. Click here if you need instructions on how to install Apache.
cd to the apache directory (/usr/local/apache).
There are several subdirectories (conf, bin, logs). Start in the conf directory. Edit the file httpd.conf using the command ‘vi conf/httpd.conf’. If the vi editor is foreign to you, you can brush up on editor commands with the vi editor tutorial
There are 2 ways to run apache, IP based Virtual Hosting and Name-Based Virtual Hosting.
The NameVirtualHost directive
REQUIRED for Name-based virtual hosting. (A * can be used to specify that the server is only doing Name-Based Virtual Hosting). The line above tells httpd to only run name based virtual hosts on 192.168.1.10 port 8080.
The following tells httpd to listen for name based virtual hosts on all interfaces
The BindAddress Directive
For IP Based hosting, you need to add each IP that apache will listen on.
BindAddress 192.168.1.20 192.168.1.25 10.0.0.1
NOTE: The IPs MUST be the IP bound to the interfaces, and IPs from multiple interfaces can be used. (A * can be used for all IPs on a given machine)
This works the same for IP and name based virtual hosting, with the exception of the ServerName and ServerAlias being absent with IP Based Virtual Hosting
#The following VirtualHost directive will answer for domain.com and *.domain.com (* being a wildcard)
ScriptAlias “/cgi-bin/” /home/user/www/cgi-bin
# This Virtual Host will answer for circle.com, square.com and triangle.com. It *WILL NOT* answer for www.circle.com, www.square.com or www.triangle.com.
ScriptAlias “/cgi-bin/” /home/circle/www/cgi-bin
#This example will serve up trapeziod.com content to anyone browsing 10.0.0.1
ScriptAlias “/cgi-bin/” /home/trapezoid/www/cgi-bin
Starting and Stopping
Status of currently running server: