1

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!

John Mee
  • 2,298
  • 1
  • 23
  • 27
Windows Ninja
  • 2,546
  • 18
  • 46
  • 70
  • 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 0.0.0.0:80 0.0.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

3 Answers3

2

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

blackriderws
  • 137
  • 7
1

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

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

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.

user9517
  • 114,104
  • 20
  • 206
  • 289