I've just deployed a new CentOS 5.7 box with a base install. After the base install I ran

yum install httpd

and confirmed that Apache was installed.

I created a test index.html file in /var/www/html/ and then restarted apache expecting that when I connect to the server in a browser that the test page would be displayed.

However, when I connect, all I see is:

ERROR Service Unavailable

The requested service is unavailable.

Please try again later.

I'm sure there is something very simple that I'm missing here but I don't have a lot of linux experience so I'm hoping somebody can lend a hand.

Thanks in advance!

  • Have you verified that apache is actually running? "ps auxw |grep http". Also, "netstat -pntl |grep 80" should slow your httpd process LISTENing on port 80. – cjc Feb 16 '12 at 17:41
  • When I ran the netstat command it came up blank so it would appear that apache is not running as you suggested may be possible. I will google how to start it up...thanks. – Windows Ninja Feb 16 '12 at 17:44
  • I ran "apachectl start" and it said command not found so I ran "/usr/sbin/apachectl start" and then ran your netstat command and it now says "tcp 0 0* LISTEN 7847/httpd" However, when I try to connect to the site it still shows the same error. – Windows Ninja Feb 16 '12 at 17:46

By default CentOS has a firewall enabled. You need to open port 80 in your firewall to allow access to the apache server.

sudo iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT

If this works then

sudo service iptables save

to save the working configuration for the next restart.

  • This answer would have worked as well but unfortunately I already awarded it...I appreciate your help with this. – Windows Ninja Feb 16 '12 at 17:56
  • When I try to input the rule I run into an error...something simple likely again but since it is a different question I will ask another question for it, thanks. – Windows Ninja Feb 16 '12 at 17:58
  • error message ? – user9517 Feb 16 '12 at 18:02
  • It was resolved here: serverfault.com/questions/360914/… – Windows Ninja Feb 16 '12 at 19:01

Try This:

Service iptables stop
service httpd restart

NOTE: the reason is that by default CentOS installation has the Firewall On, then what we did here is to disable it, but when you restart then activates again with this command: "chkconfig iptables off" we disable it permanently.

but you can also add a rule to allow port rute 80 if you want

  • This was the answer I needed. Can you explain why this worked and then I'll award you the check? Thanks for your help. – Windows Ninja Feb 16 '12 at 17:47
  • The first command will turn off the firewall. So, it looks like the firewall was running. – cjc Feb 16 '12 at 17:50
  • Thanks for this blackridersws. I'm going to look up how to add that rule to allow port 80 now. I knew this must have been something simple and it was...I appreciate your help. – Windows Ninja Feb 16 '12 at 17:55
  • Telling people to disable their firewall when there is an equally easy and better solution really is a bad idea. – user9517 Feb 16 '12 at 18:00
  • Agreed, I've changed the accepted answer to yours, thank you. – Windows Ninja Feb 16 '12 at 18:02

Check to make sure you have a valid hosts entry in /etc/hosts. Apache won't start successfully without it.

  • Anaconda is especially brain-dead when it comes to generating the hosts file at install. It always puts the hostname on Applications like Oracle don't like this. – James O'Gorman Feb 16 '12 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.