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:
--enable-fastcgi --enable-fpm
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 init.d.php-fpm.in /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
prefix= exec_prefix= php_fpm_BIN=/usr/local/sbin/php-fpm php_fpm_CONF=/usr/etc/php-fpm.conf php_fpm_PID=/var/run/php-fpm.pid
3. PHP-FPM configuration file
cd /home/cpeasyapache/src/php-5.4.x/sapi/fpm/ cp php-fpm.conf.in /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/php-fpm.pid cannot be created so you need to run the following command to create.
touch /var/run/php-fpm.pid
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/mod_fastcgi.so <IfModule mod_fastcgi.c> FastCGIExternalServer /usr/local/sbin/php-fpm -host 127.0.0.1:9000 AddHandler php-fastcgi .php #<LocationMatch "/status"> # SetHandler php-fastcgi-virt # Action php-fastcgi-virt /usr/local/sbin/php-fpm.fcgi virtual #</LocationMatch> 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 </Directory> </IfModule>
Step 5. Install mod_fastcgi
cd /tmp/ wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz 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 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 you can see Server API FPM/FASTcgi