Apache Virtual Hosting

This is extremely easy to do. This was done on Ubuntu 8.04. Replace "SERVER_IP" with the IP address of your server.

Edit /etc/apache2/apache2.conf and add the following:

NameVirtualHost SERVER_IP:80

Create a new file "subdomain" in /etc/apache2/sites-available with the content:

<VirtualHost SERVER_IP:80>
  ServerName subdomain.yourdomain.com 
  DocumentRoot /var/www/subdomain
  <Directory /var/www/subdomain> Order allow,deny Allow from all \</Directory>

Then run:

a2ensite subdomain 

then:

/etc/init.d/apache2 restart

If you made it this far, you should follow me on Twitter.

-JP

comments powered by Disqus