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 or PHP 7.2 to PHP 7.3

The problem seems to be related to the fact that after PHP 7.2 or PHP 7.3 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.3 is installed automatically. To do this, execute:

sudo a2dismod php7.0
sudo a2dismod php7.2
sudo a2enmod php7.3
sudo a2disconf php7.0-fpm
sudo a2disconf php7.2-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 apt remove php7.2
sudo rm -rf /etc/php/7.0/
sudo rm -rf /etc/php/7.1/
sudo rm -rf /etc/php/7.2/
sudo apt autoremove

Last Updated on

Recommended for you:

4 Comments to Kali Linux web server shows blank pages (SOLVED)

  1. Jon says:

    While trying to install Mutillidae and DVWA I've gotten to this point where I only see blank for the localhost/mutillidae and /DVWA pages. I've followed this guide and still only see blank.

    Here are the two errors associated. I've verified my php-mysqli install is good and don't really know where to progress.

    [Wed May 01 19:40:37.173669 2019] [php7:error] [pid 5163] [client ::1:48766] PHP Fatal error:  Uncaught Error: Class 'mysqli' not found in /var/www/html/mutillidae/classes/MySQLHandler.php:248\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 248
    [Wed May 01 19:40:39.512034 2019] [php7:error] [pid 5166] [client ::1:48768] PHP Fatal error:  Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/dvwa/dvwa/includes/dvwaPage.inc.php:470\nStack trace:\n#0 /var/www/html/dvwa/login.php(8): dvwaDatabaseConnect()\n#1 {main}\n  thrown in /var/www/html/dvwa/dvwa/includes/dvwaPage.inc.php on line 470


    • Alex Alex says:

      Hello! What distributive do you run? I cannot reproduce the issue in the last Kali Linux.

      Please check, does your OS have the files:

      • /etc/php/7.3/apache2/conf.d/20-mysqli.ini
      • /etc/php/7.3/cli/conf.d/20-mysqli.ini
      • /etc/php/7.3/fpm/conf.d/20-mysqli.ini
      • /etc/php/7.3/mods-available/mysqli.ini
      • /usr/share/php7.3-mysql/mysql/mysqli.ini
      • Jon says:

        I'm running Kali 2019.1. I'm also missing the /usr/share/php7.3-mysql/mysql/mysqli.ini file. My directory stops at /usr/share/php7.3-mysql/

  2. Anonymous says:

    Worked properly for me :

    Distributor ID: Kali
    Description:    Kali GNU/Linux Rolling
    Release:        2019.4
    Codename:       kali-rolling


Leave a Reply

Your email address will not be published.