0

I installed WAMP and followed this guide to set up virtual hosts. In both Google Chrome and Internet Explorer, http://localhost gets me to "WAMPSERVER homepage" with my virtual host listed under "Your Projects."

Clicking that link to http://mysite.local in Chome brings me to my site as expected.

Clicking that link in Internet Explorer displays the following message instead.

This page can’t be displayed

•Make sure the web address http://mysite.local is correct.

•Look for the page with your search engine.

•Refresh the page in a few minutes.

Since I can see the WAMPSERVER homepage as expected in both browsers, I don't think there's a problem with my WAMP installation. Since my virtual host is working in Chrome, I think it must be configured properly in Apache and in my Windows hosts file.

I just don't understand why Internet Explorer isn't working with my virtual host like I expect it to, and the "Page can't be displayed" message doesn't give me anything helpful to work with.

Does anyone have any suggestions for me? I'd greatly appreciate any pointers or links to other guides I can try. Thanks in advance for any replies!

Community
  • 1
  • 1
Avai
  • 3
  • 5
  • Are your `vhosts` definitions included in `httpd.conf`? Also check your local hosts file to make sure that it points to 127.0.0.1 for your local site. Further to this - you'll need to make sure that your browser isn't caching things (chrome has a habit of doing this quite a bit). – ScottMcGready Sep 06 '15 at 13:58
  • @ScottMcGready Thanks for your comment. The only change I made in httpd.conf was to uncomment the line after # Virtual hosts which is Include conf/extra/httpd-vhosts.conf, so I think I'm good there. My Windows hosts file has 127.0.0.1 mysite.local and ::1 mysite.local, the same for localhost. I'm certain Chrome is caching things. I'll see if I can completely disable that somehow. – Avai Sep 06 '15 at 14:16
  • Probably worth including the custom vhost config in your question... might be that. – ScottMcGready Sep 06 '15 at 14:18
  • Make sure the httpd.conf file you're editing is the one that Apache is using! Oh and remember to restart WAMP each time you make a change – ScottMcGready Sep 06 '15 at 14:26
  • @ScottMcGready I found port 8888 hard coded in one of my site's files, leftover from a previous installation on a Mac with MAMP. So now everything's working as expected in Chrome, but IE is still giving me the same message. – Avai Sep 06 '15 at 15:00
  • cache. Try clearing IE's cache. – ScottMcGready Sep 06 '15 at 15:02
  • Clearing IE's cache did the trick! Thanks so much for your help, Scott. You're an excellent person. :) – Avai Sep 06 '15 at 15:21
  • glad that worked. I've summarised my comments into an answer (saves any future users having to dig through comments that may get deleted). If you think it answered your question you can click the green tick beside the answer/alternatively list exactly what you did in your answer and mark your own as the accepted answer and I can delete mine. Glad you're up and working! – ScottMcGready Sep 06 '15 at 18:07

1 Answers1

1

There's several reasons WAMP/MAMP may not work on a local environment, I'll try to list a few reasons here:

Which httpd.conf?

There are sometimes multiple httpd.conf files that can cause things to go a little bit funny. MAMP/WAMP usually tend to keep all their configuration files within a conf/ directory however, that doesn't mean to say some other httpd.conf file is being used...

You can also run this command on Linux based systems to see which one is being used:

apache2ctl -V | grep SERVER_CONFIG_FILE

vhosts definitions not included in httpd.conf

In the httpd.conf file, there's a line to include the vhosts definitions file, it should be uncommented:

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf // remove the #

Incorrect vhosts definitions

Vhosts need to be defined as follows:

<VirtualHost *>
    DocumentRoot "C:/path/to/your/local/site"
    ServerName mydomain.local
</VirtualHost>

Hosts file

On OS X/Linux systems this can be found at etc/hosts. Edit that to reflect below (note, you'll need to be root)

127.0.0.1    mysite.local

On windows systems, it can be found in %SystemRoot%\System32\drivers\etc\hosts.

Browser caches

Browser caches always cause an issue with local servers/development. It's worth working with incognito mode on, or deleting all browser caches each and every time you open it up. There's a few plugins available for most browsers that should help too.

Other points to note

  • Whenever you edit anything to do with httpd.conf, vhosts, hosts file - WAMP/MAMP/Apache needs to be restarted. It's a good idea to shut the server down before doing the changes.
  • You mentioned that there was a hardcoded link in one/some of your files. It's generally regarded as bad practise to do that for this exact reason. Your code is less portable and can 'break' on other systems. I'd suggest using PHP's __FILE__ or similar to achieve what you want.
    • Alternatively you could set up local configuration files for your app that are only included when they're present. Have a look at this for a good example of such a set up.
  • Log everything. Check the logs regularly too.
ScottMcGready
  • 1,612
  • 2
  • 24
  • 33