Configure Apache and PHP with PHP-FPM using WHM /cPanel

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. For more information please follow

Step 1. WHM settings for to PHP-FPM configuration

1. Go to Home » Service Configuration » Configure PHP and suEXEC and set the following options

PHP 5 Handler: none
Apache suEXEC: off
Apache Ruid2: off

2. Add the PHP-FPM and FastCGI flags to EasyApache by editing the following line.

vi /var/cpanel/easy/apache/rawopts/all_php5

Add the following lines:


Step 2. Rebuild EasyApache

Go to Home » Software » EasyApache (Apache Update) and click Start customizing based on profile. Make sure to check the following options

1. Select Apache 2.2.x
2. Select PHP 5.4.x
3. Disable Frontpage
4. Disable Mod SuPHP
5. Disable Mod Ruid2
6. Select MPM Worker
7. Disable MPM Prefork and MPM Event

After that Click Save and build to start rebuilding EasyApache with selected options.

Step 3. Configure PHP-FPM

Once the EasyApache build is successfully completed proceed with the following configurations

1. Add php-fpm to init.d scripts

cd /home/cpeasyapache/src/php-5.4.x/sapi/fpm/
cp /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm

2. Configure /etc/init.d/php-fpm

vi /etc/init.d/php-fpm

then, change the foloowing option in php-fpm


3. PHP-FPM configuration file

cd /home/cpeasyapache/src/php-5.4.x/sapi/fpm/
cp /usr/etc/php-fpm.conf
vi /usr/etc/php-fpm.conf

then, change the following options in php-fpm.conf file

user = nobody
group = nobody

Note :-  In some cases /var/run/ cannot be created so you need to run the following command to create.

touch /var/run/

Step 4. Set the PHP-FPM handler in Apache configuration

Edit the following file by running the command below.

vi /usr/local/apache/conf/includes/post_virtualhost_global.conf

Now, Add the following lines to file

    LoadModule fastcgi_module modules/

    <IfModule mod_fastcgi.c>
    FastCGIExternalServer /usr/local/sbin/php-fpm -host
    AddHandler php-fastcgi .php

    #<LocationMatch "/status">
    # SetHandler php-fastcgi-virt
    # Action php-fastcgi-virt /usr/local/sbin/php-fpm.fcgi virtual

    Action php-fastcgi /usr/local/sbin/php-fpm.fcgi
    ScriptAlias /usr/local/sbin/php-fpm.fcgi /usr/local/sbin/php-fpm

    <Directory /usr/local/sbin>
    Options ExecCGI FollowSymLinks
    SetHandler fastcgi-script
    Order allow,deny
    Allow from all

Step 5. Install mod_fastcgi

cd /tmp/
tar -xzf mod_fastcgi-2.4.6.tar.gz
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
vi Makefile

Set the following in Makefile ( Apache version with you are using )

op_dir = /home/cpeasyapache/src/httpd-2.2.x

then, run the following commands to buid the code.

make install

Step 6. Start php-fpm service

Enable PHP-FPM to start at boot time by running following command.

chkconfig php-fpm on

At last, restart the following services to take affects on the configurations.

/etc/init.d/php-fpm restart
/etc/init.d/httpd restart

Now, check your phpinfo() file it should look like image below which would have enable-fasatcgi and enable-fpm configure command.


After completion of all above steps you will have php-fpm using whm through easy steps.

Balvinder Singh

Hello, I am Balvinder Singh - DevOps Engineer with 2.5+ year of working experience with different server environments. Tag Line:-Linux | AWS| WHM |Monitoring | Virtualization | Optimization | Performance | Security | Release & Deployment. I love helping companies / clients to deploy their code / applicateions to well managed, optimized, secure server and can go extra mile to satisfy.

You may also like...

3 Responses

  1. Micah says:

    I have successfully completed this process, but I now need to rebuild Apache with EasyApache. Will I need to repeat any of the above steps after doing so?

    Thank you!

  2. MD HUMAYUN Kabir says:

    How to do it with php7.4?

Leave a Reply

Your email address will not be published.