Search This Blog

Jul 3, 2014

Setup Virtual Host XAMPP on Linux

I always forgot on "How to set up virtual host on Linux" so I decided to create a blog post for my future reference (and for you too... you're welcome!)
I assume that you already install a XAMMP program on your system so lets jump in creating the virtual host.

1. Open your terminal and make sure you log as SU
2. Type in this command "gedit /opt/lampp/etc/httpd.conf" to open httpd.conf in the gedit editor.
3. Uncomment the "Include etc/extra/httpd-vhosts.conf" line by removing the "#".
4. Type in your terminal "gedit /opt/lampp/etc/extra/httpd-vhosts.conf" to edit httpd-vhosts.conf then add the following lines:

DocumentRoot /opt/lampp/htdocs
ServerName localhost
ServerAlias www.localhost



DocumentRoot /home/[YourCompName]/samplesite
ServerName www.samplesite.loc
ServerAlias www.samplesite.loc

IMPORTANT: Please make sure that you entered correct directory.

5. Then, edit your hosts file by typing “gedit /etc/hosts” on the terminal. Add your server alias like the following.

 127.0.0.1 localhost2
 127.0.0.1 samplesite

6. Lastly, restart your lampp by executing "/opt/lampp/lampp restart"

Again, you're welcome!

0 comments: