Ubuntu – Apache2 & PHP showing blank page

16.04Apache2PHP

I've tried to install PHP and Apache2, however when I access the file, it just shows a blank page.

I've installed the packages php, apache2, php-mysql (and some others)

I've already tried pretty much everything that I could find on the Internet.

I'm sorry if I'm not providing enough info, I will give any info that I can.

Best Answer

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 and 20.10 too.

Related Question