(168) 【解決】Ubuntu 22.04→24.04に更新したらApache2が動かなくなった。

投稿者: | 2025年5月15日

602 views

問題発生

自宅サーバの OSを Ubuntu22.04から 24.04にアップグレードした。

すると…
このサーバに置いてある Webサイトにアクセスできなくなった。

原因調査&対策

Apache2の状態を確認する。

$ sudo systemctl status apache2
× apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Thu 2025-05-15 06:56:41 JST; 3min 53s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 1041 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
        CPU: 14ms

 5月 15 06:56:41 systemd[1]: Starting apache2.service - The Apache HTTP Server...
 5月 15 06:56:41 apachectl[1081]: apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2>
 5月 15 06:56:41 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
 5月 15 06:56:41 systemd[1]: apache2.service: Failed with result 'exit-code'.
 5月 15 06:56:41 systemd[1]: Failed to start apache2.service - The Apache HTTP Server.

Syntax error on line 146 of /etc/apache2/apache2.conf
とのこと。

設定ファイルが書き換えられたのか?
それとも設定ファイルに書かれているリンク先が消えたりしたのか?

エラーログを見てみることにする。

$ sudo journalctl -u apache2.service -b
 5月 15 06:56:41 systemd[1]: Starting apache2.service - The Apache HTTP Server...
 5月 15 06:56:41 apachectl[1081]: apache2: Syntax error on line 146 of /etc/apache2/apache2.conf:
 Syntax error on line 3 of /etc/apache2/mods-enabled/php8.1.load: Cannot load /usr/lib/apache2/modules/libphp8.1.so >
 5月 15 06:56:41 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
 5月 15 06:56:41 systemd[1]: apache2.service: Failed with result 'exit-code'.
 5月 15 06:56:41 systemd[1]: Failed to start apache2.service - The Apache HTTP Server.

原因は libphp8.1.so がロードできないとのこと。
OS Updateで PHPバージョンが入れ替わったのか?

PHPバージョンを確認してみる。

$ php -v
PHP 8.3.6 (cli) (built: Mar 19 2025 10:08:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

PHP8.3にアップグレードされている。
Apach2の設定もこれに合わせて変更する。

$ sudo a2dismod php8.1                     # 古いモジュールを無効化
$ sudo apt install libapache2-mod-php8.3   # Apache2用PHP8.3モジュールをインストール 
$ sudo a2enmod php8.3                      # 新しいモジュールを有効化

新しい設定で問題ないか?

$ sudo apachectl configtest
Syntax OK

OKだ!
Apache2を再起動し、状態を確認する。

$ sudo systemctl restart apache2
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running) since Thu 2025-05-15 07:04:54 JST; 8s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 4253 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
      Tasks: 28 (limit: 19103)
     Memory: 33.8M (peak: 40.3M)
        CPU: 144ms
     CGroup: /system.slice/apache2.service
             ├─4283 /usr/sbin/apache2 -k start
             ├─4287 "Passenger watchdog"
             ├─4290 "Passenger core"
             ├─4311 /usr/sbin/apache2 -k start
             ├─4312 /usr/sbin/apache2 -k start
             ├─4313 /usr/sbin/apache2 -k start
             ├─4314 /usr/sbin/apache2 -k start
             └─4315 /usr/sbin/apache2 -k start

 5月 15 07:04:53 systemd[1]: Starting apache2.service - The Apache HTTP Server...
 5月 15 07:04:54 systemd[1]: Started apache2.service - The Apache HTTP Server.

OKだ!
正常に起動するようになった。
WebブラウザからのアクセスもOKだ!

Subversionにも繋げなくなっていた…

勝手に configファイルが書き換えられていたようだ。
これも直す。

$ sudo vi /etc/apache2/mods-available/dav_svn.conf

まるごと消えていたので、https://???.???.???.???/svn/ のアクセス先を再設定する。

<Location /svn>
  DAV svn
  SVNParentPath /var/svn/repos
</Location>

Apache2を再起動する。

$ sudo systemctl restart apache2

Subversionも使えるようになった。


アクセス数(直近7日): ※試験運用中、BOT除外簡易実装済
  • 2025-09-26: 0回
  • 2025-09-25: 3回
  • 2025-09-24: 8回
  • 2025-09-23: 4回
  • 2025-09-22: 2回
  • 2025-09-21: 6回
  • 2025-09-20: 3回
  • コメントを残す

    メールアドレスが公開されることはありません。 が付いている欄は必須項目です