HOW TO: add a virtual host

Problems with the Linux version of XAMPP, questions, comments, and anything related.

HOW TO: add a virtual host

Postby waspinator » 24. August 2012 04:04

Hi, I was having trouble adding a virutal host. I searched for a couple hours, but couldn't find a clear solution.

So here is what I came up with. I'd apperciate any comments on if this makes any sense.

Code: Select all
1. download xampp

    http://www.apachefriends.org/en/xampp-linux.html

2. untar into opt

    sudo tar xvfz xampp-linux-1.8.0.tar.gz -C /opt
   
3. secure xampp

    sudo /opt/lampp/lampp security
   
4. make a vhost directory where you will keep your files

    mkdir ~/vhost1
   
5. add vhost1 to hosts file

    gksudo gedit /etc/hosts
   
    - and add this line:
    127.0.0.1   vhost1.localhost
   

6. restart networking

    /etc/init.d/networking restart
   
7. enable virtual hosts in httpd.conf

    gksudo gedit /opt/lampp/etc/httpd.conf
   
    - search for "Include etc/extra/httpd-vhosts.conf" and remove the #
   
8. add the virtual host to httpd-vhosts.conf

    gksudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
   
    - comment out any dummy virtual hosts and add the following to the bottom
   
    <VirtualHost *:80>
        DocumentRoot "/opt/lampp/htdocs"
        ServerName localhost
        ServerAlias www.localhost
    </VirtualHost>

    <VirtualHost *:80>
        DocumentRoot "/home/username/vhost1"
        ServerName vhost1.localhost
        ServerAlias www.vhost1.localhost
        <Directory "/home/username/vhost1">
           AllowOverride FileInfo AuthConfig Limit Indexes
           Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
           Require method GET POST OPTIONS
        </Directory>
    </VirtualHost>

9. change permissions of vhost1 directory to 755

     sudo chmod -R 755 ~/vhost1
waspinator
 
Posts: 3
Joined: 24. August 2012 03:59
Operating System: Ubuntu 12.04 64bit

Re: HOW TO: add a virtual host

Postby Altrea » 24. August 2012 05:05

Hi waspinator,

nobody here can help you if you don't tell us, at which point you get problems...

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: HOW TO: add a virtual host

Postby waspinator » 25. August 2012 13:49

Hi Altrea,

Well it's working, but I'm not sure if I'm doing things the right way. Is this the proper way to set up a virtual host?

Thanks
waspinator
 
Posts: 3
Joined: 24. August 2012 03:59
Operating System: Ubuntu 12.04 64bit


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 19 guests