New Virtual Host in Apache on Ubuntu

I'm an IIS guy, so Apache seems arcane to me. And the creation of a new website (aka Virtual Host) was difficult at first, but seems straightforward enough to me now. Here's how it's done.

Create a text file that will define your website in /etc/apache2/sites-available. In that text file goes a description of your new Virtual Host. Here's a barebones example:

<VirtualHost *:80>

DocumentRoot /www/mysite



Once you've created that file, you need to place a link to it in/etc/apache2/sites-enabled using a command like this (to create the symbolic link)

ln -s /etc/apache2/sites-available/mysite

Then you need to restart Apache…

apache2ctl restart

And, if you've done it right, you should have a new virtual host ready to go.

Leave a Reply

Your email address will not be published.