Page 1 of 1

How do I make a PHP use FastCGI instead of mod_php?

Posted: Sun Jan 30, 2011 12:41 am
by Edge100x
Generally, it is best to use mod_php (the default), for performance and flexibility reasons, but if you want to run your PHP scripts here using the FastCGI interface instead, here's how to do it.

1. Turn on FastCGI support for a subdomain via the "Domains" page in your control panel (it's under the advanced options, accessible with the little down-arrow).

2. Create a php-wrapper.fcgi file in the folder corresponding to that bare subdomain (its root). Put the following in it:

Code: Select all

#!/bin/sh
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=2000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi
3. Chmod php-wrapper.fcgi to 700 (read/write/execute for the owner only).

4. Create a .htaccess file in the same folder, containing the following:

Code: Select all

<FilesMatch "\.ph(p5?|tml)$">
  SetHandler php-fastcgi
</FilesMatch>
Action php-fastcgi /php-wrapper.fcgi