Linux setup steps/Apache virtual hosting
From Nick Jenkins
Setting up Apache virtual hosting:
Load the mass virtual hosting module:
a2enmod vhost_alias
Then "nano /etc/apache2/apache2.conf", and add this to the end of the file to enable mass virtual hosting:
# --------------------------------------------------- # ---------------- Virtual Hosting ------------------ <IfModule mod_vhost_alias.c> # Get the server name from the Host: header UseCanonicalName Off # The virtual document root is under /var/www/__name_of_whatever_was_requested__ VirtualDocumentRoot /var/www/%0 # Note: Regrettably, cannot set up separate SSL certs for each virtual host here (need different IPs or ports) # see: http://www.mail-archive.com/modssl-users@modssl.org/msg15648.html </IfModule> # ---------------------------------------------------
Then check above syntax is OK:
apache2ctl -t
Then restart apache:
/etc/init.d/apache2 force-reload
Then try to access a page by the hostname (e.g. "http://IP-address"). Should get an error like "The requested URL / was not found on this server." Also a "tail -f /var/log/apache2/error.log" should show an entry like: "File does not exist: /var/www/IP-address". This indicates that virtual hosting is working.
