Apache2 升级版本后无法启动 22:04

cha*_*car 9 apache2 22.04

将 Ubuntu 16.04 升级到 18.04,然后升级到 20.04,最后升级到版本 22.04 后,我收到此错误:

\n

我该如何解决它?

\n
root@vmi155065:/etc/apache2/mods-enabled# sudo service apache2 status\n\xc3\x97 apache2.service - The Apache HTTP Server\n     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)\n     Active: failed (Result: exit-code) since Sun 2022-05-01 17:27:12 CEST; 1 day 20h ago\n       Docs: https://httpd.apache.org/docs/2.4/\n    Process: 621 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)\n        CPU: 31ms\n\nMay 01 17:27:12 vmi155065.contaboserver.net systemd[1]: Starting The Apache HTTP Server...\nMay 01 17:27:12 vmi155065.contaboserver.net apachectl[636]: 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 >\nMay 01 17:27:12 vmi155065.contaboserver.net apachectl[621]: Action 'start' failed.\nMay 01 17:27:12 vmi155065.contaboserver.net apachectl[621]: The Apache error log may have more information.\nMay 01 17:27:12 vmi155065.contaboserver.net systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE\nMay 01 17:27:12 vmi155065.contaboserver.net systemd[1]: apache2.service: Failed with result 'exit-code'.\nMay 01 17:27:12 vmi155065.contaboserver.net systemd[1]: Failed to start The Apache HTTP Server.\n
Run Code Online (Sandbox Code Playgroud)\n

小智 18

当我从 Ubuntu 20 升级到 22 时,我遇到了完全相同的问题。为了使其正常工作,我进行了以下更改。

  • sudo a2dismod php7.4(这是您升级之前的 php 版本)
  • sudo a2enmod php8.1(这是升级后的 php 版本。请通过查看/etc/apache2/mods-available文件夹来验证确切的版本。在我的例子中,我可以看到 php8.1 的最新版本,因此在此命令中相应地提到了)
  • systemctl restart apache2
  • sudo apachectl configtest

您可能想了解更多有关a2dismoda2enmode命令的信息?这是可以详细回答a2dismod, a2enmode 的链接。