1

After upgrading from 21.10 to 22.04, Apache server does not start anymore:

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

Here the PHP package installed:

$ dpkg -l | grep php8
ii  libapache2-mod-php8.0                      8.1.2-1ubuntu2                          amd64        Transitional package
ii  libapache2-mod-php8.1                      8.1.2-1ubuntu2                          amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-symfony-polyfill-php80                 1.24.0-1ubuntu2                         all          Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
ii  php-symfony-polyfill-php81                 1.24.0-1ubuntu2                         all          Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
rc  php8.0-bz2                                 8.0.8-1ubuntu0.3                        amd64        bzip2 module for PHP
rc  php8.0-cli                                 8.0.8-1ubuntu0.3                        amd64        command-line interpreter for the PHP scripting language
rc  php8.0-common                              8.0.8-1ubuntu0.3                        amd64        documentation, examples and common module for PHP
rc  php8.0-curl                                8.0.8-1ubuntu0.3                        amd64        CURL module for PHP
rc  php8.0-gd                                  8.0.8-1ubuntu0.3                        amd64        GD module for PHP
rc  php8.0-intl                                8.0.8-1ubuntu0.3                        amd64        Internationalisation module for PHP
rc  php8.0-mbstring                            8.0.8-1ubuntu0.3                        amd64        MBSTRING module for PHP
rc  php8.0-mysql                               8.0.8-1ubuntu0.3                        amd64        MySQL module for PHP
rc  php8.0-opcache                             8.0.8-1ubuntu0.3                        amd64        Zend OpCache module for PHP
rc  php8.0-readline                            8.0.8-1ubuntu0.3                        amd64        readline module for PHP
rc  php8.0-xml                                 8.0.8-1ubuntu0.3                        amd64        DOM, SimpleXML, XML, and XSL module for PHP
rc  php8.0-zip                                 8.0.8-1ubuntu0.3                        amd64        Zip module for PHP
ii  php8.1-bz2                                 8.1.2-1ubuntu2                          amd64        bzip2 module for PHP
ii  php8.1-cli                                 8.1.2-1ubuntu2                          amd64        command-line interpreter for the PHP scripting language
ii  php8.1-common                              8.1.2-1ubuntu2                          amd64        documentation, examples and common module for PHP
ii  php8.1-curl                                8.1.2-1ubuntu2                          amd64        CURL module for PHP
ii  php8.1-gd                                  8.1.2-1ubuntu2                          amd64        GD module for PHP
ii  php8.1-mbstring                            8.1.2-1ubuntu2                          amd64        MBSTRING module for PHP
ii  php8.1-mysql                               8.1.2-1ubuntu2                          amd64        MySQL module for PHP
ii  php8.1-opcache                             8.1.2-1ubuntu2                          amd64        Zend OpCache module for PHP
ii  php8.1-readline                            8.1.2-1ubuntu2                          amd64        readline module for PHP
ii  php8.1-xml                                 8.1.2-1ubuntu2                          amd64        DOM, SimpleXML, XML, and XSL module for PHP
ii  php8.1-zip                                 8.1.2-1ubuntu2                          amd64        Zip module for PHP

The available librarie is:

$ ls -l /usr/lib/apache2/modules/libphp*
-rw-r--r-- 1 root root 5354272 apr  7 19:46 /usr/lib/apache2/modules/libphp8.1.so

Here the content of the offending mods:

$ cat /etc/apache2/mods-enabled/php8.0.load
# Conflicts: php5
# Depends: mpm_prefork
LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so

Changing it to libphp8.1.so leads to apache2 service restarts correctly.

Why it didn't update this file? What should I do to avoid this manually hacking?

2 Answers 2

2

I had the same issue and resolved as above using the following steps:

  1. Remove the old php 8.0 references in mods-enabled directory.
  2. Add new symbolic links in mods-enabled to the php 8.1 references in the mods-available directory.

The steps followed are outlined below:

Before the resolution:

$ cd /etc/apache2/mods-enabled  
$ ls -l \*php\*  
lrwxrwxrwx 1 root root 29 May 29 20:27 php8.0.conf -> ../mods-available/php8.0.conf  
lrwxrwxrwx 1 root root 29 May 29 20:27 php8.0.load -> ../mods-available/php8.0.load  

Implement the resolution:

$ sudo rm php8.0.conf php8.0.load  
$ sudo ln -s ../mods-available/php8.1.load php8.1.load  
$ sudo ln -s ../mods-available/php8.1.conf php8.1.conf  

After the resolution:

$ cd /etc/apache2/mods-enabled  
$ ls -l \*php\*  
lrwxrwxrwx 1 root root 29 Jun  3 12:36 php8.1.conf -> ../mods-available/php8.1.conf  
lrwxrwxrwx 1 root root 29 Jun  3 12:36 php8.1.load -> ../mods-available/php8.1.load  

Test:

$ sudo systemctl restart apache2  
$ sudo systemctl status apache2  
* apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-06-03 12:37:30 BST; 5s ago

Hope this helps.

1
  • This does not actually answer to my questions because I've already provided kink of solution as workaround. I was asking why this happens and if there is anything we can do to avoid this manual fix. In other words, they released a bugged update?
    – Mark
    Jun 4, 2022 at 5:40
0

After struggling for quite a long time, this was the final solution: https://idroot.us/install-php-7-4-ubuntu-22-04/

Just followed the steps and my PHP website was up and running again.

Edit: steps below

sudo apt update
sudo apt upgrade
sudo apt install wget apt-transport-https gnupg2 software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install apache2 php7.4 php7.4 php7.4-common libapache2-mod-php7.4 php7.4-cli
sudo apt install php7.4 php7.4-fpm php7.4-cli
1
  • Could you put the steps in instead of just the link? It’s better to do that in case the link breaks. Thanks!
    – Will
    Dec 12, 2022 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.