Solved

CentOS:  Cant start httpd

Posted on 2011-03-12
22
943 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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
 
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 77

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 77

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

830 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