3

I'm running 2 PHP sites on the same server. I would like to use 2 different php.ini files for them. I've googled this issue with no luck. Here is what my php location looks like:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

    # With php5-cgi alone:
    # fastcgi_pass 127.0.0.1:9000;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

Any help would be appreciated.

2
  • 3
    Because you don't do that - you configure php-fpm however you want (mutiple instances if desired) and point at whichever one you want to use.
    – AD7six
    Feb 12, 2015 at 16:45
  • @AD7six - I see. Any good references on how to do this?
    – Aust
    Feb 12, 2015 at 17:55

1 Answer 1

3

As pointed out by @AD7six, I was going about it the wrong way. This is how I solved the issue for anyone else who isn't as familiar with multiple php setups.

Copy the default pool to create our new pool. (You can name the pool whatever you want, in this example I am using www2):

sudo cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/www2.conf
sudo nano /etc/php5/fpm/pool.d/www2.conf

Change the pool name:

[www] => [www2]

Change the listening socket:

listen = /var/run/php5-fpm.sock => /var/run/php5-fpm2.sock

Unfortunately, specifying php.ini files based on pool is impossible. (See this question) But as the answer there states, you can overwrite individual php.ini values. It's not great but as far as I can tell, there's no other way of doing it.

A note for overwriting the php.ini values: There are 4 ways of doing this, php_value, php_flag, php_admin_value, and php_admin_flag. Use the _flag commands when setting booleans. Use the _value commands for anything else. The _admin versions make it so those values/flags cannot be overwritten.

Finally, change your nginx.conf to use the new pool:

fastcgi_pass unix:/var/run/php5-fpm.sock => unix:/var/run/php5-fpm2.sock

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .