PHP not working with Apache on Centos 7

Solution 1:

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

Solution 2:

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"