简体   繁体   English

Apache2 升级到 Ubuntu 22.04 LTS 后无法启动 - 无法加载 /usr/lib/apache2/moduleslibphp8.0.so [关闭]

[英]Apache2 won't start after upgrade to Ubuntu 22.04 LTS - Cannot load /usr/lib/apache2/moduleslibphp8.0.so [closed]

I am a bit stuck as to how to fix this.我对如何解决这个问题有点困惑。 I did a distro upgrade a server running Apache2.我对运行 Apache2 的服务器进行了发行版升级。

Since the upgrade it has not worked.自升级以来,它一直没有用。 I ran a config test and below is the error.我运行了一个配置测试,下面是错误。 I had no issues with my configuration on the previous version of Ubuntu (21.10)我在之前版本 Ubuntu (21.10) 上的配置没有问题

$ apache2ctl configtest
apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php8.0.load: Cannot load /usr/lib/apache2/modules/libphp8.0.so into server: /usr/lib/apache2/modules/libphp8.0.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.

Any ideas where to begin?任何想法从哪里开始? I'm still fairly inexperienced when it comes to Apache.当涉及到 Apache 时,我仍然相当缺乏经验。

Thank you for your help.谢谢您的帮助。

While you've figured this out, others will come (like myself) to see how you did this.虽然你已经弄清楚了,但其他人(比如我自己)会来看看你是怎么做到的。

 # perhaps you did the following to see what modules were present > apache2ctl -M # the result of the above command may have returned an error such as: apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/php8.0.load: Cannot load /usr/lib/apache2/modules/libphp8.0.so into server: /usr/lib/apache2/modules/libphp8.0.so: cannot open shared object file: No such file or directory Action '-M' failed. # so you removed the problematic module that was no longer installed # by doing the following (as appropriate given the error above) > sudo a2dismod php8.0 # you needed to restart your server after that > sudo systemctl restart apache2 # if you tested the server in a browser html should function... # however you perhaps desired the use of another php module # and added another one (8.1) that is install by default in Ubuntu 22.04 > sudo a2enmod php8.1 # you restarted apache again and it worked? > sudo systemctl restart apache2

Perhaps you were using mod_userdir and also needed to update the apache php module configuration file:也许您正在使用mod_userdir并且还需要更新 apache php 模块配置文件:

/etc/apache2/mods-enabled/php8.1.conf

By commenting out the following lines:通过注释掉以下几行:

 <IfModule mod_userdir.c> <Directory /home/*/public_html> php_admin_flag engine Off </Directory> </IfModule>

So that they looked like this:所以他们看起来像这样:

 #<IfModule mod_userdir.c> # <Directory /home/*/public_html> # php_admin_flag engine Off # </Directory> #</IfModule>
 # finally you restarted apache2 again: sudo systemctl restart apache2 # and everything was back to normal?

Did you do something like this?你做过这样的事情吗?

Disregard everyone.无视所有人。 I figured it out.我想到了。

I checked /usr/lib/apache2/modules/ and found that libphp8.0.so had been updated to libphp8.1.so.我检查了/usr/lib/apache2/modules/,发现libphp8.0.so已经更新为libphp8.1.so。

After amending the mods-enabled to include this file and not the problematic one, apache started with no issues.在修改 mods-enabled 以包含此文件而不是有问题的文件后,apache 开始没有问题。

 sudo gedit /etc/apache2/mods-enabled/php8.0.load

and rename:并重命名:

 LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so

to:至:

 LoadModule php_module /usr/lib/apache2/modules/libphp8.1.so

I removed (purge) php and apache2 and reinstalled.我删除(清除)php 和 apache2 并重新安装。 It is easier than hit-and-miss and go through hundreds of forum messages and error messages from the system.通过数百条论坛消息和系统错误消息,它比命中注定和 go 更容易。

Now it works.现在可以了。 between 7.4 and 8.1 there has been so many changes, that most of my web pages are now broken and I have to debug them.在 7.4 和 8.1 之间发生了太多变化,以至于我的大部分 web 页面现在都损坏了,我必须调试它们。

In my case I upgraded Ubuntu 20.04 to 22.04 .就我而言,我将Ubuntu 20.04 to 22.04 So the wizard uninstalled the php7.4 modules and installed php8.1 modules instead.因此向导卸载了php7.4模块并安装了php8.1模块。 After that I tried to restart apache2 but it didn't.之后我尝试重新启动 apache2 但它没有。 I realized that in my /etc/apache2/mods-enabled folder I still had php7.4.conf and php7.4.load and php7.4.load was still pointing to libphp7.4.so .我意识到在我的 /etc/apache2/mods-enabled 文件夹中我仍然有php7.4.confphp7.4.load并且php7.4.load仍然指向libphp7.4.so

Remember that mods-enabled folder is generated from mods-available folder so you should never alter mods-enabled folder.请记住,启用 mods 的文件夹是从 mods-available 文件夹生成的,因此您永远不应更改启用 mods 的文件夹。 Instead, you should disable php7.4 modules:相反,您应该禁用 php7.4 模块:

sudo a2dismod php7.4

and enable php8.1 modules:并启用 php8.1 模块:

sudo a2enmod php8.1

Of course after enabling php8.1 modules you have to restart apache2 service.当然,启用 php8.1 模块后,您必须重新启动 apache2 服务。

sudo systemctl restart apache2

The OS upgrade to Ubuntu 22 updates the installed php 7.x to php8.x but it does not fix the Apache2 configurations操作系统升级到 Ubuntu 22 将安装的 php 7.x 更新到 php8.x,但它不能修复 Apache2 配置

sudo a2dismod php7.4须藤a2dismod php7.4

sudo a2enmod php8.1须藤a2enmod php8.1

sudo a2disconf php7.4-fpm须藤a2disconf php7.4-fpm

sudo a2enconf php8.1-fpm须藤a2enconf php8.1-fpm

sudo systemctl reload apache2 sudo systemctl reload apache2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM