Localhost not working after update

For some reason http://localhost has stopped working on my test server.

My /etc/hosts file looks like this

127.0.0.1 localhost laptop

when I try

/etc/init.d/networking restart

I get the following message

Ignoring unknown interface eth0=eth0 [OK]

Please help
LVL 1
narmi2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kruger_monkeyCommented:
What about apache?

If you ping localhost does it respond?

Check if httpd is running  /etc/init.d/httpd status

Might just be your apache that isn't running.
0
narmi2Author Commented:
i can ping localhost ok

when I try to restart apache, i get

apache2: could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
0
Kruger_monkeyCommented:
That error doesn't stop apache starting, it's more of a warning to say it doesn't know what the username is.  Can you now go to http://localhost?

To get rid of that error edit your config file (httpd.conf) and add the following line.

Servername localhost (or whatever name you need)
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

narmi2Author Commented:
localhost still does not work.

It says

http://localhost/ is not available
0
narmi2Author Commented:
should my

/etc/apache2/httpd.conf

file be empty?
0
narmi2Author Commented:
ok I added

ServerName localhost

to

/etc/apache2/apache2.conf

and that warning no longer comes up when i restart the apache server.  But i still cannot view localhost via a browser.
0
narmi2Author Commented:
I just tried restarting apache again and I got the following

* restarting web server apache2
httpd (no pid file) not running
[ok]
0
Kruger_monkeyCommented:
Actually sounds like your system is using apache2.conf instead of httpd.conf so it being empty might be ok.

Can you get the output of the following, straight after trying to start apache again.

/etc/init.d/httpd status

tail -20 /var/log/message

tail -20 /var/log/httpd/error.log

If your paths are slightly different you may have to locate the file.  Just do locate error.log

0
narmi2Author Commented:
when I do

/etc/init.d/httpd status

I get

bash: /etc/init.d/httpd: no such file or directory

so I tried

/etc/init.d/apache2 status

and I got

* usage: /etc/init.d/apache2 {start|stop|restart|force-reload|start-htcacheclean|stop-htcacheclean}
0
Kruger_monkeyCommented:
Ah differences between distros.  IN that case try the following

netstat -a|grep http

If that restuns nothing then just run netstat -a, you are looking for anything like http, apache or anything listening on port 80.

What about the other files/outputs?
0
InsoftserviceCommented:
hi,

I dont think so it issue of ur apache,
Just check whether ur n/w is working fine
just type

ifconfig

secondly do virtualhost of ur website





0
Kruger_monkeyCommented:
Just a thought, with most of your stuff referencing apache2 your logs probably live in
/var/log/apache2/
0
InsoftserviceCommented:
hi,

NameVirtualHost *:80

<VirtualHost *:80>
      ServerName www.narmi2.com
      DocumentRoot /var/path of ur www
</VirtualHost>

/hosts

just add a tab and write www.armi2.com
that's it
0
narmi2Author Commented:
@ kruger_monkey:

I have attached the file you wanted to see

@ insoftservice:

Where do I add that text?
messages
netstat
error.log
0
Kruger_monkeyCommented:
Well looking at the files apache is NOT running which is why you can't browse to it.  There is nothing listening on port 80 and apache stops immediatly.  Looking at the various files for and indicator.
0
InsoftserviceCommented:
hi,

virtual host data has to be added on last line of apache2.conf
please take backup of it

and second one in hosts file
127.0.0.1 localhost www.narmi2.com

and restart ur httpd service

and check
its not exact solution.

but a chk  
0
Kruger_monkeyCommented:
After the above can you do the followign for me in order.

/etc/init.d/apache2 start

straight after get me the /var/log/apache2/error.log again.

Then run ps -ef|grep apache - let me know if anything lists.
0
narmi2Author Commented:
I have attached the output you wanted to see.
error.log
psef
0
narmi2Author Commented:
I've just accedently noticed something, which might help solve this problem.

Basically, I use my laptop offline for a lot of development work, so I normally do not have an ethernet cable plugged in and http://localhost/ normally works without an ethernet cable plugged in.  However, I just realised that the http://localhost/ only works now when the ethernet cable is plugged in...

Why would this be happening, and how do I get it back to how it was?  i.e. http://localhost/ should work with or without the ethernet cable plugged in.
0
Kruger_monkeyCommented:
Well it looks like apache is now running.

It might just be that you have to tell your browser to work offline.  If it is already set to work offline, then remove the offline setting.

I've seen that before where the network cable is unplugged, I think it was with firefox, setting it to offline (or putting it online, I forget the details) sorted that problem.

Can you try that and let me know.
0
narmi2Author Commented:
The problem has been resolved by removing "laptop" from the hosts file.

The host file looked like this
127.0.0.1 localhost laptop

It now lools like this
127.0.0.1 localhost

Now http://localhost/ works as expected, with or without an ethernet cable plugged in.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
narmi2Author Commented:
However, I have no idea how that "laptop" got there in the first place after a system update.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.