I am trying to reset PHP opcache after a symlink-style deployment. There is the opcache_reset.php
file in my project which is executing by wget
after the document root's symlink replacement:
<?php
clearstatcache(true);
opcache_reset();
In spite of that, the old files are still used. According to opcache_get_status()
output, the number of manual_restarts
increases, last_restart_time
keeps up-to-date, but the file paths remains outdated. I need to call opcache_reset.php
manually after a minute or so after deploy to make things right.
PHP version is 5.5.6, ZendOpcache is 7.0.3-dev. Opcache config:
opcache.blacklist_filename => no value
opcache.consistency_checks => 0
opcache.dups_fix => Off
opcache.enable => On
opcache.enable_cli => On
opcache.enable_file_override => Off
opcache.error_log => no value
opcache.fast_shutdown => 1
opcache.force_restart_timeout => 180
opcache.inherited_hack => On
opcache.interned_strings_buffer => 8
opcache.load_comments => 1
opcache.log_verbosity_level => 1
opcache.max_accelerated_files => 4000
opcache.max_file_size => 0
opcache.max_wasted_percentage => 5
opcache.memory_consumption => 128
opcache.optimization_level => 0xFFFFFFFF
opcache.preferred_memory_model => no value
opcache.protect_memory => 0
opcache.restrict_api => no value
opcache.revalidate_freq => 60
opcache.revalidate_path => Off
opcache.save_comments => 1
opcache.use_cwd => On
opcache.validate_timestamps => On
I also faced that issue then finally I make a solution.
You can connect to a automatically guessed fastcgi server (if /var/run/php5-fpm.sock is a file or 127.0.0.1:9000)
Example :
You can notice that the memory , cache keys , hits everythings became 0 :-). Its very useful. I also intrigrated it with Ansible easily.
Its application for apcu and others stuffs : Check more there http://gordalina.github.io/cachetool/
Reasons and two possible solutions described in the ZendOptimizerPlus issue. We solved it by using
$realpath_root
in the nginx config:If you are for some reason not able to use fastcgi_param with
$realpath_root
and using symlink style deployment, then try to set theopcache.revalidate_path = On
in your php ini configuration. I was not able to find any good documentation that explains how this ini directory works under the hood, but it did work after I changed the symlinks. Hope this helps anyone.