Last time we have talked about setting up Multiple Virtual Host for our XAMPP. However it is only for Windows and ihave think about it that it would be good to do a little research for setting up Multiple Virtual Host for Linux Xampp or Lampp and post it here.
Just Follow this LAMPP - Multiple Virtual Host Setup for easy setup for your new sets of Virtual Host's
To begin with. Let us locate the installation directory of our Xampp/lampp on our computer. As for mine it was installed at "/opt/lampp/".
So, for the rest of the article i will refer to the installation directory of Lampp as "Lamp-Dir" and currently Lamp-Dir = /opt/lampp.
Now let us open our Terminal and type in "gksudo nautilus" for us to have some admin priveledges. Nautilus will help you modify some files easily, directly from GEdit.
Using Nautilus, browse to "Lampp-dir/etc/extra" and open the "httpd-vhosts.conf".
By default there are two VirtualHost sections, each contained between the tag. We will do some changes to these sections now. The first section we should change it to point to localhost . Should look like this:
ServerAdmin admin@localhost
DocumentRoot Lampp-dir/htdocs
ServerName localhost
ServerAlias localhost
ErrorLog localhost
CustomLog localhost-access_log common
Next, for every other additional virtual host you will append the same block of code to your "httpd-vhosts.conf"file, but making some slight changes. For example, if you want to add the virtual host myhost.com , whose files are located in "Lampp-dir/htdocs/myhost" , you will add this code:
ServerAdmin admin@myhost
DocumentRoot Lampp-dir/htdocs/myhost
ServerName myhost.com
ErrorLog logs/myhost-error_log
CustomLog logs/myhost-access_log common
Notice 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 Lampp-dir/etc . Open the file "httpd.conf"with nautilus, and uncomment the line:
#Include etc/extra/httpd-vhosts.conf
Save the file.
Now we should add the domain name to the hosts file in order for the domain name to point to our ip address 127.0.0.1 , but not to look 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 :
127.0.0.1 myhost.com
(or change myhost.com to the name of your own virtual host name).
Do the same thing for all the other virtual hosts you have. Save the file.
Now we will need to restart Xampp/Lampp in order for the changes to take effect. Open a terminal window and run this command:
gksudo Lampp-dir/lampp restart
Now you should be able to work with your new virtual hosts, by going with your browser to "http://myhost.com/"