4

I try to run php7.4 in ubuntu 21.10 but I get this error.

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

Missing libphp7.4.so

I installed libphp7.4-embed but the problem persists. The files are installed in /usr/lib/ not in /usr/lib/apache2/modules/. Symbolic link did not help (undefined symbol: php7_module).

How to make php7.4 run in ubuntu 21.10?

I try some commands

$ sudo a2enconf php7.4-fpm

Conf php7.4-fpm already enabled
$ sudo a2enmod php7.4-fpm

ERROR: Module php7.4-fpm does not exist!
user30424
  • 147
  • 1
  • 10
  • Before becoming enthusiastic ... after much frustration, I just deleted `sudo rm php7.4.load` and miracle ... it works. – user30424 Jan 09 '22 at 14:01

3 Answers3

7

Both OP and @Andrew have pieced together a good solution, but since I just had to do this, let me put it all together, with a few extra clarification steps.

First: What version of PHP do you have now / will you use?

php -v

Returns PHP 8.1.2 so 8.1 in my case.

Next, disable the existing apache2 module that was giving you trouble:

sudo a2dismod php7.4

Finally, enable the one you found above:

sudo a2enmod php8.1

Restart apache2 and you're all set.

sudo systemctl restart apache2
cdehaan
  • 394
  • 5
  • 10
2

after much try and error: rm /etc/apache2/mods-enabled/php7.4.load

Now it works.

(there is only one php* in mods-enabled: php7.4.conf. I don't know if it matters.)

user30424
  • 147
  • 1
  • 10
0

I needed to stay on php7.4, so moving to 8.1 was not an option. Line 3 of php7.4.load made referance to libphp7.4.so

LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so

When googling, I learned that I was missing an php module. Apache2 would start after installing this.

sudo apt install -y libapache2-mod-php7.4
wruckie
  • 1,717
  • 1
  • 23
  • 34