I have a clean install of apache/httpd and php7.1.0 running on CentOS 7.
When I execute from the command line:
php -v
I get the expected response:
PHP 7.1.0 (cli) (built: Dec 1 2016 08:13:15) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
But when I try to hit my phpinfo.php page, all I get is...
<?php phpinfo(); ?>
literally outputted to the screen - can someone tell me what I'm missing, did I forget to enable a mod?
If you are loading the php file locally instead of running it from a webserver such as nginx or apache, then you will not get any php output. If you are running from a webserver, then it may not know how to interpret the php file. Read the documentation for your webserver to learn more about this.
If you are running your PHP script on a Windows computer, you need to manually install PHP. If you haven't already done so, your PHP code won't execute.
The most common reason for a blank page is that the script is missing a character. If you left out a ' or } or ; somewhere, your PHP won't work. You don't get an error; you just get a blank screen.
For PHP 7 (May apply to previous versions as well), but I had to do this:
Add this to the bottom of /etc/apache2/apache2.conf or for Centos /etc/httpd/conf/httpd.conf
SetHandler application/x-httpd-php
Fabien's answer worked for me, but apache started to serve css/js files with the wrong mime type. I fixed it adding this at the end of /etc/httpd/conf/httpd.conf
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With