I’ve been working on a number of website development projects of late. I use my laptop, running Ubuntu Linux, for all of the development work. I use:
- PHP as the server side scripting language;
- JavaScript, and in particular jQuery and various jQuery plugins, for client side scripts;
- VIM (Vi IMproved) for all of the editing; and
- Apache 2.2 as the web server.
I also use an Oracle database for storing data for projects at work, Flinders University, my other projects haven’t needed a database platform yet.
To keep all of the projects organised I’ve created virtual hosts and associated directories for each project. Virtual hosts allow you to run more than one host on the same IP address. More information on virtual hosts is available here.
This is the procedure that I follow for starting a new project. The exact details may be different depending on your Linux distribution. I would imagine the same principles apply for doing this under Windows, but I don’t know how.
- Make a backup copy of the
/etc/hostsfile
sudo cp /etc/hosts /etc/hosts.old - Open the /etc/hosts file using vi as the root user
sudo vi /etc/hosts - Add an additional line for the new host, for example
127.0.0.1 localhost4 - Save the file and exit
- Make a directory for the new project (all of mine are in a sub directory of my home directory)
mkdir /home/user/web-sites/www4 - Copy the existing default virtual host configuration file
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/www4 - Open the new file using vi as the root user
sudo vi /etc/apache2/sites-available/www4 - Change the value of the
ServerNamedirective to the host specified in step 3 - Change the value of the
DocumentRootdirective to the directory created in step 5 - Change the value of the
Directorydirective to the directory created in step 5 - Save the file and exit
- Enable the new virtual host
sudo a2ensite www4 - Restart the Apache web server
sudo /etc/init.d/apache2 restart - Confirm the new site is up and running by visiting it in your web browser
I’ve got four websites so far running on my laptop using this technique and so far it is working really well. It means I can keep my directory structures clean and tidy which helps with keeping track of the various sites and the files within them.





