localhost isnt working!

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

localhost isnt working!

Post 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.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
Last edited by anjanesh on Sun Jun 13, 2004 2:08 am, edited 2 times in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Check your httpd.conf and make sure DirectoryIndex is something like:
DirectoryIndex index.php index.html

(then restart apache)

*beaten to it* :o
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Post by snpo123 »

index.php is already added to the directory index in httpd.conf, so i dont think thats the problem. Any other ideas?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Out of interest if you goto http://127.0.0.1 does that make any difference?
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Post 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. :(
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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)
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Post 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. 8O The first link (with the slash at the end) never worked from the start. Could it be my internet browser (im using IE)?
Last edited by snpo123 on Sun Jun 13, 2004 2:31 am, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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)
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Post by snpo123 »

127.0.0.1 localhost is already added to the end of hosts :(
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Could just be caching it then. Try clearing IE's cache, closing the browser, opening it and trying again *shrug*
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Post by snpo123 »

How do I clear the cache?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

tools > internet options

'delete files' button.. 'delete cookies' button... close and restart IE.
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Post 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? :?:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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? :P
Post Reply