PHP as FastCGI: Custom php.ini not working

fastcgiPHPphp.ini

I'm running PHP as FastCGI (I needed multiple versions of PHP).

.htaccess

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php-5.2.17.fcgi

cgi-bin/php-5.2.17.fcgi

#!/bin/sh
PHP_CGI=/usr/local/php/5.2.17/bin/php-cgi
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI -c /home/john/www/crm/php.ini

The main issue is that PHP is ignoring -c option. My php.ini files is NOT loaded.

Can anybody share any suggestions?

Best Answer

My first thought is permissions -- Apache typically runs as a limited user, often www-user or apache, depending on your flavor of Linux and how you installed Apache.

This means that with the default permissions on pretty much all Linuxes (Linii?), the Apache user (which will also be the same user running php-cgi) cannot read any file inside your home directory.

I would move the php.ini file to another location (e.g. /usr/local/php/crm/php.ini), which I suspect will solve your problem here. Another option is to simply spawn the php-cgi process using an entirely separate script, optionally running under its own user account, and have Apache talk to that.