Page 1 of 1

HOW TO: add a virtual host

PostPosted: 24. August 2012 04:04
by waspinator
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

Re: HOW TO: add a virtual host

PostPosted: 24. August 2012 05:05
by Altrea
Hi waspinator,

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

best wishes,
Altrea

Re: HOW TO: add a virtual host

PostPosted: 25. August 2012 13:49
by waspinator
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