Wednesday 12 August 2009, 2:22 PM
Virtual Hosts on Ubuntu
Whilst commuting to and from The Agency, through the Garden of England, I have been wanting to build dynamic Joomla! web sites whilst sat on the gloriously over-crowded flu infested train. To do that, I needed to set up local Virtual Hosts on my Ubuntu laptop. This is how I did it (warning, contains command line interface wijjery jiggery):
1. Install Apache2 web server, PHP, MySQL and PHPMyAdmin
For the first 3 items, the easiest way is to enter in the terminal:
sudo tasksel install lamp-server
PHPMyAdmin is a browser-based interface to MySQL which makes it easy to create and edit databases. Just fire up System > Administration > Synaptic Package Manager and do a quick search and install.
2. Set up Name based virtual hosting
You need to sudo gedit the file /etc/apache2/apache2.conf and add this to the end:
# Server name
ServerName 127.0.0.1
# Name based virtual hosting
NameVirtualHost 127.0.0.1:80
3. Create config file example.dev
In the directory /etc/apache2/sites-available/ create a text document named example.dev
ServerName example.dev
ServerAlias www.example.dev
ServerAdmin isp@growdigital.net
DocumentRoot /home/yourname/Work/www/example.dev
4. Create symlnk to sites-enabled
Once you have configured site, you need to enable it by creating a symbolic link to the sites-enabled folder:
cd /etc/apache2/sites-enabled/
ln -s ../sites-available/example.dev
5. Add entry into /etc/hosts
sudo gedit the hosts text file, which points the browser at the right place, by adding:
127.0.0.1 example.dev
6. Simple restart
Once you've done all that, you need to reboot the Apache2 web server:
sudo /etc/init.d/apache2 restart
Don't forget to actually have a web site set up at /home/yourname/Work/www/example.dev. Now, when I type www.example.dev into my browser, it comes up with my example development web site.
To set up Joomla!, I firstly create an empty database using PHPMyAdmin, and then either use JoomlaPack to re-create my default setup, or do a fresh install of Joomla!
Credit: I used this tutorial from Ubuntu Tutorials to help me on the way.


