mardi 27 janvier 2015

Apache httpd cannot parse php on CentOS 7


I'm setting up a new CentOS 7 server,


I installed apache httpd successfully and get the html welcome page then I installed php 5.4 then tried to test it using test page:



<?php
phpinfo();
?>


placed it in /var/www/html but I got a blank page. apache error log says:



[Mon Jan 26 21:20:12.474636 2015] [:error] [pid 8352] [client ::1:60206] PHP Fatal error: Unknown: Failed opening required '/var/www/html/test.php' (include_path='.:/php/includes') in Unknown on line 0


What I tried is:


in /etc/httpd/conf/httpd.conf I added:



LoadModule php5_module "/usr/lib64/php"
AddType application/x-httpd-php .php


and found: DirectoryIndex index.html then add index.php


I also uncommitted include_path='.:/php/includes' in /etc/php.ini


then restart apache. Nothing changed! Any idea?


UPDATE


When I checked: apachectl configtest I got:



[Mon Jan 26 22:22:49.748764 2015] [so:warn] [pid 4984] AH01574: module php5_module is already loaded, skipping
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK


So I listed my hosts:



[admin@localhost etc]$ cat hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


then replaced ServerName www.example.com:80 in httpd.conf with ServerName localhost4.localdomain4 and also tried ServerName localhost:80


but still the issue exists. However the apachectl configtest result became:



[Mon Jan 26 22:49:46.968433 2015] [so:warn] [pid 5841] AH01574: module php5_module is already loaded, skipping
Syntax OK


and error_log:



[Mon Jan 26 22:58:27.110725 2015] [:error] [pid 6103] [client ::1:47747] PHP Fatal error: Unknown: Failed opening required '/var/www/html/test.php' (include_path='.:/php/includes') in Unknown on line 0


SOLUTION


I finally decided to uninstall php54 then re install php with the following command:



yum install php php-pear


then changed ServerName in conf to localhost:80 and it works!


Thanks all for your time



Aucun commentaire:

Enregistrer un commentaire