Skip to content Skip to sidebar Skip to footer

I have a problem with Apache not running after Logrotate Activity

Issue

Hi guys, in this article i will discuss my case with Apache cant running. You can see that on picture bellow.

# systemctl status httpd
status apache
status apache


In picture you can see output is "Failed to start The Apache HTTP Server" but you can't see clue what caused. next you must see the error.log to search clue.

# cd /etc/var/log
# cat error.log
error.log
error.log

yeay we got the output of error

[Thu Sep 10 03:19:02.257198 2020] [core:error] [pid 25553] (13)Permission denied: AH00099: could not create /run/httpd/httpd.pid
[Thu Sep 10 03:19:02.257342 2020] [core:error] [pid 25553] AH00100: httpd: could not log pid to file /run/httpd/httpd.pid


ok from this output of error you must analysis with the that directory "/run/httpd/" why permission denied.

# cd /
# ll
directory run
directory run
# cd run
# ll
directory httpd
directory httpd
# cd httpd
# ll
content of directory httpd
content of directory httpd

Solving

for solving is very simple just delete httpd.pid on directory /run/httpd/ 

# rm -rf /run/httpd/httpd.pid
delete httpd.pid
delete httpd.pid


after delete that you must restart service apache

# systemctl restart httpd


and see what happen

# systemctl status httpd


Cause

but this solving just temporary, on my case after analysis, the caused of Apache not running is after Logrotate Activity.


From the issue above, I can conclude that at 03.11 WIB there was an apache service activity ordered an automatic reload due to Logrotate routine every 7 days / Weekly. However there was a bug to reload itself so failure for the command caused the Service Apache failed process / not up.


You can the config of logrotate

# cat /etc/logrotate.conf
logrotate.conf
logrotate.conf


and see the logrotate of httpd

# cat /etc/logrotate.d/httpd
logrotate of httpd
logrotate of httpd


From the picture above, when postrotate there is a command systemctl reload httpd.service. you can try the command to try it. Surely it will fail up and cause the apache service not running.


Resolution

To make sure this event doesn't repeat itself there I recommend overriding configure from the logrotate.conf. 


Change from reload to restart

# vi /etc/logrotate.d/httpd
change logrotate of httpd
change logrotate of httpd

and you must change permission of directory /run/httpd to 770

# chmod 770 /run/httpd
change permission of directory /run/httpd
change permission of directory /run/httpd

Note : 

# systemctl reload httpd 

After you made changes to your CentOS Apache configuration file, you can use the reload option to reload the httpd.conf file without closing currently open http connections.

# systemctl restart httpd 

We can use the reload option to just reload the httpd.conf file instead of restarting the ntire httpd process


Post a Comment for " I have a problem with Apache not running after Logrotate Activity"