Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-07-15
24
Medium Priority
?
305 Views
Last Modified: 2012-05-07
Hi

1. I have setup a Centos5.2 server on my LAN.
2. It has IP address 192.168.0.100
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 http://192.168.0.100/ 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
     ServerName 192.168.0.100
</VirtualHost>

Open in new window

0
Comment
Question by:lwfuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 9
  • 2
  • +2
24 Comments
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24861993
Check for firewalling.

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


0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24862010
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 http://192.168.0.100/ into my browser and expect to see the apache default page

0
 

Author Comment

by:lwfuk
ID: 24862128
Hi mrjoltcola

> telnet 192.168.0.100 80

Fails.

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?
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:lwfuk
ID: 24862151
Hi mrjoltcola

I used:

#service httpd restart

Is that the same?
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24862161
Yes that should work. Or manually without the init script:  apachectl restart

Try:
ps -ef | grep http

Then:
telnet localhost 80
0
 

Author Comment

by:lwfuk
ID: 24862198
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
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.

Open in new window

0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24862332
Appears that it is listening on localhost port 80, but not listening to other interfaces (192.xxx). Please provide the httpd.conf (relevant portions)
0
 
LVL 29

Expert Comment

by:Jan Springer
ID: 24862426
In httpd.conf:

Listen 192.168.0.100:80

service httpd reload
0
 

Author Comment

by:lwfuk
ID: 24862452
It's just a standard httpd.conf with the following changes.
Listen 192.168.0.100:80
ServerAdmin root@localhost
ServerName 192.168.0.100:80
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
 
<VirtualHost *:80>
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www/html
     ServerName 192.168.0.100
</VirtualHost>

Open in new window

0
 
LVL 1

Expert Comment

by:smary
ID: 24862751
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.
0
 

Author Comment

by:lwfuk
ID: 24862818
Hi Smary

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

Thanks

0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24862841
When you telnet to 192.168.0.100 80

Is connection refused immediately or does it "hang" / timeout?
0
 

Author Comment

by:lwfuk
ID: 24862888
It says it's connecting and then it hangs for about 20-30 seconds
Untitled-1.gif
0
 
LVL 29

Expert Comment

by:Jan Springer
ID: 24862891
I don't use the ServerName directive within a vhost container.
0
 

Author Comment

by:lwfuk
ID: 24862900
PS: I forgot to add the port on the first 2 attempts.
0
 

Author Comment

by:lwfuk
ID: 24862929
I tested the return path by pinging my desktop PC from the server.

All is OK.
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 2000 total points
ID: 24862935
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.

0
 

Author Comment

by:lwfuk
ID: 24862946
Do you know what I would need to type?
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24862980
Try:

service iptables stop

0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24862983
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
0
 

Author Closing Comment

by:lwfuk
ID: 31603872
Mr Jolt Cola

You are the MAN!!!

#service iptables stop

and it works like a charm.

Many Many Thanks.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24863033
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.
0
 

Author Comment

by:lwfuk
ID: 24863065
Many thanks.

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

Kind Regards,

Adrian Smith
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24863130
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


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question