無法在執行 PHP 8.1.2 的 Ubuntu 22.04 上啟動 Apache。如何安裝缺少的 PHP 載入模組?

無法在執行 PHP 8.1.2 的 Ubuntu 22.04 上啟動 Apache。如何安裝缺少的 PHP 載入模組?

我使用的是 Ubuntu 22.04。我最近將 PHP 從 7.4 升級到 8.1

PHP版本:

PHP 8.1.2-1ubuntu2.8 (cli) (built: Nov  2 2022 13:35:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.8, Copyright (c), by Zend Technologies

阿帕契版本:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2022-06-14T12:30:21

當運行以下命令時,

$ sudo service apache2 restart

我得到這個:

Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xeu apache2.service" for details.

跑步apachectl configtest給了我以下:

apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.4.load: Cannot load /usr/lib/apache2/modules/libphp7.4.so into server: /usr/lib/apache2/modules/libphp7.4.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.

我查看了/etc/apache2/mods-enabled/資料夾內部,但沒有 PHP 8.1 的模組。我只能看到php7.4.load

解決這個問題的正確方法是什麼?看起來我缺少該模組,但不知道如何安裝它並繼續進一步配置。

請建議!

相關內容