Page 1 of 2
localhost isnt working!
Posted: Sun Jun 13, 2004 1:51 am
by snpo123
Up until recently,
http://localhost/ would bring up the index of my local apache server. A while back I installed apache, php and mysql on my computer. If I ever wanted to test a script, typing in
http://localhost worked fine. But now all of the sudden it wont work when I type it in. My computer treats it as if it were a real web address, and when it cant find it on the web it brings up one of those Lycos search pages where the address you typed in is presented as a search query. I do know that apache is somewhat working, because when i go to
http://localhost/index.php it brings up the index of my local server. All other pages work if I type it in this way too, but when an address is typed in anything but manually (after logging in, a redirect ect.) they don't. Can anyone tell me what the problem is and how to fix it? Thanks.
Posted: Sun Jun 13, 2004 2:05 am
by anjanesh
That means your apache is installed ok. You must search for Directory Index in httpd.conf (missed this) file and you should find index.html Just add (blank and then index.php) index.php and apache will load index.php by typing the folder name in the address bar.
Posted: Sun Jun 13, 2004 2:06 am
by markl999
Check your httpd.conf and make sure DirectoryIndex is something like:
DirectoryIndex index.php index.html
(then restart apache)
*beaten to it*

Posted: Sun Jun 13, 2004 2:08 am
by snpo123
index.php is already added to the directory index in httpd.conf, so i dont think thats the problem. Any other ideas?
Posted: Sun Jun 13, 2004 2:15 am
by markl999
Out of interest if you goto
http://127.0.0.1 does that make any difference?
Posted: Sun Jun 13, 2004 2:18 am
by snpo123
That works fine. I guess I could just use 127.0.0.1, but eventually I would like to know why localhost isnt working.

Posted: Sun Jun 13, 2004 2:21 am
by markl999
What OS?
If your on *nix check your /etc/hosts has an entry similar to:
127.0.0.1 debian localhost
(replace debian with whatever the ouput of the command 'hostname' returns)
Posted: Sun Jun 13, 2004 2:25 am
by snpo123
Im using windows XP with apace 1.3
And I just discovered something new:
When I went to the top of this post, I clicked on the second localhost link I wrote (the one without the slash at the end). It worked when I clicked on it (meaning it brought up my index.php)! Then I tried typing it in manually in the address bar. It started not working again. Then when I clicked that link it suddendly stopped working.

The first link (with the slash at the end) never worked from the start. Could it be my internet browser (im using IE)?
Posted: Sun Jun 13, 2004 2:30 am
by markl999
Try editing c:\windows\system32\drivers\etc\hosts then and adding:
127.0.0.1 localhost
(some spyware/adware programs may overwrite this so make a backup after you've edited it)
Posted: Sun Jun 13, 2004 2:33 am
by snpo123
127.0.0.1 localhost is already added to the end of hosts

Posted: Sun Jun 13, 2004 2:49 am
by markl999
Could just be caching it then. Try clearing IE's cache, closing the browser, opening it and trying again *shrug*
Posted: Sun Jun 13, 2004 1:29 pm
by snpo123
How do I clear the cache?
Posted: Sun Jun 13, 2004 1:31 pm
by feyd
tools > internet options
'delete files' button.. 'delete cookies' button... close and restart IE.
Posted: Sun Jun 13, 2004 3:38 pm
by snpo123
tried that, and it didnt work.
I also noticed that the other files that were not workng didnt work because of a bug in my php scripts. That means that all files on my apache server work fine when I type them in. Now the only problem that exists is when I go to
http://localhost it doesnt bring up my index page. But when I go to
http://my IP address or
http://127.0.0.1 it works fine and brings up my index page. Does this make the problem any clearer?

Posted: Sun Jun 13, 2004 3:46 pm
by feyd
sounds like your hosts file is screwed up..
The great Google knows all:
http://www.accs-net.com/hosts/how_to_use_hosts.html
try restarting.. after that.. I dunno.. format?
