Blog > detail

Just my tiny mind

Add New Virtual Host XAMPP or LAMPP on Linux

26-2-2012 Admin General 2 Comments

In this article, I would like to give a tutorial to Add New Virtual Host XAMPP or LAMPP on Linux.


In this case, I assume you already install xampp on your linux. Then lets start to Add New Virtual Host XAMPP or LAMPP on Linux immediately.

  1. Open your terminal and log as SU
  2. Type in your terminal "gedit /opt/lampp/etc/httpd.conf" to open httpd.conf in your text editor
    • delete "#" in front of "Include etc/extra/httpd-vhosts.conf" line

  3. Type in your terminal "gedit /opt/lampp/etc/extra/httpd-vhosts.conf" to edit httpd-vhosts.conf
    • add lines :

      <VirtualHost *:80>

      DocumentRoot /opt/lampp/htdocs

      ServerName localhost

      ServerAlias www.localhost

      </VirtualHost>

      <VirtualHost *:80>

      DocumentRoot /home/[YourCompName]/localhost2

      #some path of your new host

      ServerName localhost2

      #the name of your new host

      ServerAlias www.localhost2

      #alias of your new host

      </VirtualHost>

  4. Type in your terminal "gedit /etc/hosts" to edit hosts
    • add line :

      127.0.0.1 localhost2

      #127.0.0.1 Your new host name

  5. Restart lampp by execute "/opt/lampp/lampp restart"

Now you have two virtual hosts in your computer. You can access it through url http://localhost and http://localhost2. In this case, the two virtual host has its own document root. The default http://localhost has document root in /opt/lampp/htdocs, while the http://localhost2 has document root in /home/[YourCompName]/localhost2.


Have a nice try on Add New Virtual Host XAMPP or LAMPP on Linux...


Add New Virtual Host XAMPP or LAMPP on Linux

Add New Virtual Host XAMPP or LAMPP on Linux

Add New Virtual Host XAMPP or LAMPP on Linux

Add New Virtual Host XAMPP or LAMPP on Linux