TheDotProduct

Web-tech nerd stuff

Setting or overriding PHP configuration in PHP-FPM (pool) configurations

I’ve recently been working on some very different parallel projects on a development server i have and came across a situation where i needed to have one vhost/site for the LDAP GUI GOsa on the server with the (soon to be deprecated) PHP feature magic_quotes_gpc enabled whilst the rest of my vhosts/sites (quite rightly) mandate that magIc_quotes_gpc is turned off.

My server runs what is now my default PHP stack:

Nothing too unusual there for the slightly more experimental/progressive amongst us who have ditched our old pal Apache HTTPD

Try as i might though, i simply couldn’t override the PHP magic_quotes_gpc config variable/setting through the usual override (an entry in the Nginx vhost of fastcgi_param php_value “magic_quotes_gpc=On”; or anything even close to that). So i thought about it a bit and remembered that an often overlooked feature in PHP-FPM is “pools”…

PHP-FPM pools essentially allow you to more strictly isolate your hosts (or groups of vhosts), providing a simple way to use very different configurations on the same server. So a quick dive into a very nice Nginx/PHP-FPM configuration/optimisation reference reminded me how to configure pools. I simply created a new pool for GOsa and added the following to the pool config file:

php_admin_value[magic_quotes_gpc]=On

A restart of PHP-FPM and Nginx later and everything worked!

So my actions, step-by-step were:

That’s it, all very simple.

I realise i can override magic_quote_gpc in PHP code but since GOsa is a 3rd party app, i don’t want to mess with the source code as i’ll update it some time and forget then the whole thing will break.

Hope that helps

Created: Fri, 11 May 2012 09:00:00 GMT
Last modified: Fri, 11 May 2012 09:00:00 GMT