In this article we are setting up apache to run PHP as a fastCGI process server, and address that fastCGI server directly from within apache, via a dedicated proxy module (mod_proxy_fcgi.). In other words we configure apache php-fpm on centos7  or  it means that we can now run php code using only stock apache and php binaries. No need to configure anything like suphp, mod_php or suexec. Feel free to implement the idea if you have centos 6 or even the newer centos 8.

Install Apache


Copy to Clipboard

Install php-fpm

Copy to Clipboard

Create below two directories.

Copy to Clipboard

Create a file Named example.conf using below command.

Copy to Clipboard

Add below content in above example.conf file.

Copy to Clipboard

Create Below Directories  and files.

Copy to Clipboard

Allow Apache  to read the conf files from the /etc/httpd/sites-enabled folder.  For that we are going to add following line at the end of /etc/httpd/conf/httpd.conf file.

Copy to Clipboard

Now go the folder named /etc/php-fpm.d and create a file named example.conf  and add below content.

Copy to Clipboard

Add below content in example.conf file.

Copy to Clipboard

Execute Below commands.

Copy to Clipboard

This concludes the installation and configuration apache with php-fpm. Now if you visit the phpinfo page, we can see FPM/FastCGI in the ServerAPI field. Take a look at the below screenshot. Leave your thoughts at the comment box.