Problem with vhosts or hosts files - going to localhost 'homepage' (using WAMPServer)

I am trying to set up a mobile app that I got from another developer on my machine, it is a cordova based mobile app which is basically html5 / javascript etc.

I 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 WAMP version, my virtual hosts are in the following directory:

C:\wamp\vhosts\local.conf

      

In my virtual hosts file (there are many existing vhosts there) I 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 restarted apache and reset the dns, but for some reason every time I load app.myapps.local in the browser I am presented with the default WAMPSERVER home page.

Can anyone suggest what might be wrong with my setup?

+3


source to share


1 answer


The folder is C:\wamp\vhosts

now a defunct concept and you must use the original file wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhost.conf

. And then uncomment the inclusion of that file in the file httpd.conf

located at the bottom of the file httpd.conf

.

Also, you have not indicated or told Apache instructions who is allowed to access this site.

There are several errors in the definition of the virtual host you created. You have to add VHOST definition for localhost as well as your own new sites. Also wrong DocumentRoot "c:/wwwroot/app/App/www/app.html"

, it should only identify the folder and not include the page name, not the parameter <Directory...>

.

# 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>

      

Now, you need to create a file entry C:\windows\system32\drivers\etc\hosts

for each virtual host so that windows knows where to find the domain you created in the parameter ServerName

, just like you do, but it's a good idea to add an IPV4 127.0.0.1

address and an 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

      

After you make this change, you can restart the Windows cache server from the command line, this also needs to be started from the menu item Run as Administrator

.

net stop dnscache
net start dnscache

      

Then you should be ready to restart Apache to get all these changes.

If you have problems, remember that Apache writes to the Windows event log before it actually opens its own error log. if you have errors in your httpd.conf file or any file included in that file for example wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhosts.conf

it will identify the line number where the error was found.

+2


source







All Articles