Apache server suddenly stopped. Which logs we should check?

Y I
Y I used Ask the Experts™
on
Apache server suddenly stopped.  Although we tried to reboot, it stuck. To find the root cause, which logs we should check?

[root@servername ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
[root@servername ~]# systemctl stop httpd
[root@servername ~]# systemctl start httpd
its stuck

It's appreciate your advices.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Principal Software Engineer
Commented:
Issue "apachectl stop" or "apache2ctl stop" from a priv account.  Then look in the log directory for "error_log."  If Apache logged anything useful before it hung, it will be the last thing, or nearly the last thing, in that file.

If there's nothing useful in the log file, delete all logs and restart Apache.

If that fails, shut down the system, restart the system and see if Apache starts properly on the restart.  If it does not, issue "apachectl -E /var/log/apfail" (or wherever) and see if it logs anything in that file.

Don't forget to syntax check the Apache config files in case somebody diddled them -- "apachectl -t" -- the result should be "Syntax OK."

I have never been a fan of using "systemctl" to control Apache, as it lacks some of the useful features of apachectl and I don't trust systemd.  But you pays your money and you takes your choice, EMMV.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Which logs you check will vary in name, based on your Distro + if you're using your Distro's actual Apache package or you've done a source build.

If you've installed Distro packages, you'll normally find /var/log/httpd or /var/log/apache2 contains a file named error.log or something similar.

If you're running in some sort of shared hosting environment then, as Dr. Klahn mentioned, likely you'll have an error_log file somewhere.

Once you find your error log file, attach the entire file to this question. Also, if your system does file rotation also post the error.log.1 file, which will be the previous day's logs.
Y I

Author

Commented:
Thank you very much for the information. httpd could restart by using httpd start instead of systemctl.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Maybe the systemd Apache control files are somehow munged on your machine.

Look in /var/log/messages or /var/log/sysctl or wherever your logs are generated for systemd logging.

If you're unsure, you can determine log files in use by installing the inotify-tools package, then...

# in one window run...
inotifywait -mrq /var/log

# in another window run...
service httpd restart

Open in new window


When systemd runs to start httpd, you'll see every log file touched in your first window's inotifywait output.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial