Xampp and multiple domains for local testing

Discussion in 'Site & Server Administration' started by johneva, Feb 16, 2011.

  1. #1
    Hi all

    I have been testing php pages loacl for ages now and always just struggled with the standard setup of xampp in terms of directory issues with the live site.

    So thought its time to figure out how to have multiple domains local, that are basicly copys of the real domain but with .lh instead of .com or .co.uk

    So found this blog post and ran through it, but it did not seem to work.

    How To Set Up Virtual Hosts In XAMPP ? Return True

    After having a play around with what it had instructed for a while managed to get it to work but had to assign a different IP for each new domain and then put that domain inplace of the * where it says:

    <VirtualHost *:80>
    Code (markup):
    Would this be ok doing it this way instead?

    According to the articles I have seen you should be able to setup your windows host file like this for example:

    127.0.0.1		localhost
    127.0.0.1		total-fleet-management.lh
    127.0.0.1		car-maintenance-package.lh
    Code (markup):
    But I had to do it like this

    127.0.0.1		localhost
    127.0.0.2		total-fleet-management.lh
    127.0.0.3		car-maintenance-package.lh
    Code (markup):
    Then they say you should be able to set your apache vitualhostfile like this:

    <VirtualHost *:80>
        ServerAdmin webmaster@dummy.example.com
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
        ServerAlias localhost
    
        ServerAdmin webmaster@dummy.example.com
        DocumentRoot "C:\xampp\htdocs\Fleet-Management"
        ServerName total-fleet-managemet.lh
        ServerAlias total-fleet-management.lh
    
        ServerAdmin webmaster@dummy.example.com
        DocumentRoot "C:\xampp\htdocs\Maintenance-Site"
        ServerName car-maintenance-package.lh
        ServerAlias car-maintenance-package.lh
    </VirtualHost>
    Code (markup):
    But I have had to do it like this

    <VirtualHost 127.0.0.1:80>
        ServerAdmin webmaster@dummy.example.com
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
        ServerAlias localhost
    </VirtualHost>
    
    <VirtualHost 127.0.0.2:80>
        ServerAdmin webmaster@dummy.example.com
        DocumentRoot "C:\xampp\htdocs\Fleet-Management"
        ServerName total-fleet-managemet.lh
        ServerAlias total-fleet-management.lh
    </VirtualHost>
    
    <VirtualHost 127.0.0.3:80>
        ServerAdmin webmaster@dummy.example.com
        DocumentRoot "C:\xampp\htdocs\Maintenance-Site"
        ServerName car-maintenance-package.lh
        ServerAlias car-maintenance-package.lh
    </VirtualHost>
    Code (markup):
     
    johneva, Feb 16, 2011 IP
  2. mellow-h

    mellow-h Peon

    Messages:
    750
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is not right:

    A single virtualhost can not contain multiple ServerName. That is why there is a serveralias. It can not contain multiple documentroot as well. Otherwise both would create ambiguity in the system.

    This would work, but this would work too:

    Good luck.
     
    mellow-h, Feb 16, 2011 IP