Why we like php-fastcgi and its flexibility
Unfortunately, php_value in .htaccess are possible only with PHP as an Apache module (not with CGI/FastCGI versions).
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.
That technical mumbo-jumbo sound confusing? Well, here’s an example (you’ll need to create your own ‘extra’ wrapper/php.ini files) that may help clear the air:
I want to have ~/web/public/subdir1 use session.auto_start and not register_globals, and ~/web/public/subdir2 use register_globals, but not auto-start sessions.
To accomplish this, I duplicate the ~/php-fastcgi/phpX-fcgi script for the version of php you’d like to use (4 or 5) and name them with unique names.
server # cd php-fastcgi
server # ls
php4-fcgi php5-fcgi
server # cp php5-fcgi php5-fcgi_sess_autostart
server # cp php5-fcgi php5-fcgi_reg_globals
server # ls
php4-fcgi php5-fcgi php5-fcgi_sess_autostart php5-fcgi_reg_globals
Then copy the main php.ini for your selected version (/usr/local/etc/php.ini for php5 and /usr/local/etc/php4/php.ini for php4) to a newly created directory (inside ~/etc would be customary)
server # cd ~/etc/
server # ls
dav.digest.groups dav.digest.passwd svn-access.conf svn.basic.passwd
server # mkdir php5_sess_autostart
server # mkdir php5_reg_globals
server # cp /usr/local/etc/php.ini php5_sess_autostart
server # cp /usr/local/etc/php.ini php5_reg_globals
server # ls php5_*
php5_reg_globals:
php.ini
php5_sess_autostart:
php.ini
Edit the php.ini files with your required settings, then finally edit the PHPRC value within the new wrapper scripts:
server # grep ^PHPRC php5-fcgi_sess_autostart
PHPRC="/home/yourusername/etc/php5_sess_autostart"
server # grep ^PHPRC php5-fcgi_reg_globals
PHPRC="/home/yourusername/etc/php5_reg_globals"
Lastly, to actually use our new wrappers, simply add a .htaccess to the appropriate subdirectory with a new AddType declaration to have Apache use the proper wrappers for your php files:
AddType application/x-httpd-fastphp-autostart .php
Action application/x-httpd-fastphp-autostart /php-fastcgi/php5-fcgi_sess_autostart
See our article on Trade Secret #1 for more information on php-fastcgi.
·:· Posted 14 November 2005, 05:42 by Ryan Schwartz to Apache |

Anyways I love the flexibity at TextDrive.
— Jacques Marneweck 20 November 2005, 20:28 #