CentOS: Cant start httpd

Hi All,

Recently i made a few changes to my CentOS VPS (installed DNS, a few certificates and change some chmod permissions).  Everything seemed to have worked well.  

However when I rebooted the server the httpd service didn't start.  When i try to start it manually I get the following error.






-bash-3.2# /etc/init.d/httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
                                                           [FAILED]

Open in new window

LVL 2
detox1978Asked:
Who is Participating?
 
compaqusConnect With a Mentor Commented:
it is unable to bind, since it is already started and listening on 80
0
 
compaqusCommented:
to see who's using the port:
nmap -T Aggressive -A -v 127.0.0.1 -p 80
0
 
detox1978Author Commented:
-bash-3.2# nmap -T Aggressive -A -v 127.0.0.1 -p 80
-bash: nmap: command not found
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
compaqusCommented:
also change permissions on apache's log file, it seems unable to write it or find it.
0
 
compaqusCommented:
to install nmap:
sudo yum install nmap
0
 
detox1978Author Commented:
where is the log located and what should the chmod be?
0
 
detox1978Author Commented:
I've installed nmap. results below
-bash-3.2# nmap -T Aggressive -A -v 127.0.0.1 -p 80

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-03-12 22:40 GMT
Initiating SYN Stealth Scan against forum.mydomain.net (127.0.0.1) [1 port] at 22:40
Discovered open port 80/tcp on 127.0.0.1
The SYN Stealth Scan took 0.01s to scan 1 total ports.
Initiating service scan against 1 service on forum.mydomain.net (127.0.0.1) at 22:40
Stats: 0:00:31 elapsed; 0 hosts completed (1 up), 1 undergoing Service Scan
Service scan Timing: About 0.00% done; ETC: 02:09 (-596:-31:-54 remaining)
The service scan took 113.51s to scan 1 service on 1 host.
Warning:  OS detection will be MUCH less reliable because we did not find at lea                                             st 1 open and 1 closed TCP port
For OSScan assuming port 80 is open, 34841 is closed, and neither are firewalled
For OSScan assuming port 80 is open, 40169 is closed, and neither are firewalled
For OSScan assuming port 80 is open, 42055 is closed, and neither are firewalled
Host forum.mydomain.net (127.0.0.1) appears to be up ... good.
Interesting ports on forum.mydomain.net (127.0.0.1):
PORT   STATE SERVICE VERSION
80/tcp open  http?
Device type: general purpose|printer|broadband router|telecom-misc
Running (JUST GUESSING) : Linux 2.4.X|2.5.X|2.6.X|2.3.X (95%), Lexmark embedded                                              (93%), D-Link embedded (93%), Wooksung embedded (93%)
Aggressive OS guesses: Linux 2.4.0 - 2.5.20 (95%), Linux 2.4.18 (95%), Linux 2.4                                             .18 - 2.4.20 (x86) (95%), Linux 2.4.20 (X86, Redhat 7.3) (95%), Linux 2.4.21 (x8                                             6, RedHat) (95%), Linux 2.4.22 (SPARC) (95%), Linux 2.4.30 (95%), Linux 2.4.7 -                                              2.6.11 (95%), Linux 2.5.25 - 2.6.8 or Gentoo 1.2 Linux 2.4.19 rc1-rc7 (95%), Lin                                             ux 2.6.0-test10 (x86) (95%)
No exact OS matches for host (test conditions non-ideal).
TCP Sequence Prediction: Class=random positive increments
                         Difficulty=2034515 (Good luck!)
IPID Sequence Generation: All zeros

Nmap finished: 1 IP address (1 host up) scanned in 123.087 seconds
               Raw packets sent: 46 (3548B) | Rcvd: 105 (6488B)
-bash-3.2#

Open in new window

0
 
compaqusCommented:
the location is usually /var/log/httpd/
should be 644

also run netstat just to verify:
netstat --tcp --udp --listening --program
0
 
detox1978Author Commented:
The log files were all set to 644.


-bash-3.2# netstat --tcp --udp --listening --program
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 dns1.mydomain.com:mysql       *:*                         LISTEN      3471/mysqld
tcp        0      0 *:ftp                       *:*                         LISTEN      3391/vsftpd
tcp        0      0 vm7401.mydomain.com:smtp *:*                         LISTEN      3553/master
tcp        0      0 *:http                      *:*                         LISTEN      3582/httpd
tcp        0      0 *:ssh                       *:*                         LISTEN      3377/sshd
tcp        0      0 *:https                     *:*                         LISTEN      3582/httpd
-bash-3.2#

Open in new window

0
 
compaqusCommented:
you should have 2 log files:
httpd-error.log
httpd-access.log

If there are missing, create them ( touch /var/log/httpd/httpd-error.log ) and chmod 664 them
user and group should be apache or httpd (not sure, i don't have a centos install here to check)
0
 
TintinConnect With a Mentor Commented:
Are you 100% httpd didn't start?  It would be highly unusual to have anything else running on port 80.
0
 
compaqusCommented:
it looks like it's already running...
0
 
TintinCommented:
Didn't see your netstat output before posting my last comment.

The netstat output shows that you do indeed have httpd running.  What made you think it wasn't?
0
 
arnoldConnect With a Mentor Commented:
run the following command in the shale which will tell you definitively what service is bound to port 80
lsof -i:80
service httpd status
0
 
detox1978Author Commented:
None of the websites are accessible and when starting httpd it said failed.

But it does look like it's running, just not working as expected.
-bash-3.2# lsof -i:80
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
httpd   3582 root    4u  IPv6   8033       TCP *:http (LISTEN)

Open in new window

0
 
detox1978Author Commented:
output below;
-bash-3.2# /etc/init.d/httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
                                                           [FAILED]
-bash-3.2# service httpd status
httpd is stopped
-bash-3.2#

Open in new window

0
 
compaqusCommented:
you have to check the error log see what's being said there.
0
 
detox1978Author Commented:
where is the error log?

I'm fairly new to centos.
0
 
compaqusCommented:
usually in
/var/log/httpd/httpd-error.log
0
 
detox1978Author Commented:
The SSL certificate was causing the issue.  I've removed it from httpd.config and the service started ok.
0
 
arnoldCommented:
/var/log/httpd
run the following command to see whether your virtualhosts are being processed provided you added them /etc/httpd/conf.d/

/usr/sbin/apachectl -t -D DUMP_VHOSTS
0
 
compaqusCommented:
:) glad you've sorted it out.
cheers!
0
All Courses

From novice to tech pro — start learning today.