우분투 18.04를 사용하고 있습니다. "sudo apachectl start"를 사용하여 Apache2를 다시 시작할 수 없는 것 같습니다. 나는 이것을 본다
~$ 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.
상태를 확인해보니
$ 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.
"journalctl -xe"는 다음과 같이 말합니다.
$ 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)
그런데 이상하게도 "sudo apachectl restart"를 실행하면 Apache가 나타나서 상호 작용할 수 있습니다.
$ sudo apachectl restart
httpd not running, trying to start
어떻게 되어가나요? 아래는 내 서비스 구성 파일입니다 ...
$ 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
이론상으로는 시스템에 서비스로 설정되어 있으므로 서비스를 다시 시작하기 위해 실행 가능한 프로그램을 실행해도 아무런 효과가 없습니다. "systemctl restart apache2"를 사용해야 합니다. 중지하려면 "systemctl stop apache2"를 입력하고 "systemctl start apache2"로 시작하세요.
http://manpages.ubuntu.com/manpages/bionic/man5/systemd.service.5.html