Geek; Programmer; Pythonista; FOSS enthusiast, evangelist and contributor; Melange developer; opinionated about programming languages; crazy about cars and air-planes; choosy in watching movies; loves Bangalore, San Francisco and Southern California; and most importantly addicted to coffee!
Madhusudan C.S.
map (thoughts) => words;   reduce (words) => this;
April 9, 2008, 8:39 p.m.


   One of my previous tutorials guides through the process of installing LAMP server. If you have not got  LAMP server working yet please go through that tutorial. Click Here To Read That Tutorial. If LAMP is working fine continue. I will try to explain this tutorial with an example. Say I now want to run two websites in addition to the localhost I have with the names and Type the following in the terminal:

   $ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/   
   $ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/

   Now open each of these files. Just below the line <VirtualHost *> and above the line ServerAdmin localhost@localhost add the following line with the keyword ServerName and your website name say and in these two cases. Change the email ID to whatever you want in the ServerAdmin line. Change the paths of DocumentRoot and Directory as explained in the tutorial linked above. One of the files named looks as follows:

NameVirtualHost *
<VirtualHost *>

        DocumentRoot /home/madhu/mywebdevelopment/madhusudancs/
        <Directory />
               Options FollowSymLinks
               AllowOverride All
        <Directory /home/madhu/mywebdevelopment/madhusudancs/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny

   Do this for both the files. Now type the following in the terminal:

   $ sudo a2ensite
   $ sudo a2ensite

   This done you have enabled the site, now you need to tell your machine where to find these sites. So goto System->Administration->Network in GNOME Menu Panel. In the dialog that opens click on the Hosts tab. You can click on add and in the new dialog that appears put an IP in the range of 127.0.0.x and your website name as Alias i.e in this case. You can Add another entry ffor another website. Also alternatively you can click on Properties of localhost and then add the aliases of all the new sites you created there all together. Both the methods work equally well. You can choose which ever method you want. Now restart apache by typing the following in terminal:

   $ sudo /etc/init.d/apache2 restart 

   This completes the tutorial. To test whether both the sites are working, put some content into respective folders with index.html or index.php or whatever and type the websites's name in the browser say in this example. Hurray, we have Virtual Servers running now. Enjoy!!!

   If you have any problems with the above tutorial or any queries please write back to me at

--Yours lovingly

comments powered by Disqus