mod_fastcgi with PHP-FPM on Centos

yum install php-fpm
chkconfig –levels 235 php-fpm on
vi /etc/php-fpm.d/www.conf
;listen = 127.0.0.1:9000
listen = /tmp/php5-fpm.sock
pm.status_path = /status
ping.path = /ping

service php-fpm start

yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum install mod_fastcgi # Get mod_fastcgi from rpmforge or compile yourself

yum install libtool httpd-devel apr-devel apr
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar -zxvf mod_fastcgi-current.tar.gz
cd mod_fastcgi*
make top_dir=/usr/lib64/httpd
make install top_dir=/usr/lib64/httpd

mv /etc/httpd/conf.d/{php.conf,php.conf.disable}
mkdir /usr/lib/cgi-bin/
vi /etc/httpd/conf.d/mod_fastcgi.conf
LoadModule fastcgi_module modules/mod_fastcgi.so


DirectoryIndex index.php index.html index.shtml index.cgi
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization

# For monitoring status with e.g. Munin

SetHandler php5-fcgi-virt
Action php5-fcgi-virt /php5-fcgi virtual

service httpd restart

Leave a Reply

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