Link to home
Start Free TrialLog in
Avatar of aej1973
aej1973

asked on

Setting up virtual hosts in apache ver 2.4.9 (WAMP, Windows 2012)

Hello, I have a wamp server running and my conf/extra/httpd-vhosts.conf configuration is as follows;

On my httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

On my c:\xampp\apache\conf\extra\httpd-vhost.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80

# for localhost to work properly
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory  "c:/wamp/www">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "c:\wamp\www\folder01"
    ServerName demo.re-web.com
    ServerAlias demo.re-web.com
    ErrorLog "logs/mysite-error.log"
    CustomLog "logs/mysite-access.log" common
    <Directory  "c:\wamp\www\dds">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www\folder02"
    ServerName stage1.re-web.com
    ServerAlias stage1.re-web.com
    ErrorLog "logs/mysite-error.log"
    CustomLog "logs/mysite-access.log" common
    <Directory  "c:\wamp\www\dds">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

Open in new window


my hosts file is:
127.0.0.1       localhost
127.0.0.1       demo.re-web.com
127.0.0.1       stage.re-web.com
127.0.0.1       stage1.re-web.com
::1             localhost
::1             stage.re-web.com
::1             demo.re-web.com
::1             stage1.re-web.com

Open in new window


The issue I am having is that when is use stage1.re-web.com (or any of the other virtual sites ) the  site that always comes up is my localhost content and not the folder that I have pointed my virtual site to (folder 01 / folder 02). How can I correct this issue?

Thanks,
A
SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aej1973
aej1973

ASKER

When you say 'default Virtual host' do you mean the following lines?
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory  "c:/wamp/www">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

Open in new window

That could be it.  You can check for sure by opening a command prompt, changing directories into your apache2\bin, and running:
httpd -S

Open in new window

The output of that command will list all the defined virtual hosts and their files, though not necessarily in order.  You can go through each of those to discover in what order they are being included, and modify that order if necessary.

Also, make sure you have a "NameVirtualHost *:80" somewhere in your config.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aej1973

ASKER

Thank you all...