0

I'm using Ubuntu 18.04. I seem to be unable to restart Apache2 using "sudo apachectl start". I see this

~$ sudo apachectl start
Invoking 'systemctl start apache2'.
Use 'systemctl status apache2' for more info.
Job for apache2.service failed because a timeout was exceeded.
See "systemctl status apache2.service" and "journalctl -xe" for details.
Action 'start' failed.
The Apache error log may have more information.

when I check the status, I see

$ sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: timeout) since Fri 2021-01-22 16:01:25 UTC; 2min 2s ago
  Process: 1453 ExecStart=/usr/sbin/apachectl start (code=killed, signal=TERM)

Jan 22 15:56:25 prod systemd[1]: Starting The Apache HTTP Server...
Jan 22 15:56:25 prod apachectl[1453]: Invoking 'systemctl start apache2'.
Jan 22 15:56:25 prod apachectl[1453]: Use 'systemctl status apache2' for more info.
Jan 22 16:01:25 prod systemd[1]: apache2.service: Start operation timed out. Terminating.
Jan 22 16:01:25 prod systemd[1]: apache2.service: Failed with result 'timeout'.
Jan 22 16:01:25 prod systemd[1]: Failed to start The Apache HTTP Server.

and "journalctl -xe" says ...

$ sudo journalctl -xe
Jan 22 15:56:25 prod apachectl[1453]: Use 'systemctl status apache2' for more info.
Jan 22 16:00:00 prod sshd[1475]: Received disconnect from 113.128.15.170 port 50036:11: Bye Bye [preauth]
Jan 22 16:00:00 prod sshd[1475]: Disconnected from authenticating user root 113.128.15.170 port 50036 [preauth]
Jan 22 16:00:01 prod CRON[1477]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 22 16:00:01 prod CRON[1478]: (root) CMD (/bin/bash -l -c '/opt/scripts/import_coop_data_from_google_sheet.sh >> /tmp/cronoutput.txt 2>&1')
Jan 22 16:00:18 prod sshd[1499]: Received disconnect from 218.93.208.150 port 25505:11:  [preauth]
Jan 22 16:00:18 prod sshd[1499]: Disconnected from authenticating user root 218.93.208.150 port 25505 [preauth]
Jan 22 16:00:44 prod CRON[1477]: (CRON) info (No MTA installed, discarding output)
Jan 22 16:00:44 prod CRON[1477]: pam_unix(cron:session): session closed for user root
Jan 22 16:01:25 prod systemd[1]: apache2.service: Start operation timed out. Terminating.
Jan 22 16:01:25 prod sudo[1446]: pam_unix(sudo:session): session closed for user root
Jan 22 16:01:25 prod systemd[1]: apache2.service: Failed with result 'timeout'.
Jan 22 16:01:25 prod systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit apache2.service has failed.
-- 
-- The result is RESULT.
Jan 22 16:02:26 prod sshd[1525]: Received disconnect from 221.181.185.135 port 57424:11:  [preauth]
Jan 22 16:02:26 prod sshd[1525]: Disconnected from authenticating user root 221.181.185.135 port 57424 [preauth]
Jan 22 16:02:28 prod sshd[1528]: Invalid user drcomadmin from 207.244.247.57 port 45316
Jan 22 16:02:28 prod sshd[1528]: Received disconnect from 207.244.247.57 port 45316:11: Bye Bye [preauth]
Jan 22 16:02:28 prod sshd[1528]: Disconnected from invalid user drcomadmin 207.244.247.57 port 45316 [preauth]
Jan 22 16:03:07 prod sudo[1531]: davea : TTY=pts/0 ; PWD=/home/davea ; USER=root ; COMMAND=/bin/systemctl status apache2.service
Jan 22 16:03:07 prod sudo[1531]: pam_unix(sudo:session): session opened for user root by davea(uid=0)
Jan 22 16:03:09 prod sudo[1531]: pam_unix(sudo:session): session closed for user root
Jan 22 16:03:28 prod sudo[1535]: davea : TTY=pts/0 ; PWD=/home/davea ; USER=root ; COMMAND=/bin/systemctl status apache2.service
Jan 22 16:03:28 prod sudo[1535]: pam_unix(sudo:session): session opened for user root by davea(uid=0)
Jan 22 16:03:28 prod sudo[1535]: pam_unix(sudo:session): session closed for user root
Jan 22 16:03:47 prod sudo[1538]: davea : TTY=pts/0 ; PWD=/home/davea ; USER=root ; COMMAND=/bin/journalctl -xe
Jan 22 16:03:47 prod sudo[1538]: pam_unix(sudo:session): session opened for user root by davea(uid=0)

But oddly, when I run "sudo apachectl restart", Apache comes up and I can interact with it

$ sudo apachectl restart
httpd not running, trying to start

What's going on? Below is my service configuration file ...

$ sudo cat /lib/systemd/system/apache2.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
EnvironmentFile=/etc/environment
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
Restart=on-abort
TimeoutStartSec=300

[Install]
WantedBy=multi-user.target

1 Answer 1

0

In theory, it is setup as a service on the system and doing the program executable to try and restart the service will not work. You should be using "systemctl restart apache2". To stop it, "systemctl stop apache2" and to start "systemctl start apache2"

http://manpages.ubuntu.com/manpages/bionic/man5/systemd.service.5.html

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.