wodby / php

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

Additional opcache settings: blacklist_filename and optimization_level #138

Open bramcordie opened 3 years ago

bramcordie commented 3 years ago

Hi, I'm looking for a proper way to set the following opcache settings that are not supported by environment variables out of the box:

opcache.optimization_level=0x7FFEBFFF
opcache.blacklist_filename=/var/www/html/opcache-blacklist

I did get the blacklist filename working by mounting an additional docker-php-custom.ini file, with the exact 2 lines above, in my docker-compose.override.yml file:

version: '3.1'

services:

  php:
    volumes:
      - ./docker-php-custom.ini:/usr/local/etc/php/conf.d/docker-php-custom.ini

I checked phpinfo() which show the expected blacklist filename path.

then I looked at opcache.optimization_level and it seems stuck at 0. Even if I don't try to override, it is set to 0 which is a weird default to begin with? I would expect a bitmask value like the PHP docs suggests: 0x7FFEBFFF, see: https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.optimization-level

Tested with the following php image tags: 7.4-dev-4.18.6 and 7.4-dev-4.20.0 on both nginx or apache.

bramcordie commented 3 years ago

opcache.optimization_level getting stuck at 0 was caused by xdebug as also mentioned in the archlinux tracker. In hindsight this might be obvious but hopefully this comment might save someone else the time of figuring this out.

It would still be nice to set both opcache.optimization_level and opcache.blacklist_filename with environment variables.