Tuesday, April 26, 2016

HTTPD issue: Subsys lock problem with CentOS 6.2 and Apache

Subsys lock problem with CentOS 6.2 and Apache

While I was improving my LAMP module I ran in to a problem with Apache 2.2.15 on CentOS 6.2.
Apache wasn’t working with my new module so I decided to install it normally via yum and see what’s going on.
Got it installed just fine with:
yum install httpd
Ran sudo service httpd restart.
All went fine.
But now when I checked status:
service httpd status
httpd dead but subsys locked

Tried to delete the lock:
sudo rm -f /var/lock/subsys/httpd
Didn’t help. It’s still giving the same lock message. The Apache actually works as it’s serving my web pages but the service status is not working as it should. And this is a problem with my Puppet LAMP module.
UPDATE: As pointed out in the comments, here’s another related error message that you might get when you try to restart httpd:
service httpd restart
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address 10.10.26.11:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
I have also tried rebooting the box and updating packages with yum update but didn’t help.
I started examining httpd.conf and noticed that the PidFile variable was set to run/httpd.pid by default.
Changed it to point to /var/run:
PidFile /var/run/httpd.pid
And also changed the variable in /etc/sysconfig/httpd:
PIDFILE=/var/run/httpd.pid
Killed the httpd processes:
killall -9 httpd
Removed the lock:
sudo rm -f /var/lock/subsys/httpd
Restarted apache:
sudo service httpd restart
And now it works:
service httpd status
httpd (pid 14331) is running...
Now I wanted to test this again to confirm that this solution works so I restored my virtualbox snapshot from the time when apache was not installed on the CentOS. Installed it again same way with yum. Checked httpd status and it was stopped. Restarted the httpd service and it went OK. Checked the status now presuming that it would complain about the lock again:
httpd (pid 13298) is running…
It’s working!?!

No comments:

Post a Comment