How do I Setup Apache to respond to server IP address.


1. I have setup a Centos5.2 server on my LAN.
2. It has IP address
3. I have installed apache 2 with yum
4. #top tells me that it's running
5. Ping tells me that my desktop computer can see the server
6. I created a directory called /var/www/html/
7. I ran #chown -R apache:apache /var/www/html
8. I setup the vhost directive as shown below
9. I type into my browser and expect to see the apache default page
10. I don't

Anybody know why?

Kind Regards,
<VirtualHost *:80>
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www/html

Open in new window

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.

Check for firewalling.

Can you access the port locally from the same server? (ie.   telnet 80)

In your list of steps you did not say whether you restarted apache with apachectl

>>6. I created a directory called /var/www/html/
>>7. I ran #chown -R apache:apache /var/www/html
>>8. I setup the vhost directive as shown below

restart apache here

>>9. I type into my browser and expect to see the apache default page

lwfukAuthor Commented:
Hi mrjoltcola

> telnet 80


I switched off my PC firewall but still no good.

There shouldn't be any filtering on the lan side of my router should there?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

lwfukAuthor Commented:
Hi mrjoltcola

I used:

#service httpd restart

Is that the same?
Yes that should work. Or manually without the init script:  apachectl restart

ps -ef | grep http

telnet localhost 80
lwfukAuthor Commented:
Here are the results

[root@localhost www]# ps -ef | grep http
root      3810     1  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3812  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3813  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3814  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3815  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3816  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3817  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3818  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
apache    3819  3810  0 09:41 ?        00:00:00 /usr/sbin/httpd
root      3857  3289  0 10:02 pts/0    00:00:00 grep http
[root@localhost www]# telnet localhost 80
Connected to localhost.localdomain (
Escape character is '^]'.

Open in new window

Appears that it is listening on localhost port 80, but not listening to other interfaces ( Please provide the httpd.conf (relevant portions)
Jan SpringerCommented:
In httpd.conf:


service httpd reload
lwfukAuthor Commented:
It's just a standard httpd.conf with the following changes.
ServerAdmin root@localhost
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
<VirtualHost *:80>
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www/html

Open in new window

I assume that your port 80 is not blocked.
If it is blocked, then issue this command:

# iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Check your /var/log/messages and httpd_error.log and paste if you get some error messages there.
lwfukAuthor Commented:
Hi Smary

I ran the command anyway and no change I'm affraid.


When you telnet to 80

Is connection refused immediately or does it "hang" / timeout?
lwfukAuthor Commented:
It says it's connecting and then it hangs for about 20-30 seconds
Jan SpringerCommented:
I don't use the ServerName directive within a vhost container.
lwfukAuthor Commented:
PS: I forgot to add the port on the first 2 attempts.
lwfukAuthor Commented:
I tested the return path by pinging my desktop PC from the server.

All is OK.
This sounds like firewall. When a port is not open and a firewall is not in the way, the connection will be refused immediately. I say try to disable the Linux firewall temporarily for a sanity check.

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
lwfukAuthor Commented:
Do you know what I would need to type?

service iptables stop

AS Every one said, its a firewall issue

You dont have to change any configuraion in httpd.conf to allow it telnet to port 80

if your iptables is open for port 80 , it will allow

can you post the output
cat /etc/sysconfig/iptables

I need to see if you have any rules for selinux or not
lwfukAuthor Commented:
Mr Jolt Cola

You are the MAN!!!

#service iptables stop

and it works like a charm.

Many Many Thanks.
Ok, but that is not a permanent solution, unless you do have a secondary firewall. If this is open to the net, you need to re-configure the firewall to allow port 80. So your root problem is solved, now perhaps post a related question for firewall config help.

Personally I do not run firewalls on my internal boxes, I simply turn off most services, and run Cisco firewalls at the border to the dmz.
lwfukAuthor Commented:
Many thanks.

I have an external firewall and I only want to use it as a testing server.

Kind Regards,

Adrian Smith
Also, be aware, iptables will restart when you reboot. :)

If you have the CentOS desktop open, try Services Configuration Tool (run system-config-services ) and disable what you don't want, including iptables.

Or you can remote the script from /etc/rc*.d

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
Apache Web Server

From novice to tech pro — start learning today.