How to Set Up Virtual Hosts in Xampp on Ubuntu

Over a year ago I discovered how to set up virtual hosts in Xampp and posted my method in the Ubuntu forum. Today I had to do it again. My memory is not very good and as it is not something I do every day I could not remember the precise details. I had to go searching in the Ubuntu forums to find my instructions again and of course, this took quite a while to find as there is a mass of excellent hints and tips over there and it is very easy to become distracted. Therefore, I have decided to post my method here hoping that the next time I need to install virtual hosts I will be able to find the instructions straight away!

At the moment I am using Ubuntu 10.10 and XAMPP Linux 1.7.3a

1. First of all enable virtual hosts by editing httpd.conf:

sudo gedit /opt/lampp/etc/httpd.conf

Find #Include etc/extra/httpd-vhosts.conf and remove the # so it looks like:

Include etc/extra/httpd-vhosts.conf

Save and close.

2. Now add the virtual host:

sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf

You will find two virtual hosts set up as examples. Remove or edit these with your own details.


ServerAdmin webmaster@mysite.com
DocumentRoot /opt/lampp/htdocs/myname/mysite
ServerName mysite.com
ErrorLog logs/mysite.com-error_log
CustomLog logs/mysite.com-access_log common

Save and close the file.

3. Now tell Xampp where to find this site:

sudo gedit /etc/hosts

Add this:

127.0.0.1 mysite.com

Save and close the file.

4. Restart xampp server

sudo /opt/lampp/lampp restart

5. Now you can point your browser to http://mysite.com and it should fetch your site.

I hope this method helps you too.

One Response to “How to Set Up Virtual Hosts in Xampp on Ubuntu”

  1. uut3 Says:

    thanks…
    im new in linux…
    so i don’t realy understand how to configure xampp on linux,
    cause it’s not in windows version that user only click and install the program…
    this think help me alot…
    :D