Apache2 & PHP showing blank page

Solution 1:

Try the following:

  1. Install php for Apache with sudo apt-get install libapache2-mod-php

  2. Restart apache with

    sudo service apache2 restart
    
  3. Place code to the /var/www/html/phpinfo.php:

    <?php
    phpinfo();
    ?>
    
  4. Navigate web-browser to http://localhost/phpinfo.php.

These steps will help to check that PHP is working normally.


Note: this method works for Ubuntu 18.04 LTS, 20.04 LTS, 21.04 and 21.10 too.