Linux – PHP on CentOS generating blank page, no errors

apache-2.2centoslinuxPHP

My sysadmin setup a virtual server using CentOS, PHP and Apache.
All seems correctly installed: I get the Apache welcome page, I can find PHP using which php as well as yum list installed *php*.

I can also put a file testing1.html in /var/www/html/ and see html content on a browser.

But when creating a file testing2.php containing <? phpinfo(); ?> I try to access it via browser and get a blank page.

The Apache log says

[23/Oct/2015:09:27:13 -0400] "GET /testing2.php HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"

which doesn't really help me figure out what's wrong.

Folder permissions are 755 and file permissions are 644.

Any suggestions on how to begin troubleshooting this?

Best Answer

Looking at the contents of the test PHP file (<? phpinfo(); ?>) I suspect that your php.ini doesn't have short-open-tag enabled.

To fix this, you have two options.

  1. Change the contents of your code to:
    <?php phpinfo(); ?>

  2. Enable short-open-tag in php.ini.

The preferred approach would be the first, in accrodance with PHP:

PHP also allows for short open tag <​? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).