Apache2 & PHP showing blank page

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.

6

2 Answers

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 .

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.

1

A black page could be because of a php fatal error (or could be an php non-fatal error if no content was still send to the browser) when display_errors is set to off in the php.ini.

Look at the php log file to get back the error log.

It could be also because the php file content is send as raw text to your navigator, look at the "html source code" from your browser to make sure you don't see php code. If you do the php module isn't setup properly with apache.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like