I searched for a whole day trying to find this, so I'm sharing my experience in attempting set php_value
and php_admin_value
with Amazon Linux2 instances.
First of all, Linux2 runs PHP with the much more efficient and faster FPM (FastCGI Process Manager). For some reason now, FPM more or less ignores the PHP vars set within an Apache site config. However, there is a PHP-FPM config that can handle this for you. I did not dig too deeply, but simply got the configs working by placing my php_admin_value
within the FPM config file which is actually expecting these vars.
sudo nano /etc/php-fpm.d/www.conf
Toward the end of the config file you will notice the php.ini config section. Honestly, this could be better documented on AWS and even within the file itself.
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; 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'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
If you have multiple site running on box, then you can (I assume) create different FPM configs for each site. This is a bit of a pain, but if you absolutely need the php_admin_value
vars set you can set them like this:
php_admin_value[session.cookie_httponly] = 1
php_admin_value[session.cookie_secure] = 1
php_admin_value[browscap] = /var/www/browscap.ini
php_admin_value[date.timezone] = America/New_York
php_admin_value[display_errors] = 1
php_admin_value[error_reporting] = 32767
php_admin_value[error_log] = /var/log/www-error.log
Also note that Linux2 PHP-FPM also creates it's own PHP error log which evidently Apache ignores now. Set this error log to wherever you prefer your site error logs to live.
Hope this is helpful and saves you some time looking for this. Feel free to offer any additional advice!