PHP-FPM Centos 6 for PHP 5.3.3-14 rpm installing and configuring howto

I have compiled for you a PHP-FPM Centos 6 rpm that can be installed for PHP 5.3.3-14. This rpm works with the standard PHP version that is installed with Centos 6. With this you can configure Apache to use fastcgi and this opens the possibility to use Apache worker MPM.

phpinfo showing that php-fpm is active

Why? PHP-FPM offloads php scripts to a dedicated daemon freeing up precious memory and processing power in Apache making it faster.

Download the RPM here: php-fpm-5.3.3-14.el6_3.x86_64.rpm then upload it to your server.

You can install the PHP-FPM Centos 6 rpm using the the yum install command:

yum install php-fpm-5.3.3-14.el6_3.x86_64.rpm

Note that this precompiled RPM only works on 64-bit installations. See below for compiling php-fpm yourself.

After installing the rpm you must configure PHP-FPM. This involves installing mod_fastcgi from RepoForge.

I assume you already installed PHP and Apache, otherwise do it now. (yum install httpd php)

Install mod_fastcgi available from RepoForge. Install the RepoForge repository and optionally configure yum priorities to keep as much not-centos packages out of your system.

yum install mod_fastcgi

Edit /etc/httpd/conf.d/php.conf and make it empty to disable php5_module. Or comment everything out.

Edit /etc/httpd/conf.d/fastcgi.conf and change FastCgiWrapper to off:

FastCgiWrapper Off

Make a new file /etc/httpd/conf.d/fastcgi.php.conf and paste the following into it to configure the connection from mod_fastcgi to PHP-FPM:

DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /var/www/cgi-bin/php5-fcgi
FastCgiExternalServer /var/www/cgi-bin/php5-fcgi -idle-timeout 60 -host -pass-header Authorization

Restart Apache and PHP-FPM:

service httpd restart
service php-fpm restart

Test if it works and enjoy your speedy Centos 6 Apache server. phpinfo() should include this: Server API FPM/FastCGI

Not working and using selinux? Execute: setsebool httpd_can_network_connect on

Building the PHP-FPM rpm yourself.

I have painstakingly made a src rpm using the standard src rpm for PHP from Centos with all the modifications to compile php with PHP-FPM.

Download my php src rpm php-5.3.3-14.el6_3.src.rpm and upload it to your server or dedicated build machine. Then install all the dependencies needed to compile the src rpm:

yum-builddep php-5.3.3-14.el6_3.src.rpm

Yum-builddep is available from yum-utils. You may need to install that is yum-builddep is not found.

Now build the rpm file:

rpmbuild --rebuild --define 'dist .el6_3' php-5.3.3-14.el6_3.src.rpm

After a while (depending on the cpu power of your system) you should have a complete set of .rpm files that can install PHP (in /root/rpmbuild/RPMS/x86_64/). Only the php-fpm rpm have to be used to update an existing php installation with PHP-FPM.

It is now possible to configure Apache with the worker MPM by enabling the HTTPD setting in /etc/sysconfig/httpd

Did you like this post? Please give it a thumbs up by sharing it on your social network. Thanks!

2 thoughts on “PHP-FPM Centos 6 for PHP 5.3.3-14 rpm installing and configuring howto

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>