wodby / php

Generic PHP docker container images
MIT License
152 stars 103 forks source link

Add opcache.preload_user for php 7.4 #120

Closed iLexN closed 3 years ago

iLexN commented 3 years ago

https://www.php.net/manual/en/opcache.preloading.php

preload.php is an arbitrary file that will run once at server startup (PHP-FPM, mod_php, etc.) and load code into persistent memory. If PHP will be run as root (not recommended), the opcache.preload_user value can specify an alternate system user to run the preloading. Running preloading as root is not allowed.

this patch added the opcache.preload_user can config from the env.

csandanov commented 3 years ago

Could you please explain the use case? we run fpm from www-data user by default, why would you want to set it to root and preload something from a different user? and what user would it be? wodby? Running fpm from root is not safe and not recommended, which is why I'm hesitant about merging this

iLexN commented 3 years ago

i am trying the Preloading for php 7.4, using wodby/drupal-php:7.4

in the docker-compose.yml , after add a env variable PHP_OPCACHE_PRELOAD: /file-path/preloader.php , the container cannot start and have a error Fatal Error "opcache.preload_user" has not been defined

after define the opcache.preload_user=wodby in the .ini file, it work.

csandanov commented 3 years ago

Ok, I see, it just needed a user specified, we now set it by default to the same user www-data we use for fpm. Thank you for reporting this.