I'm on centos 7 and have the httpd service (2.4.6) installed from yum no problems and I had to install PHP from a different repo remi to get php 5.6 installed.

PHP works on the command line and the httpd service is running but all php is not being executed, there are no errors in any logs, and the below php.conf exists.

AddHandler php5-script .php
AddType text/html .php

<IfModule  mod_php5.c>
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php

I've been at this hours now going around in circles and just can't seem to see where the disconnect between apache and php is, any help greatly appreciated.

  • What happend when you try to display a php page, php source is displayed ? – Froggiz Nov 23 '15 at 20:52
  • @Froggiz, PHP code is displayed plain-text. – llanato Nov 23 '15 at 20:57
  • @llanato, create test.php with the following code <?php phpinfo(); ?> and put it in your Apache document root or anywahere that you can execute from a browser. Then see what happens when you go to page hostname_or_ip/test.php. This is a test to see if php is working with apache. – Diamond Nov 23 '15 at 21:32
  • @bangal, as I already said, php isn't working with apache at all, it's only working on the command line and all php code is displayed as plain-text. – llanato Nov 23 '15 at 21:36
  • @llanato, what does your /var/log/httpd/error_log says when you try to execute a php page? – Diamond Nov 23 '15 at 21:41

It seems your php module for apache is not working. It's may be not properly installed or configured.

To see all available modules, you can run:

apachectl -M

You can enable the module by adding the following line either in httpd.conf or your vhost config file:

LoadModule php5_module        modules/libphp5.so

Every time I have this problem, it is because I did something like:

# yum install httpd php-mysql
# yum install php-fpm
# systemctl start httpd

Finally I remember that this is not a dependency and get it working:

# yum install php
# apachectl -M | grep -i php
 php5_module (shared)

# systemctl enable httpd
# systemctl restart httpd

At this point I can use php in httpd without external repos or mod_php package listed in "rpm -qa"

  • Why do you say without mod_php package? You installed mod_php and you are using it! – Michael Hampton Aug 14 '20 at 13:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.