Kali Linux web server shows blank pages (SOLVED)

After a recent update of PHP from 7.0 to 7.2 version in Kali Linux, a new bug has appeared: in Kali Linux the Apache web server shows pages with HTML code, but does not show most pages with PHP code. If this is your case, then this guide should help you.

Just in case, to be sure that the services of the web server and DBMS are running, run:

sudo systemctl start apache2.service
sudo systemctl start mysql

Uncaught Error: Class 'mysqli' not found in

One of the signs that the problem in the conflict of PHP versions is an error in the logs of the web server, which says that the mysqli class cannot be found. At the same time, before the PHP update, the code on the server worked.

Errors of the web server in Kali Linux can be found in the /var/log/apache2/error.log file, for example:

tail /var/log/apache2/error.log

An error that indicates that the mysqli class was not found:

PHP Fatal error:  Uncaught Error: Class 'mysqli' not found in /var/www/html/mutillidae/classes/MySQLHandler.php:212\nStack trace:\n#0 /var/www/html/mutillidae/database-offline.php(8): MySQLHandler::databaseAvailable()\n#1 {main}\n  thrown in /var/www/html/mutillidae/classes/MySQLHandler.php on line 212

How in Kali Linux switch from PHP 7.0 to PHP 7.2

The problem seems to be related to the fact that after PHP 7.2 is installed, the version of PHP 7.0 still continues to be used. And in spite of the fact that extensions, for example such as php7.0-mysql, do not disappear from the system, but they cease to be picked up by the PHP interpreter and the server can no longer fully work with PHP code.

The simplest way that will solve this problem is disabling PHP 7.0 for Apache and enabling PHP 7.2 for the web server, since in any case PHP 7.2 is installed automatically. To do this, execute:

sudo a2dismod php7.0
sudo a2enmod php7.2
sudo a2disconf php7.0-fpm
sudo systemctl restart apache2

After that, errors with missing modules should disappear, and pages with PHP code should start to be displayed.

To remove unnecessary versions of PHP and their tracks, you can run the following commands (this is optional):

sudo apt remove php7.0
sudo rm -rf /etc/php/7.0/
sudo rm -rf /etc/php/7.1/
sudo apt autoremove

Recommended for you:

Leave a Reply

Your email address will not be published.