Skip to content

Instantly share code, notes, and snippets.

@jackvial
Last active August 29, 2015 14:04
Show Gist options
  • Save jackvial/15b43c0fd831b5bc474d to your computer and use it in GitHub Desktop.
Save jackvial/15b43c0fd831b5bc474d to your computer and use it in GitHub Desktop.
Add New Virtual Host XAMPP or LAMPP on Linux

On Windows: http://austin.passy.co/2012/setting-up-virtual-hosts-wordpress-multisite-with-xampp-on-windows-7/

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.

Open your terminal and log as SU 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 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>

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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment