1. Install httpd-itk
Command: yum install httpd-itk
Note: Requires EPEL repo
2. Download and install mod_fastcgi
Command: rpm -ivh mod_fastcgi-2.4.6-2.el6.cosh.x86_64.rpm
Get the RPM: http://rpm.centoshelp.org/el6/mod_fastcgi/
3. Edit /etc/sysconfig/httpd
Command: vi /etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker
HTTPD=/usr/sbin/httpd.itk
4. Edit /etc/php.ini
Command: vi /etc/php.ini
Find and uncomment the following 2 directives:
cgi.force_redirect = 1
cgi.fix_pathinfo = 1
5. Disable DSO (mod_php)
Command: mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable
6. Create /var/www/cgi-bin/php.fcgi
Command: vi /var/www/cgi-bin/php.fcgi
Add the following contents:
1 2 3 4 5 6 7 |
<em>#!/bin/bash</em> <em>PHP_CGI=/usr/bin/php-cgi</em> <em>PHP_FCGI_CHILDREN=4</em> <em>PHP_FCGI_MAX_REQUESTS=1000</em> <em>export PHP_FCGI_CHILDREN</em> <em>export PHP_FCGI_MAX_REQUESTS</em> <em>exec $PHP_CGI</em> |
Save and exit :wq!
Command: chmod +x /var/www/cgi-bin/php.fcgi
7. Sample vhost config
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<VirtualHost *:80> ServerAdmin webmaster@example.com DocumentRoot /var/www/example.com ServerName example.com ErrorLog logs/example.com-error_log CustomLog logs/example.com-access_log common AccessFileName .htaccess ## FastCGI ### AssignUserId webdev1 webdev1 <Directory /var/www/example.com/> Options -Indexes FollowSymLinks +ExecCGI AllowOverride All AddHandler php5-fastcgi .php Action php5-fastcgi /cgi-bin/php.fcgi DirectoryIndex index.php index.html Order allow,deny Allow from all </Directory> </VirtualHost> |
9. Restart Apache httpd
Command: service httpd restart
Appendix
APC Howto: