EC2にて、初めてApacheを起動しようとしたらエラー。
suEXECが原因だったっぽい。
エラー
[ec2-user@aws-test ~]$ sudo service httpd start Redirecting to /bin/systemctl start httpd.service Job for httpd.service failed because the service did not take the steps required by its unit configuration. See "systemctl status httpd.service" and "journalctl -xeu httpd.service" for details.
[ec2-user@aws-test ~]$ systemctl status httpd.service × httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: failed (Result: protocol) since Thu 2023-10-10 20:50:10 JST; 43s ago Docs: man:httpd.service(8) Process: 2743 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS) Main PID: 2743 (code=exited, status=0/SUCCESS) Status: "Reading configuration..." CPU: 37ms Oct 10 20:51:14 aws-test systemd[1]: Starting httpd.service - The Apache HTTP Server... Oct 10 20:51:14 aws-test httpd[2743]: httpd (pid 2469) already running Oct 10 20:51:14 aws-test systemd[1]: httpd.service: Failed with result 'protocol'. Oct 10 20:51:14 aws-test systemd[1]: Failed to start httpd.service - The Apache HTTP Server.
プロセスを消す
apacheが再起動できなくなった
linux - systemctl restart httpd Failed to start The Apache HTTP Server httpd pid already running - Stack Overflow
こちらなどをみると、既存プロセスが専有中(already running)だから、PIDを削除すればよさそう。
しかし、そんなプロセスは上がっていないので違うと思われる。そもそも一回も起動してない。
ついでにec2-userでログインしているからなのか、httpd.pidファイルをfindしても権限外でヒットしない。
ログを確認
[ec2-user@aws-test ~]$ sudo less /var/log/httpd/error_log [Thu Oct 10 20:50:47.339081 2023] [suexec:notice] [pid 2449:tid 2449] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Thu Oct 10 20:50:47.371717 2023] [lbmethod_heartbeat:notice] [pid 2469:tid 2469] AH02282: No slotmem from mod_heartmonitor [Thu Oct 10 20:50:47.372703 2023] [systemd:notice] [pid 2469:tid 2469] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [Thu Oct 10 20:50:47.377719 2023] [mpm_event:notice] [pid 2469:tid 2469] AH00489: Apache/2.4.56 (Amazon Linux) configured -- resuming normal operations
suEXECを無効化してみる
suEXECを無効化するにはファイルを削除してよいということなので、削除。
[ec2-user@aws-test ~]$ ls -la /usr/sbin/suexec -r-x--x---. 1 root apache 24296 Mar 17 2023 /usr/sbin/suexec [ec2-user@aws-test ~]$ sudo mv /usr/sbin/suexec /usr/sbin/suexecbkup [ec2-user@aws-test ~]$ ls /usr/sbin/suexec /usr/sbin/suexecbkup ls: cannot access '/usr/sbin/suexec': No such file or directory /usr/sbin/suexecbackup
リブートしたら無事、立ち上がりました。
2行目のNo slotmen from mod_heartmonitorもオフってよいものらしいが、ひとまず起動したので今回は放置。
参考
助かりました。
qiita.com