Procbits

source code snippets and other random musings about software

Apache Virtual Hosting

Posted by JP on March 10, 2009

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>

</VirtualHost>

Then run:
a2ensite subdomain
/etc/init.d/apache2 restart

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>