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
Reasons and two possible solutions described in the ZendOptimizerPlus issue.
We solved it by using $realpath_root
in the nginx config:
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;