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

Post Reply
User avatar
Edge100x
Founder
Founder
Posts: 13009
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

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

Post 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
Post Reply