Categories
PHP

Thinking of switch to PHP w/Fast CGI?

If you’re contemplating switching to running PHP5 under FastCGI, to take advantage of apache’s threaded worker model and improve your server’s performance, think again.  If you’re used to setting and overriding php values via .htaccess files or using php_value/php_flag in your virtual host directory, this is not supported with FastCGI.  You’ll have to figure out how to set those values via some other means.  Some PHP ini directives can be set in your script directly, with ini_set, but others have to be set outside of it (register_globals for example).  There are ways to set them, but making the switch from prefork to worker is not trivial, especially if you have multiple PHP applications on a single server.

Why we like php-fastcgi and its flexibility

So if you’d like to use php-fcgi but still need some flexibility with your php configuration, (since the php-fcgi scripts are just wrappers) you can create php.ini files for whatever feature-set you need, duplicate the wrapper scripts, defining different PHPRC values for each, then use a .htaccess in each of the subfolders to define which one of the wrappers to use with the following directives.