3

I am trying to setup an mobile app that I have received from another dev locally on my machine, this is a cordova based mobile app that is basically html5/javascript etc..

I have added the following line to my .hosts file:

127.0.0.1 app.myapps.local
127.0.0.1 localhost # existing line has always been there #

In my version of WAMP my virtual hosts are found within the following directory:

C:\wamp\vhosts\local.conf

In my virtual hosts file (there are lots of existing vhosts in there) I have added the following new addition

<VirtualHost *:80>
  ServerAdmin me@website.com
  DocumentRoot "c:/wwwroot/app/App/www/app.html"
  ServerName app.myapps.local
<Directory "c:/wwwroot/app/App/www/app.html">
    Options +Indexes
    AllowOverride All
</Directory>
  ErrorLog "c:/wwwroot/app/log/error.log"
  CustomLog "c:/wwwroot/app/log/access.log" common
  LogLevel debug
  SetEnv MANGO_ENVIRONMENT ME
</VirtualHost>

I have restarted apache and flushed the dns but for some reason everytime I load up app.myapps.local in the browser I am presented with the default WAMPSERVER homepage.

Can anyone suggest what could be wrong in my setup?

Zabs
  • 13,852
  • 45
  • 173
  • 297

1 Answers1

2

The C:\wamp\vhosts folder is now a defunct concept and you should use the original wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhost.conf file. And then uncomment the include of that file in the httpd.conf file, its near the bottom of the httpd.conf file.

Also you have not included and instructions to Apache telling it who is allowed to access this site.

There are a few mistakes in the Virtual Host definition you have created as well. You should add a VHOST definintion for localhost as well as your own new sites. Also the DocumentRoot "c:/wwwroot/app/App/www/app.html" is wrong, it should only identify the folder and not include a page name, ditto the <Directory...> parameter.

# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "C:/wamp/www">
        AllowOverride All
        #If APACHE2.4
        #   Require local

        #If APACHE2.2
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1 
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin me@website.com
    DocumentRoot "c:/wwwroot/app/App/www"
    ServerName app.myapps.local

    <Directory "c:/wwwroot/app/App/www">
        AllowOverride All
        Options +Indexes
        #If APACHE2.4
        #   Require local

        #If APACHE2.2
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1 
    </Directory>

    ErrorLog "c:/wwwroot/app/log/error.log"
    CustomLog "c:/wwwroot/app/log/access.log" common
    LogLevel debug
    SetEnv MANGO_ENVIRONMENT ME

    # as you have moved the Apache logs it may also be a good idea
    # to move the php error log as well.
    php_value error_log "c:/wwwroot/app/log/php_error.log"
</VirtualHost>

You now have to create an entry in the C:\windows\system32\drivers\etc\hosts file for each Virtual Hosts so that windows knows where to find the domain you created in your ServerName parameter, as you did, but it is a good idea to add the IPV4 address 127.0.0.1 and the IPV6 address ::1.

#The first 2 line should already be in here
127.0.0.1 localhost
::1 localhost

127.0.0.1 app.myapps.local
::1 app.myapps.local

Once you have made this change you can reload the windows DNS Cache from a command window, this also has to be launched using the Run as Administrator menu option.

net stop dnscache
net start dnscache

You should then be ready to reload Apache to pick up all these changes.

If you get problems, remember Apache writes to the Windows Event Log before it actually opens its own error log. if you have errors in the httpd.conf file or any file included within that file like wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhosts.conf it will identify the line number where an error is found.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • I can see only `httpd-vhosts.conf` file (notice the 's') at `wamp\bin\apache\apachex.y.z\conf\extra\`` There is no `httpd-vhost.conf` file. – Omar Tariq Dec 17 '15 at 13:04
  • @OmarTariq Minor spelling error corrected. It is in fact called `httpd-vhosts.conf` If thats the only problem with this answer I am doing quite well – RiggsFolly Dec 17 '15 at 13:11