Principal Software Engineer Works at Oath: (which acquired Millennial Media) (which acquired Nexage) Lives in Atlanta, GA
Java developer, currently into Scala, likes to tinker, tries to solve all problems in life by writing code and loves the great indoors!
[ Blog ]
Is your Apache 2 server crashing with the error "AH00060: seg fault or similar nasty error detected in the parent process"
? Did you think log_rotate was somehow involved?
I have noticed recently (after a number of upgrades on my Ubuntu machine) that the Apache 2 server would periodically shut down. I looked at the /var/log/apache2/error.log
and sure enough it crashed with the following error:
All googling pointed at log_rotate
being the offender as the shut down would always happen at the exact time (maybe each Sunday morning to rotate the apache logs) for most people. I looked at /etc/logrotate.d/apache2
file and it sure was restarting apache to rotate the logs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/var/log/apache2/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi;
endscript
}
I changed line 12 above to restart
instead of reload
and that stopped apache from shutting down periodically every time the logs had to rotate.
Now it was time to investigate why a reload
is crashing apache. A quick look at /etc/init.d/apache2
script showed that reload
is just a wrapper for apache2ctl graceful
Fortunately, I had a different machine where this was not happening. I got a list of modules that are enabled on that machine and eliminated them from the list of suspects. Starting with each of the remaining enabled modules, I would do the following :
a2dismod
Example : a2dismod access_compat
service apache2 restart
ps -ef | grep apache2 | grep -v grep | wc
service apache2 graceful
ps -ef | grep apache2 | grep -v grep | wc
a2enmod
and restart
a2enmod access_compat && service apache2 restart
ps -ef | grep apache2 | grep -v grep | wc
I did this until I found the offender : mime_magic
. I am not sure how this is causing the crash, but it was in my case.
tl;dr
sudo a2dismod mime_magic && sudo service apache2 restart