How to install PHP on CentOS has preinstalled Apache HTTPD?

Solution 1:

"mod_php" (the main "php" package) is build with system httpd, so cannot be installed without it.

Using FPM (php-fpm) you can use any webserver.

I recommend you read PHP Configuration Tips which explain how to switch to FPM, and why it is better.

Notice:

  • httpd 2.4 in CentOS 7 is maintained and have all security fixes, see Backporting Security Fixes
  • More recent version is also available, with new features in the httpd24 Software Collections, maintain by the SCLo SIG from RHSCL.
  • httpd 2.4 in CentOS 8 is also more recent (and use FPM by default)