Jump to content

Recommended Posts

Hello,

I have correctly configured OPcache for PHP-FPM (5.6, 7.4, and 8.2) using Apache and mpm_worker, but OPcache does not respect my settings.

php_value[opcache.blacklist_filename] = /home/cycles/opcache_blacklist

I can view the configuration as complete both in phpinfo() and using a sweet GitHub package - https://github.com/amnuts/opcache-gui

My "opache_blacklist" file uses the standard INI file format and shows the following:

/home/cycles/public_html/wp-admin
/home/cycles/public_html/wp-content/plugins/biorhythms
/home/cycles/php-error-log-viewer
/home/cycles/public_html/wp-config.php
/home/cycles/public_html/wp-login.php

I have tried using the full path as shown above and using wildcards "*" but nothing seems to disable the caching and acceleration.

The only way I can stop it is to completely disable OPcache, which is undesirable. 

Perhaps some other OPcache setting must be enabled; any help is greatly appreciated.

When you are using opcache gui, does the "Ignored files" tab appear?  What if anything is in that tab?

For entire directories you most certainly need a glob like this:

/home/cycles/public_html/wp-admin/*

With that said, it appears you are trying to make the blacklist file setting in an .htaccess?  The blacklist file is an INI SYSTEM parameter which means it can only be set in the php.ini or httpd.conf.

A page with phpinfo(); would help you verify the settings.

  • 2 weeks later...

Thank you for your quick reply, but I have spent too much time and still have no luck!

The "ignored files" tab does not appear, which was a great insight as I went through the "opcache-gui" code...

https://github.com/amnuts/opcache-gui/tree/master

I have tried many combinations for the "opache_blacklist.txt" file, wildcards, rebooting the system, and even unix2dos conversion, but nothing.

Below is the output of my "opcache_get_configuration()" call in a simple test script.

As you can see, the array element "blacklist" is empty; any clues as to why?

/home/cycles/opcache-gui/test_opcache.php:5:
array (size=3)
  'directives' => 
    array (size=34)
      'opcache.enable' => boolean true
      'opcache.enable_cli' => boolean false
      'opcache.use_cwd' => boolean true
      'opcache.validate_timestamps' => boolean true
      'opcache.validate_permission' => boolean false
      'opcache.validate_root' => boolean false
      'opcache.dups_fix' => boolean false
      'opcache.revalidate_path' => boolean true
      'opcache.log_verbosity_level' => int 3
      'opcache.memory_consumption' => int 67108864
      'opcache.interned_strings_buffer' => int 8
      'opcache.max_accelerated_files' => int 3907
      'opcache.max_wasted_percentage' => float 0.05
      'opcache.consistency_checks' => int 0
      'opcache.force_restart_timeout' => int 180
      'opcache.revalidate_freq' => int 30
      'opcache.preferred_memory_model' => string '' (length=0)
      'opcache.blacklist_filename' => string '/home/cycles/opcache-gui/opcache_blacklist.txt' (length=46)
      'opcache.max_file_size' => int 0
      'opcache.error_log' => string '/home/cycles/logs/php_opcache.log' (length=33)
      'opcache.protect_memory' => boolean false
      'opcache.save_comments' => boolean false
      'opcache.enable_file_override' => boolean false
      'opcache.optimization_level' => int 2147401725
      'opcache.lockfile_path' => string '/tmp' (length=4)
      'opcache.file_cache' => string '' (length=0)
      'opcache.file_cache_only' => boolean false
      'opcache.file_cache_consistency_checks' => boolean true
      'opcache.file_update_protection' => int 2
      'opcache.opt_debug_level' => int 0
      'opcache.restrict_api' => string '' (length=0)
      'opcache.huge_code_pages' => boolean false
      'opcache.preload' => string '' (length=0)
      'opcache.preload_user' => string '' (length=0)
  'version' => 
    array (size=2)
      'version' => string '7.4.33' (length=6)
      'opcache_product_name' => string 'Zend OPcache' (length=12)
  'blacklist' => 
    array (size=0)
      empty

Any help is greatly appreciated; many thanks in advance.

I don't see an issue, based on what you've shown. 

The only other thing I can think is that the file /home/cycles/opcache-gui/opcache_blacklist.txt has permissions that don't allow it to be read by the php-fpm process user.  

Just to be clear, this simple test script is in a webpage and not just a script run from CLI php, correct?

Opcache is basically useless for php cli because the php process that includes the cache is disposed of each time.

I'd be interested to know what you currently have in your opcache_blacklist.txt file, and I'd like to have you also add a call to https://www.php.net/manual/en/function.opcache-get-status.php

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.