Question

Apache2 stops working randomly on Ubuntu

Posted December 8, 2021 149 views
ApacheDigitalOcean Droplets

I have a droplet in DigitalOcean that connected to domain that purchased from GoDaddy. Using Apache2 for web server. Some times web site is down and any path in www/html folder is not working. It seems like it’s happening randomly. I am not sure about this but if I run “sudo systemctl status apache2” command when web site down, then web site comes back to work and I see everything is fine.

Ubuntu version: 20.04.1 LTS
Apache2 version: 2.4.41

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, @spektragamess

What is the output of the command when you execute:

  • sudo systemctl status apache2

If the Apache server is down you will need to start/restart it with:

  • sudo systemctl start apache2

or

  • sudo systemctl restart apache2

What you can also do is to examine the Apache error log file in order to track down what is causing the issue. You can check the last 200 entries of the file with this command:

  • tail -n 200 /var/log/apache2/error.log

And also check for out of memory or killed processes:

  • grep -i oom /var/log/messages

and

  • grep -i kill /var/log/messages

Hope that this helps!
Regards,
Alex

  • Thanks for your answer.

    Firstly I just want to say I don’t have “messages” folder in “/var/log/” . And also I don’t have “error.log” file in “/var/log/apache2/” folder. For now, the web side is down and I am getting this response if I run “sudo systemctl status apache2” command:

    root@SepktraNew:~# sudo systemctl status apache2
    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
         Active: active (running) since Thu 2021-09-30 06:29:28 UTC; 2 months 8 day>
           Docs: https://httpd.apache.org/docs/2.4/
        Process: 91579 ExecReload=/usr/sbin/apachectl graceful (code=exited, status>
       Main PID: 1206814 (apache2)
          Tasks: 48 (limit: 9513)
         Memory: 685.5M
         CGroup: /system.slice/apache2.service
                 ├─ 162418 /usr/sbin/apache2 -k start
                 ├─ 162595 /usr/sbin/apache2 -k start
                 ├─ 162925 /usr/sbin/apache2 -k start
                 ├─ 162967 /usr/sbin/apache2 -k start
                 ├─ 163019 /usr/sbin/apache2 -k start
                 ├─ 163025 /usr/sbin/apache2 -k start
                 ├─ 163095 /usr/sbin/apache2 -k start
                 ├─ 163164 /usr/sbin/apache2 -k start
                 ├─ 163166 /usr/sbin/apache2 -k start
                 ├─ 163196 /usr/sbin/apache2 -k start
                 ├─ 163197 /usr/sbin/apache2 -k start
                 ├─ 163297 /usr/sbin/apache2 -k start
                 ├─ 163308 /usr/sbin/apache2 -k start
                 ├─ 163311 /usr/sbin/apache2 -k start
    lines 1-23...skipping...
    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
         Active: active (running) since Thu 2021-09-30 06:29:28 UTC; 2 months 8 days ago
           Docs: https://httpd.apache.org/docs/2.4/
        Process: 91579 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
       Main PID: 1206814 (apache2)
          Tasks: 48 (limit: 9513)
         Memory: 685.5M
         CGroup: /system.slice/apache2.service
                 ├─ 162418 /usr/sbin/apache2 -k start
                 ├─ 162595 /usr/sbin/apache2 -k start
                 ├─ 162925 /usr/sbin/apache2 -k start
                 ├─ 162967 /usr/sbin/apache2 -k start
                 ├─ 163019 /usr/sbin/apache2 -k start
                 ├─ 163025 /usr/sbin/apache2 -k start
                 ├─ 163095 /usr/sbin/apache2 -k start
                 ├─ 163164 /usr/sbin/apache2 -k start
                 ├─ 163166 /usr/sbin/apache2 -k start
                 ├─ 163196 /usr/sbin/apache2 -k start
                 ├─ 163197 /usr/sbin/apache2 -k start
                 ├─ 163297 /usr/sbin/apache2 -k start
                 ├─ 163308 /usr/sbin/apache2 -k start
                 ├─ 163311 /usr/sbin/apache2 -k start
                 ├─ 163316 /usr/sbin/apache2 -k start
                 ├─ 163317 /usr/sbin/apache2 -k start
                 ├─ 163319 /usr/sbin/apache2 -k start
                 ├─ 163320 /usr/sbin/apache2 -k start
                 ├─ 163377 /usr/sbin/apache2 -k start
                 ├─ 163444 /usr/sbin/apache2 -k start
                 ├─ 163462 /usr/sbin/apache2 -k start
                 ├─ 163474 /usr/sbin/apache2 -k start
                 ├─ 163507 /usr/sbin/apache2 -k start
                 ├─ 163511 /usr/sbin/apache2 -k start
                 ├─ 163523 /usr/sbin/apache2 -k start
                 ├─ 163582 /usr/sbin/apache2 -k start
                 ├─ 163594 /usr/sbin/apache2 -k start
                 ├─ 163595 /usr/sbin/apache2 -k start
                 ├─ 163641 /usr/sbin/apache2 -k start
                 ├─ 163646 /usr/sbin/apache2 -k start
                 ├─ 163647 /usr/sbin/apache2 -k start
                 ├─ 163652 /usr/sbin/apache2 -k start
                 ├─ 163653 /usr/sbin/apache2 -k start
                 ├─ 163655 /usr/sbin/apache2 -k start
                 ├─ 163688 /usr/sbin/apache2 -k start
                 ├─ 163693 /usr/sbin/apache2 -k start
                 ├─ 163743 /usr/sbin/apache2 -k start
                 ├─ 163746 /usr/sbin/apache2 -k start
                 ├─ 163763 /usr/sbin/apache2 -k start
                 ├─ 163766 /usr/sbin/apache2 -k start
                 ├─ 163767 /usr/sbin/apache2 -k start
                 ├─ 163769 /usr/sbin/apache2 -k start
                 ├─ 163770 /usr/sbin/apache2 -k start
                 ├─ 163772 /usr/sbin/apache2 -k start
                 ├─ 163773 /usr/sbin/apache2 -k start
                 ├─ 163774 /usr/sbin/apache2 -k start
                 ├─ 163775 /usr/sbin/apache2 -k start
                 └─1206814 /usr/sbin/apache2 -k start
    
    Dec 06 00:00:06 SepktraNew apachectl[3571940]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    Dec 06 00:00:06 SepktraNew systemd[1]: Reloaded The Apache HTTP Server.
    Dec 07 00:00:01 SepktraNew systemd[1]: Reloading The Apache HTTP Server.
    Dec 07 00:00:01 SepktraNew apachectl[3931905]: [Tue Dec 07 00:00:01.900585 2021] [alias:warn] [pid 3931905] AH00671: The Alias directive in /etc/phpmyadmin/apache.conf at line 3 will probably never match because it overlaps an earlier A
    
    • Hello, @spektragamess

      It seems like the server might be running of Apache workers. You can check the /var/log/syslog and check for killed processes:

      “command
      grep -i oom /var/log/syslog

      
      and
      
      ```comamnd
      grep -i kill /var/log/syslog
      

      You can check the Apache configuration file and see where the Errors are logged. Check for ErrorLog in the file and it should point you to the correct log file.

      Regards,
      Alex