Configuring Apache2 for handling multiple sites on Ubunntu.

I use Ubuntu virtual server for various tasks and hosting my blog and other website is one of them. Ubuntu is so easy and simple to use, I moved all my servers from fedora to Ubuntu. Ubuntu makes it easy to setup the server itself and other services like LAMP, proxy server, etc..

Ubuntu Natty Narwhal

Ubuntu Natty Narwhal. Taken from

I run a lot of website on the server by configuring Virtual host file. I will give you a detailed info on how to configure Apache2 web server to run multiple website. I assume you have already install LAMP and is all configured. If not, please click here to find instruction for the same.

Once it is done you can test if it is working by opening a web browser and entering http://localhost/ in the address bar. You should get Apache’s default message that says “It works!”.

Now that Apache is installed we can go ahead and configure it to fit our needs. You can use Tunnelier application to access your Ubuntu server. It has features like SSH, SFTP, Terminal access, etc.. I use it because it has all the services in single software. If you use others, it is fine.

Let’s imagine you are going to configure the website

  • FTP to the server and create a web directory in /var/www/ and upload a simple HTML file (index.html). This is where you will store all your website files and folders.
  • Next go to /etc/apache2/sites-available.
  • There you will find a various files. Find the file with the name “default”. Download it to your local drive to edit its contents.
  • Rename the file from default to
  • Open the file with a text editor, I use Notepad++.
  • The file should contain the follow. Make the changes as need. See the example below.

<VirtualHost *:80>
 DocumentRoot /var/www/
 <Directory /var/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
 ErrorLog /var/www/
 LogLevel warn
 CustomLog /var/www/ combined


The contents of the file may vary, and you might see more info than what is show here. You don’t have to worry about the rest in the file.

In this file ServerName and ServerAlias tell the Apache2 what the hot names are. The DocumentRoot value tells the Apache2 where to find the files for this website. The Directory value specifies the various directives for the given directory. Finally the ErrorLog and CustomLog values tell Apache2 where to store the log files.

  • Save the file once you are done with the changes.
  • Upload the file to the following location /etc/apache2/sites-available
  • Execute the follow from the command line. sudo a2ensite
  • This will enable the virtual host website for
  • If you want to disable the site run the follow command sudo a2dissite
  • And finally, it is time to restart Apache2 for the changes to take effect. You can do so by running the following commands.

sudo /etc/init.d/apache2 restart


service apache2 restart

If everything went well you should able to bring up the website by typing in your web browser.


Tags: , , , , , , ,

Leave a Comment