0

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!

WebTigers
  • 297
  • 2
  • 8
  • Not all of us are familiar with FPM as you appear to be. Because of the FPM implementation, Amazon Linux2 is just using a different config file than what typical Apache users of the previous version of Amazon Linux might be expecting. This wasn't documented very well. Amazon admitted such and said they would update their docs. No need to be snide with the "I can't really understand what the question is ..." Not everyone is experienced with FPM. That's why we're here on Stack. – WebTigers Jul 21 '20 at 14:47
  • I'm not on Stack Overflow to mock people so I've removed the comment you found offensive. When I said I can't understand the question I only meant I can't understand the question. – Álvaro González Jul 21 '20 at 14:51
  • Oh, I think I see what you are saying now. You are correct. No, there is no question being asked. Often on Stack people will simply share their experiences with what they found to be difficult issues. There will be no question actually asked. My apologies for thinking you were being snarky. My bad. I have found many such "no question" articles on Stack, or where people are simply answer their own question. That's simply what I did here. Cheers! – WebTigers Jul 22 '20 at 18:46

0 Answers0