Re: Test Web page problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.
It always helps people trying to help you, if you specify the type of system you are talking about (server, laptop, Windows, Linux, etc..) and the version of Apache (1.something, 2.something). Many people here are clever, some of them are even wizards, but even they have trouble guessing this at a distance.
And the answers may be a bit different (as in this case).

Blake Simmons wrote:
Hi,
I have a problem with my Apache web server (or at least I think I do) that prevents me from
accessing my web site's home page from my own computer.. Instead, it shows a "It Works!" page

Very good ! it means at least that Apache is working.

when I try to access the site through my domain name or localhost.
However, when I access my domain name from another computer, or type in 127.0.0.1
in my browsers address bar, my web site's home page appears.
Can you please explain to me why this happens, and what I can do to fix it?

From the above, we can guess that it probably is not a problem of Apache. How is that for wizardry, he ? Better even : the problem is most probably due to a Name Resolution failure.

Explanation (you asked for it) :

When you type in your browser's URL bar a URL like
http://mycomputer.mydomain.com/something/somethingelse
your browser understands that it should
- contact some other computer, whose name is "mycomputer.mydomain.com"
- that it should do that using the HTTP protocol (the "http://"; bit)
- that it should request from that computer the "object" named "/something/somethingelse" (or if you don't enter anything there, it just means you want the object named "/").

The TCP/IP protocol used to communicate between computers on the Internet, does not work with computer "names". That's only for humans.
Instead, it works with IP addresses (like 127.0.0.1).
Thus, when you type "mycomputer.mydomain.com", the first thing your browser must do, is to get a translation for this name into an IP address.

There are essentially two places it can get it, in this order :
- from a local file called "hosts" (that's true under Windows and under Unix/Linux, but they are not in the same place)
- or from some external translating system known as DNS

If you are under Windows, the "hosts" file is usually located in
C:\windows\system32\drivers\etc\hosts
and under Unix/Linux, at
/etc/hosts

If you examine that file, you will see that there is usually a first line like this :
127.0.0.1 localhost
(and if it isn't there, add it, because it should).
(by convention, under TCP/IP, 127.0.0.1 is always an address for the local computer)

Let's bring this all together now :

a) If in your browser's address bar, you enter
http://127.0.0.1/something/somethingelse
your browser has no problem at all finding the correct Apache computer to which to send the request, because you already provide the IP address, and it does not even have to translate it.

b) If in your browser you type :
http://localhost/something/somethingelse
it is a bit more work for the browser, but it still does not have much trouble : using the local "hosts" file, it can easily translate "localhost" to 127.0.0.1 (the local computer), and so it also knows
to send the request to the local Apache.

c) but if you enter
http://mycomputer.mydomain.com/something/somethingelse
then your browser (who is also not a wizard, and does not know by itself that this is the name under which other computers know this one), has to look for a translation. So it will look first into the local hosts file to find a translation for "mycomputer.mydomain.com". If it does not find it there, it will ask some other system (the DNS) to provide a translation. If that other system does not know (or does not answer, or returns some false address), then your browser will not be able to send the request to your local Apache, and it will appear as if Apache is not working.

The solution :
In your hosts file, add a line like
127.0.0.1 mycomputer.mydomain.com

then close your browser, re-open it, and try again.
If it works, I thank you because I have just earned enough credits for a promotion to Wizard, 3rd class.

To be totally honest, I do not know at this point why, when you enter
http://localhost
it currently appears not to work.  It must be because the line
127.0.0.1 localhost
is missing from your local hosts file, or you don't have a local hosts file. But both of these are strange.

André

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux