Linux 4 All

Best Linux tricks source

It’s easy to run Apache with mod_fastcgi and php-fpm. On a RedHat/CentOS box, assuming you have IUS repository enabled, and php 5.4 installed from IUS, here are the steps:

1. Install and start php-fpm for php54:

yum install php54-fpm

2. Edit /etc/php-fpm.d/www.conf and change to listen on socket to avoid tcp overhead:

listen = /dev/shm/apache-php.sock
service php-fpm start
chkconfig php-fpm on

2. Get mod_fastcgi

wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar xvzf mod_fastcgi-current.tar.gz
cd mod_fastcgi-[[tab-tab]]
cp Makefile.AP2 Makefile
make top_dir=/usr/lib64/httpd
make install top_dir=/usr/lib64/httpd

3. Create /etc/httpd/conf.d/mod_fastcgi.conf

# cat /etc/httpd/conf.d/mod_fastcgi.conf
LoadModule fastcgi_module modules/mod_fastcgi.so

AddType application/x-httpd-php .php
Action application/x-httpd-php /php.fcgi
DirectoryIndex index.php index.html index.htm
FastCGIExternalServer /dev/shm/apache-php.fcgi -socket /dev/shm/apache-php.sock -flush

4. Disable Apache mod_php

mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disabled
echo "# PHP is running as mod_fastcgi" >/etc/httpd/conf.d/php.conf

5. Enable PHP engine, by adding the following to your Apache Virtual Host:

# FastCGI handler for PHP-FPM
# See conf.d/fastcgi.conf
Alias /php.fcgi /dev/shm/apache-php.fcgi

6. Restart Apache

service httpd restart

How to find the largest 50 files arrow-right
Next post

arrow-left Restore file permissions and ownership using ACL
Previous post

Leave a Reply

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