Multiple virtual hosts in xampp/lampp in Ubuntu

Xampp ( for Windows) or Lampp (for UNIX based systems) is anApache MySql PHP distribution which installs quickly and offers agood solution for testing websites on local machines. I myself useit and it has never disappointed me.When working with multiple websites, there is no need to createsub-domains to the existing local domain name “localhost”.Xampp/lampp enables you to work with a real domain name like””, for example, but with the files hosted on yourcomputer. The secret is the hosts files and the virtual hostsfeature.First of all you should find out where Xampp/lampp was installedon your computer. On my computer it is /opt/lampp/ .Next, because you should get some admin privileges, open up aterminal and type gksudo nautilus . Nautilus willhelp you modify some files easily, directly from GEdit.Now, with Nautilus, browse to/opt/lampp/etc/extra (change /opt/lamppto your own directory where xampp/lampp is installed, if differentfrom mine). Now open this file:httpd-vhosts.confBy default there are two VirtualHost sections, each containedbetween the tag. We will do some changes to these sections now. Thefirst section we should change it to point tolocalhost . Should look like this:ServerAdmin webmaster@dummy-host.example.comDocumentRoot /opt/lampp/htdocsServerName localhostServerAlias localhostErrorLog logs/ logs/ commonIn this line DocumentRoot /opt/lampp/htdocs you should onceagain change /opt/lampp to the directory where xampp/lampp isinstalled in your system.Next, for every other additional virtual host you will appendthe same block of code to your httpd-vhosts.conf file, but makingsome slight changes. For example, if you want to add the virtualhost , whose files are located in/opt/lampp/htdocs/myhost , you will add thiscode:ServerAdmin webmaster@dummy-host.example.comDocumentRoot /opt/lampp/htdocs/myhostServerName myhost.comErrorLog logs/ logs/ commonNotice that DocumentRoot and ServerName has been changed.ServerAlias is not needed anymore. Save the file.Next you should enable virtual hosts in the configuration file,located at /opt/lampp/etc . Open the filehttpd.conf with nautilus, and find this line#Include etc/extra/httpd-vhosts.conf . Remove the# char from the beginning of the line, so itremains Include etc/extra/httpd-vhosts.conf only.Save the file.Now we should add the domain name to the hosts file in order forthe domain name to point to our ip address , but not tolook for it in the DNS database. So go to /etc/with Nautilus, also, and open this file: hosts .Now at the end of the file append the following line : (or change to thename of your own virtual host name). Do the same thing for all theother virtual hosts you have. Save the file.Now we will need to restart Xampp/Lampp in order for the changesto take effect. Open a terminal window and run this command:gksudo /opt/lampp/lampp restart ( remember tochange /opt/lampp if needed).Now you should be able to work with your virtual hosts, by goingwith your browser to or tohttp://the_name_of_your_own_virtual_host.your_own_tld . Goodluck!