Category: General PHP

PHP Fast CGI Apache 2

1. Install components

yum install mod_fcgid

2. Rename php.conf to disable mod_php

mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.notused

3. Uncomment cgi.fix_pathinfo = 1 in php.ini

vi /etc/php.ini

4. Create wrapper script and set permissions

mkdir -p /var/www/php-fcgi-scripts/web
vi /var/www/php-fcgi-scripts/web/php-fcgi-starter

5./bin/sh
PHPRC=/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/bin/php-cgi

chmod -R 755 /var/www/php-fcgi-scripts/web
chown -R $user:apache /var/www/php-fcgi-scripts/web

6. Add virtual hosts

vi /etc/httpd/conf/httpd.conf
or
vi /etc/httpd/conf.d/vhost.conf

 
    SuexecUserGroup web1 web1
    PHP_Fix_Pathinfo_Enable 1
    
      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/web1/php-fcgi-starter .php
      Order allow,deny
      Allow from all
    
  


7. Test in browser

Tags:

PHP

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count: