Solved

CentOS:  Cant start httpd

Posted on 2011-03-12
22
933 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:detox1978
  • 10
  • 8
  • 2
  • +1
22 Comments
 
LVL 7

Expert Comment

by:compaqus
ID: 35118024
to see who's using the port:
nmap -T Aggressive -A -v 127.0.0.1 -p 80
0
 
LVL 2

Author Comment

by:detox1978
ID: 35118040
-bash-3.2# nmap -T Aggressive -A -v 127.0.0.1 -p 80
-bash: nmap: command not found
0
 
LVL 7

Expert Comment

by:compaqus
ID: 35118044
also change permissions on apache's log file, it seems unable to write it or find it.
0
 
LVL 7

Expert Comment

by:compaqus
ID: 35118050
to install nmap:
sudo yum install nmap
0
 
LVL 2

Author Comment

by:detox1978
ID: 35118051
where is the log located and what should the chmod be?
0
 
LVL 2

Author Comment

by:detox1978
ID: 35118067
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
 
LVL 7

Expert Comment

by:compaqus
ID: 35118114
the location is usually /var/log/httpd/
should be 644

also run netstat just to verify:
netstat --tcp --udp --listening --program
0
 
LVL 2

Author Comment

by:detox1978
ID: 35118141
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
 
LVL 7

Expert Comment

by:compaqus
ID: 35118147
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
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 167 total points
ID: 35118149
Are you 100% httpd didn't start?  It would be highly unusual to have anything else running on port 80.
0
 
LVL 7

Expert Comment

by:compaqus
ID: 35118152
it looks like it's already running...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Expert Comment

by:Tintin
ID: 35118154
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
 
LVL 76

Assisted Solution

by:arnold
arnold earned 166 total points
ID: 35118160
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
 
LVL 2

Author Comment

by:detox1978
ID: 35118187
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
 
LVL 2

Author Comment

by:detox1978
ID: 35118190
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
 
LVL 7

Expert Comment

by:compaqus
ID: 35118194
you have to check the error log see what's being said there.
0
 
LVL 2

Author Comment

by:detox1978
ID: 35118198
where is the error log?

I'm fairly new to centos.
0
 
LVL 7

Accepted Solution

by:
compaqus earned 167 total points
ID: 35118199
it is unable to bind, since it is already started and listening on 80
0
 
LVL 7

Expert Comment

by:compaqus
ID: 35118202
usually in
/var/log/httpd/httpd-error.log
0
 
LVL 2

Author Comment

by:detox1978
ID: 35118234
The SSL certificate was causing the issue.  I've removed it from httpd.config and the service started ok.
0
 
LVL 76

Expert Comment

by:arnold
ID: 35118241
/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
 
LVL 7

Expert Comment

by:compaqus
ID: 35118245
:) glad you've sorted it out.
cheers!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now