Subsys lock problem with CentOS 6.2 and Apache
Posted by on June 11, 2012
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!?!
It was the exact same setup when it was complaining about that lock. But now it worked right away. No idea what’s going on here.
Well as that didn’t confirm anything I had to try again:
Restored the VM snapshot. This is CentOS 6.2, installed on virtualbox from liveCD. Firewall disabled, sshd enabled.
Installed apache:
sudo yum install -y httpd
Status check:
service httpd status
httpd is stopped
Started apache:
sudo service httpd start
Starting httpd: [ OK ]
Status check:
service httpd status
httpd dead but subsys locked
Changed the pidfile variable in /etc/httpd/conf/httpd.conf from this:
PidFile run/httpd.pid
To this:
PidFile /var/run/httpd.pid
Changed the pidfile variable in /etc/sysconfig/httpd from this:
#PIDFILE=/var/run/httpd/httpd.pid
To this:
PIDFILE=/var/run/httpd.pid
Killed httpd processes:
killall -9 httpd
Removed any httpd locks:
sudo rm -f /var/lock/subsys/httpd
Restarted apache:
sudo service httpd restart
Stopping httpd: [ FAILED ]
Starting httpd: [ OK ]
Status check:
service httpd status
httpd (pid 6009) is running...
Finally confirmed that it’s working!
Oh and I will publish the improved LAMP puppet module as soon as I have time to test it.
I have same version of CentOS, same version of Apache and same damn problem. Weird thing is that initally it was working fine. Then I started configuring httpd.conf and suddenly this error although I didn’t change PidFile … To make this post more google friendly add this error message – that’s how I was looking for solution but it didn’t work
Cheers mate!
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]
Thanks for your reply Michal. I’ll add the error message to the original post
I hope you got your Apache working in the end.
Hi,
Initially, this solution worked fine. But when I reboot, the problem occurred again : (
What should I do? There is no more for changing to “PidFile /var/run/httpd.pid”…..
Thank you.
Difficult to say as I can’t reproduce the error. It’s working for me still after several reboots. Check your /etc/sysconfig/httpd once more and make sure the the pidfile is /var/run/httpd.pid and not /var/run/httpd/httpd.pid and that it isn’t commented out (# in front).
Thank very much!! I was search this solution for few days
Whoa, this fixed my problem! Thanks for the post. Make sure to uncomment out the line /etc/sysconfig/httpd because it didn’t work before I did that.