9

After upgrading Ubuntu 16.04 to 18.04, then to 20.04 and finally to version 22.04, I got this error:

How can I fix it ?

root@vmi155065:/etc/apache2/mods-enabled# sudo service apache2 status
× apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2022-05-01 17:27:12 CEST; 1 day 20h ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 621 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
        CPU: 31ms

May 01 17:27:12 vmi155065.contaboserver.net systemd[1]: Starting The Apache HTTP Server...
May 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 >
May 01 17:27:12 vmi155065.contaboserver.net apachectl[621]: Action 'start' failed.
May 01 17:27:12 vmi155065.contaboserver.net apachectl[621]: The Apache error log may have more information.
May 01 17:27:12 vmi155065.contaboserver.net systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
May 01 17:27:12 vmi155065.contaboserver.net systemd[1]: apache2.service: Failed with result 'exit-code'.
May 01 17:27:12 vmi155065.contaboserver.net systemd[1]: Failed to start The Apache HTTP Server.
2
  • I think problem is fixed by changing - LoadModule php7_module "/usr/lib/apache2/modules/libphp7.4.so" to + LoadModule php_module "/usr/lib/apache2/modules/libphp8.0.so" thank you. hope it will help someone else. May 3, 2022 at 16:55
  • 1
    Thanks for contributing! Please post the details of your solution as an answer, not a comment. This will ensure that your contribution is most helpful to future visitors.
    – Nmath
    May 3, 2022 at 18:45

4 Answers 4

18

I faced exactly this same issue while I did upgrade from Ubuntu 20 to 22. I made the following changes in order to make it work.

  • sudo a2dismod php7.4 (This is php ver. you had previously before upgrade)
  • sudo a2enmod php8.1 (This is php ver. you have after upgrade. Please verify the exact version by looking into /etc/apache2/mods-available folder. In my case I could see the latest ver. of php8.1 so did accordingly mentioned in this command)
  • systemctl restart apache2
  • sudo apachectl configtest

You might would like to know more about a2dismod and a2enmode commands? Here's the link which can answer it in detail a2dismod, a2enmode.

3
  • Apache was able to start but Phpmyadmin does not work after these steps. Oct 11, 2022 at 10:30
  • Worked like a charm. Thanks a lot. Dec 4, 2022 at 20:52
  • worked, jammy 22.04
    – centurian
    Jan 23, 2023 at 16:26
0

I faced same issue and the steps shared in this thread helped resolve the problem.

libphp module loading error

To install PHP with success you have to install some dependencies first.

sudo apt install software-properties-common apt-transport-https

This may be the difference between your troubles, and why mine works. This step is to import a PPA repository from Ondřej Surý who is a renowned PHP and Debian developer and maintains its packages as well as Ubuntu’s packages.

sudo add-apt-repository ppa:ondrej/php -y

run your update command only... Now see if this helps:

sudo apt install php8.1 libapache2-mod-php8.1

now reload:

sudo systemctl restart apache2

check if it is working:

sudo systemctl status apache2
systemctl status apache2
\u25cf apache2.service - The Apache HTTP
Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
     Active: active (running) since Thu 2022-06-02 13:13:11 EDT; 8s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 14432 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/S>    Main PID: 14436 (apache2)
      Tasks: 6 (limit: 4622)
     Memory: 9.9M
        CPU: 52ms
     CGroup: /system.slice/apache2.service
             \u251c\u250014436 /usr/sbin/apache2 -k start
             \u251c\u250014437 /usr/sbin/apache2 -k start
             \u251c\u250014438 /usr/sbin/apache2 -k start
             \u251c\u250014439 /usr/sbin/apache2 -k start
             \u251c\u250014440 /usr/sbin/apache2 -k start
             \u2514\u250014441 /usr/sbin/apache2 -k start
0

Just ensuring the php8.1 mod was installed worked for me.

sudo apt install libapache2-mod-php8.1
1
  • This is already in the question. Nothing new here.
    – David
    May 3, 2023 at 8:13
0

sudo apt install -y libapache2-mod-php7.4

I have installed the libapache2-mod-php of the desired PHP version and it is working fine

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .