9

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?

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Didier Jean Charles
  • 462
  • 2
  • 9
  • 22
  • 1
    Well, looks like php is not activated inside your http server. – arkascha Jan 04 '17 at 15:51
  • Either it is not installed (note that CLI and http server module are _separate_ packages) or it simply is not activated in the http server configuration. – arkascha Jan 04 '17 at 15:52

6 Answers6

5

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 Thetis
  • 1,666
  • 15
  • 11
5

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>
fabianfiorotto
  • 139
  • 1
  • 4
2

That means that PHP isn't enabled in Apache. PHP addresses that here - step 8 should solve your problem.

As an addition: what I usually do on a new install, is install an entire LAMP-server. On Ubuntu, that's done with sudo apt-get install lamp-server^ (note: the caret is not a typo).

0

This was solution for me - adding this line into httpd.conf where your app's ServerName and DocumentRoot are:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/laravel/public/$1
wast
  • 878
  • 9
  • 27
0

Comment out the "Directory" line in the /etc/httpd/conf.d/php.conf file. Then restart the httpd server enter image description here

Gorson
  • 11
  • 1
0

ran into the same problem. On a Centos 8 Stream installation.

First check if php is installed and working, for example:

php /var/www/html/info.php

If this works, and apache is not serving/interpreting the php file, than install php-fpm (mod_php was deprecated):

dnf install php-fpm
systemctl enable php-fpm
systemctl status php-fpm
systemctl restart httpd

Check in the browser. If successful, delete the info.php file

ionescu77
  • 1,150
  • 10
  • 14