
Error “Cannot load modules/libphp7.so” (SOLVED)
February 19, 2021
Some Linux distributions have already started migrating to PHP 8. In some distributions the new version of PHP removes the old one, as a result of which the web server may stop working due to the fact that the files specified in the web server configuration are missing or renamed.
Examples of errors you may encounter:
httpd: Syntax error on line 504 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf/mods-enabled/php.conf: Cannot load modules/libphp7.so into server: /etc/httpd/modules/libphp7.so: cannot open shared object file: No such file or directory
It says the file /etc/httpd/modules/libphp7.so was not found.
Another error that says the /etc/httpd/conf/extra/php7_module.conf file was not found:
httpd: Syntax error on line 504 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /etc/httpd/conf/mods-enabled/php.conf: Could not open configuration file /etc/httpd/conf/extra/php7_module.conf: No such file or directory
On some distributions, the Apache web server service is called apache2, and on some httpd. Therefore, this guide will consider both options.
Fix “Cannot load modules/libphp7.so” when webserver service is named httpd (Arch Linux, CentOS and their derivatives)
To view the status of the service and the errors that led to its inoperability, run the command:
systemctl status httpd.service
Open the config file /etc/httpd/conf/mods-enabled/php.conf:
sudo vim /etc/httpd/conf/mods-enabled/php.conf
Find the line in it
LoadModule php7_module modules/libphp7.so
and replace it with:
LoadModule php_module modules/libphp.so
Then find the line
Include conf/extra/php7_module.conf
and replace with:
Include conf/extra/php_module.conf
Restart the web server service:
sudo systemctl restart httpd.service
and check its status:
systemctl status httpd.service
Fix “Cannot load modules/libphp7.so” when webserver service is named apache2 (Debian, Ubuntu, Linux Mint, Kali Linux and their derivatives)
To view the status of the service and the errors that led to its inoperability, run the command:
systemctl status apache2.service
Disable PHP 7.* module:
a2dismod php7.4
Maybe you have a different version of PHP, start typing “a2dismod php” and use the TAB key for autocompletion:
To enable PHP 8 use a command like (use the TAB key for auto-completion):
a2enmod php8
Restart the web server service:
sudo systemctl restart apache2.service
and check its status:
systemctl status apache2.service
Related articles:
- How to install Python as a CGI module in Apache on Linux (93.7%)
- Error “No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed” (SOLVED) (89.3%)
- How to set up Python as a CGI module in Apache on Debian (Ubuntu, Linux Mint) (88%)
- How to install a web server (Apache, PHP, MySQL, phpMyAdmin) on Linux Mint, Ubuntu and Debian (86.2%)
- Chromium will no longer sync passwords - what should Linux users do? (83.8%)
- Full-text search in MS Word files and archives in Linux (RANDOM - 50%)
Muchas gracias por la publicación!!