ZZZZZZZZZ The internet and other bits

16Apr/100

Enabling sites and accessing them locally with Apache on Ubuntu

Sites can be added and enabled in Apache by creating the site's directory:

mkdir /var/www/my_site_name

Create the my_site_name configuration file within /etc/apache2/sites-available

vim my_site_name

and enter the configuration

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName my_site_name.dev

DocumentRoot /var/www/my_site_name

</VirtualHost>

and running the Apache enable site command to 'enable' the site:

sudo a2ensite my_site_name.dev

Then you have to restart Apache so it sees the new site / configuration

sudo /etc/init.d/apache2 reload

Next you will probably need to add an entry to your /etc/hosts file if you want to access the site via a user friendly url like my_site_name.dev.

sudo vim /etc/hosts

Add an entry for your site:

127.0.0.1 my_site_name.dev

save it and you may also need to restart your web browser.

If you placed an index file in your DocumentRoot you should see it when you visit

my_site_name.dev

Referenced: http://www.debian-administration.org/articles/412