different php.ini settings for various virtualhost (php-fpm)
Solution 1:
On php-fpm, you usually set this in the fpm pool of the domain. The pools are included from php-fpm's main conf-file, which is located on my server at /etc/php/fpm-php5.3/php-fpm.conf
:
...
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
include=/var/www/*/conf/fpm-pool.conf
In the fpm-pool-config, you can set php_admin_flag
and php_admin_value
like this:
...
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
php_flag[display_errors] = on
php_admin_value[error_log] = /var/www/cloud/logs/php_err.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 1024M
#php_value[max_execution_time] = 30
php_admin_value[upload_max_filesize] = 4G
php_admin_value[post_max_size] = 4.2G
php_admin_value[max_input_time] = 3600
php_admin_value[max_execution_time] = 3600
Solution 2:
I had a RAM-hungry server and wanted to avoid configuring multiple pools for each of the low-traffic sites I was running. I also didn't like the security concerns of directory-based .user.ini’s, so I implemented a different solution using php.ini "sections":
http://php.net/ini.sections
You can define sections of php.ini (in my case, /etc/php5/fpm/php.ini) that are either path, or host, specific. At the bottom, I have:
[HOST=host1.example.com]
auto_prepend_file = '/var/www/something'
[HOST=host2.example.net]
upload_max_filesize = 5M
I read elsewhere that if you use the host method, you must use the specific value defined in ServerName in the VirtualHost config, not any of the aliases.
P.S. This was all done on Debian Jessie 8.4