I have a problem with Apache not running after Logrotate

I have a problem with Apache not running after Logrotate
I have a problem with Apache not running after Logrotate

I have a problem with Apache not running after Logrotate - Welcome to our troubleshooting guide for resolving Apache startup issues following Logrotate activities. In this article, we'll delve into a common scenario where Apache fails to start after logrotate, examining the root causes, troubleshooting steps, and effective resolutions. Apache, as a widely used web server, plays a critical role in serving web content efficiently.

However, occasional hiccups in its operation, especially post-Logrotate, can disrupt service availability. Through this guide, we aim to provide clarity and actionable solutions to address these challenges, ensuring the smooth operation of your Apache web server on Red Hat Enterprise Linux 7 (RHEL 7).

Let's dive in and unravel the mysteries behind Apache startup issues post-Logrotate.

Issue

# systemctl status httpd
status apache
status apache

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

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

yeah we got the output of the 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 analyze with the directory "/run/httpd/" why permission was 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 deleting that you must restart the service apache

# systemctl restart httpd

and see what happen

# systemctl status httpd

Cause

but this solution is just temporary, In my case after analysis, the cause 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 that ordered an automatic reload due to the logrotate routine every 7 days / Weekly. However, there was a bug to reload itself so failure for the command caused the Service Apache to fail process / not up.

You can the config of log rotate

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

and see the log rotate 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 and cause the Apache service not to run.

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 log rotate 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 whole httpd process

Closing statement

In conclusion, troubleshooting Apache startup issues following Logrotate activities requires a systematic approach to identify and address the root causes effectively. By analyzing error logs, examining Logrotate configurations, and implementing appropriate resolutions such as adjusting permissions and modifying Logrotate settings, users can ensure the uninterrupted operation of their Apache web servers on RHEL 7. 

This guide has provided insights and actionable steps to resolve common Apache startup issues post-Logrotate, empowering administrators and users to maintain robust and reliable web server environments. 

With the knowledge gained from this troubleshooting process, users can confidently manage and optimize their Apache servers, delivering seamless web services to their users and customers. Thank you for joining us on this troubleshooting journey, and we hope this guide has been valuable in resolving your Apache startup issues.

Maybe that's all I can share with you guys, hopefully this article will be useful.

Thank You 

Bangkit Ade Saputra
Bangkit Ade Saputra At the end of the day, my job involves people. we're complicated, we're always changing, we have millions of things going on in our lives, and changing jobs is always a big decision.

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