Showing posts with label apache not started. Show all posts
Showing posts with label apache not started. Show all posts

Monday, June 2, 2014

httpd dead but pid file exists

Your Apache is not working because it gives following error :
httpd dead but pid file exists

You have tried to restart Apache several times but still it gives same error.
To remove this error, you need to remove Semaphore Arrays of Apache.

Find all Semaphore Arrays of Apache. Run following command in terminal.
ipcs -s | grep apache
Now remove each entry using command
ipcrm -s semid
semid is second column of the table.

If there are multiple entries of Apache and it is difficult to remove each entry individually, Run following command.
for i in `ipcs -s | grep apache | awk '{ print $2 }'` ; do ipcrm -s $i ; done;
If it is not working for you, Run
ipcs -s | grep apache |  perl -e 'while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}'
Now restart Apache. Run following command.
service httpd restart 

Solution : 2
If still you are facing same error after restarting Apache. Run
rm /var/lock/subsys/httpd
and Run
rm /var/run/httpd/httpd.pid
Now restart Apache again.
service httpd restart 
Now what is Semaphore Array
A semaphore is a variable or abstract data type that is used for controlling access, by multiple processes.
In its simplest form a semaphore is a location in memory whose value can be tested and set by more than one process. 
ipcs  provides  information on the ipc facilities for which the calling process has read access.
-s displays semaphore arrays.
ipcrm removes a message queue, semaphore set or shared memory id.