Apache2 failing unexpectedly

Posted August 31, 2021 110 views
ApacheUbuntu 20.04

I am running Ubuntu 20.04 as a web server on a cloud instance. There I have installed apache 2. Daily, I need to restart the instance or the apache2.service to restore access to the website.

sudo systemctl status apache2.service

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-08-31 19:45:10 UTC; 3h 50min ago
   Main PID: 1092 (code=exited, status=1/FAILURE)

Aug 31 19:42:17 bhub systemd[1]: Starting The Apache HTTP Server...
Aug 31 19:42:18 bhub systemd[1]: Started The Apache HTTP Server.
Aug 31 19:45:10 bhub systemd[1]: apache2.service: Main process exited, code=exited, status=1/FAILURE
Aug 31 19:45:10 bhub systemd[1]: apache2.service: Failed with result 'exit-code'.

sudo apache2ctl configtest

Syntax OK

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hello, @jllandivarscott

I will recommend you examine the Apache error_logs in order to track down the exact issue.

To examine log files for errors while troubleshooting Apache on a Fedora, CentOS, or RedHat server, examine the /var/log/httpd/error_log file.

If you are troubleshooting a Debian or Ubuntu derived system, examine /var/log/apache2/error.log for errors using a tool like tail or less. For example, to view the last two lines of the error log using tail, run the following command:

  • sudo tail -n 2 /var/log/apache2/error.log

Substitute the number of lines that you would like to examine in place of the number 2 in the command. On a CentOS or Fedora system, the log file to examine is /var/log/httpd/error_log.

You can also follow our tutorial on How To Troubleshoot Common Apache Errors


by Jamon Camisso
There are three main commands, and a set of common log locations that you can use to get started troubleshooting Apache errors. Generally when you are troubleshooting Apache, you will use these commands in the order indicated here, and then examine log files for specific…