■概要
Apacheのバージョンアップをした際に
バージョンアップはされたがApacheが起動しなかったので
その時の対応をまとめたものとなります。
■OS等
・OS:AmazonLinux2
・Apacheバージョンアップ前:[root@xxxxx ~]# httpd -v
Server version: Apache/2.4.53 ()
Server built: Apr 12 2022 12:00:44
[root@xxxxx ~]#
・Apacheバージョンアップ後:[root@xxxxx ~]# httpd -v
Server version: Apache/2.4.59 ()
Server built: Apr 22 2024 13:07:26
[root@xxxxx ~]#
■実際にやったこと
①yum update list にてApacheのバージョンアップが可能であることを確認[root@xxxxx ~]# yum list updates |grep httpd
httpd.x86_64 2.4.59-1.amzn2 amzn2-core
httpd-filesystem.noarch 2.4.59-1.amzn2 amzn2-core
httpd-tools.x86_64 2.4.59-1.amzn2 amzn2-core
[root@xxxxx ~]#
②アップデートを実施し、Apacheのバージョン・起動確認を実施
・バージョンアップは無事に完了[root@xxxxx ~]# httpd -v
Server version: Apache/2.4.59 ()
Server built: Apr 22 2024 13:07:26
[root@xxxxx ~]#
・Apacheの起動が失敗していることを確認[root@xxxxx conf]# systemctl -l status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: failed (Result: exit-code) since Fri 2024-06-14 10:38:18 JST; 1min 9s ago
Docs: man:httpd.service(8)
Process: 28456 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 28456 (code=exited, status=1/FAILURE)
Status: "Reading configuration..."
Jun 14 10:38:18 xxxxx systemd[1]: Starting The Apache HTTP Server...
Jun 14 10:38:18 xxxxx httpd[28456]: (98)Address already in use: AH00072: make_sock:could not bind to address [::]:80
Jun 14 10:38:18 xxxxx httpd[28456]: (98)Address already in use: AH00072: make_sock:could not bind to address 0.0.0.0:80
Jun 14 10:38:18 xxxxx httpd[28456]: no listening sockets available, shutting down
Jun 14 10:38:18 xxxxx httpd[28456]: AH00015: Unable to open logs
Jun 14 10:38:18 xxxxx systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 14 10:38:18 xxxxx systemd[1]: Failed to start The Apache HTTP Server.
Jun 14 10:38:18 xxxxx systemd[1]: Unit httpd.service entered failed state.
Jun 14 10:38:18 xxxxx systemd[1]: httpd.service failed.
[root@xxxxx conf]#
■原因調査
①「staus」と「jounalctl -xe」のコマンドを確認してみる
※statusのコマンド結果は上記に記載しているため割愛
・「jounalctl -xe」のコマンド結果[root@xxxxx ~]# journalctl -xe
-- Unit httpd.service has failed.
-- The result is failed.
Jun 14 10:09:41 xxxxx systemd[1]: Unit httpd.service entered failed state.
Jun 14 10:09:41 xxxxx systemd[1]: httpd.service failed.
Jun 14 10:09:56 xxxxx systemd[1]: Cannot add dependency job for unit httpd-init.serv
Jun 14 10:09:56 xxxxx systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit httpd.service has begun starting up.
Jun 14 10:09:56 xxxxx kernel: xfs filesystem being remounted at /tmp supports timest
Jun 14 10:09:56 xxxxx kernel: xfs filesystem being remounted at /var/tmp supports ti
Jun 14 10:09:56 xxxxx httpd[24821]: httpd (pid 1124) already running
Jun 14 10:09:56 xxxxx systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit httpd.service has failed.
-- The result is failed.
Jun 14 10:09:56 xxxxx systemd[1]: Unit httpd.service entered failed state.
Jun 14 10:09:56 xxxxxx systemd[1]: httpd.service failed.
Jun 14 10:10:01 xxxxx systemd[1]: Started Session 121860 of user root.
-- Subject: Unit session-121860.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit session-121860.scope has finished starting up.
-- The start-up result is done.
Jun 14 10:10:01 xxxxx CROND[24830]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 14 10:11:10 xxxxx dhclient[2077]: XMT: Solicit on eth0, interval 115880ms.
「status」「jounalctl -xe」ともに「既に起動している」とのエラーメッセージが記載されていました。
・「status」のコマンド結果抜粋Jun 14 10:38:18 xxxxx httpd[28456]: (98)Address already in use: AH00072: make_sock:could not bind to address 0.0.0.0:80
・「jounalctl -xe」のコマンド結果抜粋Jun 14 10:09:56 xxxxx httpd[24821]: httpd (pid 1124) already running
調べてみると、どうやらApacheの古いプロセスが残っているのが原因で
古いプロセスを「kill」することで解決するとのこと。
■古いプロセスをkill
①Apacheのプロセスを確認[root@xxxxx ~]# ps -ef |grep httpd
apache 2732 1 0 10:47 ? 00:00:00 /usr/sbin/httpd -k start
apache 2763 1 0 10:47 ? 00:00:00 /usr/sbin/httpd -k start
root 2870 2196 0 10:47 pts/0 00:00:00 grep --color=auto httpd
[root@xxxxx ~]#
②プロセス「2732」「2763」をkillする[root@xxxxx ~]# kill -9 2732
[root@xxxxx ~]# kill -9 2763
③残っているプロセスがないか確認 → 問題なさそう。[root@xxxxx ~]# ps -ef |grep httpd
root 2924 2196 0 10:48 pts/0 00:00:00 grep --color=auto httpd
[root@xxxxx ~]#
④Apacheを起動し、ステータスを確認する[root@xxxxx ~]# systemctl start httpd
[root@xxxxx ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Fri 2024-06-14 10:48:07 JST; 8s ago
Docs: man:httpd.service(8)
Main PID: 2932 (httpd)
Status: "Total requests: 7; Idle/Busy workers 100/0;Requests/sec: 1; Bytes served/sec: 678 B/sec"
Memory: 26.8M
CGroup: /system.slice/httpd.service
├─2932 /usr/sbin/httpd -DFOREGROUND
├─2934 /usr/sbin/httpd -DFOREGROUND
└─2948 /usr/sbin/httpd -DFOREGROUND
Jun 14 10:48:07 xxxxx systemd[1]: Starting The Apache HTTP Server...
Jun 14 10:48:07 xxxxx systemd[1]: Started The Apache HTTP Server.
[root@xxxxx ~]#
無事にApacheが起動しました!!