Unfortunately the apache server has been stopped and when tried to start getting an error like below,


/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]

Apache error log status are,

tail -f /var/log/httpd/error_log

[Thu Jul 24 09:08:38 2014] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Thu Jul 24 14:34:35 2014] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Thu Jul 24 14:41:33 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Jul 24 14:41:34 2014] [notice] Digest: generating secret for digest authentication ...
[Thu Jul 24 14:41:34 2014] [notice] Digest: done
[Thu Jul 24 14:41:42 2014] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Thu Jul 24 14:41:46 2014] [warn] pid file /etc/httpd/run/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Jul 24 14:41:46 2014] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Fri Jul 25 06:39:24 2014] [error] [client 127.0.0.1] (70007)The timeout specified has expired: proxy: error reading status line from remote server localhost
[Fri Jul 25 06:39:24 2014] [error] [client 127.0.0.1] proxy: Error reading from remote server returned by /server-status

Solution 1:

We need to check semaphores on IPCS. IPCS stands for Inter Process Communications and support to different process are Pipes, Message Queue, Shared Memory and Semaphores.

ipcs -s | grep apache

0x00000000 0          apache    600        1         
0x00000000 557057     apache    600        1         
0x00000000 589826     apache    600        1         
0x00000000 622595     apache    600        1         
0x00000000 655364     apache    600        1    
...

-s        - option is used to display the apache accessible semaphores.
ipcrm  - remove an XSI message queue, semaphore set.

ipcs -s | grep apache | awk '{print $2}' | xargs ipcrm sem
resource(s) deleted

or
ipcs -s | grep httpd | awk '{print $2}' | xargs ipcrm sem

Start Apache:

/etc/init.d/httpd start
Starting httpd:                                            [  OK  ]

Solution 2:

Check whether the apache server currently running on which port number using the netstat command,

netstat -ltnp | grep 'httpd'

tcp        0      0 :::80                       :::*                        LISTEN      29636/httpd         
tcp        0      0 :::443                      :::*                        LISTEN      29636/httpd    

fuser -k -n tcp 80
80/tcp:              29599 29601 29602 29603 29604 29605 29606 29607 29608 29609   

fuser - To determine which process is using the files or sockets  
-k      -  Kill processes accessing the file.
-n      - Select a different name space file TCP and UDP sockets.

Now, be ensuring the apache server is running.


ps aux | grep httpd

root     29636  8.5  1.2  32932 12940 ?        Ss   09:40   0:00 /usr/sbin/httpd
apache   29637  0.0  0.3  22464  3260 ?        S    09:40   0:00 /usr/sbin/httpd
apache   29639  0.0  0.7  33092  7600 ?        S    09:40   0:00 /usr/sbin/httpd
apache   29641  0.0  0.7  33092  7592 ?        S    09:40   0:00 /usr/sbin/httpd

Solution 3 :

Kill all the apche process using pkill command and start it again,
 
pkill -9 httpd

Solution 4:

Another options are check tcp connection,
 
# netstat -anp | grep 80

tcp        0      0 4.2.2.2:80            94.23.49.89:61956           SYN_RECV    -                   
tcp        0      0 4.2.2.2:80            213.136.88.4:58691          SYN_RECV    -                   
tcp        0      0 4.2.2.2:80            37.59.235.164:57532         SYN_RECV    -                   
tcp        0      0 4.2.2.2:80            104.143.23.160:34186        SYN_RECV    -
# fuser -k -n tcp 80

80/tcp:              12592 18105
# netstat -anp | grep 80

-k     Kill processes accessing the file.An fuser process never kills itself, but may kill other fuser processes.
-n      Select  a different name
 
# /etc/init.d/httpd start

Starting httpd:                               [  OK  ]