phpopcache

proper opcache configuration for CLI


what is the proper opcache configuration when using PHP for CLI only?

I find very confusing/old resources and am not sure this is the proper conf:

[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.file_cache=/tmp/php-opcache

More specifically: the doc describe opcache.file_cache as a second level cache, SHM memory being the 1st level. But I can't find any recent resource indicating whether the SHM memory is shared across PHP's cli invocations depending on this, either opcache.file_cache isn't nescessary or opcache.file_cache_only is required.

Secondly, I'd like to determine the required management over the content of the directory that opcache.file_cache points to


Solution

  • Thanks to @Chris Haas comments, I've got some informations, but don't consider this answer as comprehensive: there are a lot of unknown around using the opcache for CLI.

    Properly enabling the opcache for CLI only require this conf:

    [opcache]
    opcache.enable_cli=1
    opcache.file_cache=/tmp/php-opcache
    opcache.file_cache_only=1
    

    notes:

    interesting ressources:

    Personally, I convinced my team to not enable this feature "opcache for CLI", because I think there a too much dark corners.