Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP opcache reset + symlink-style deployment

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
like image 463
Vitaly Chirkov Avatar asked May 19 '14 12:05

Vitaly Chirkov


People also ask

How do you reset OPcache?

To clear the Opcache on CLI, just restart your PHP command. It's usually as simple as CTRL+C to abort the command and start it again.

What is OPcache Enable_cli?

opcache. enable_cli boolean enables the opcode cache for the CLI version of PHP. This is mostly useful for testing and debugging. Therefore it should be disabled unless you're really need this.

Is OPcache enabled by default?

Using OPcache with WordPressOPcache is enabled by default which you can see in a phpinfo.


1 Answers

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;
like image 99
Vitaly Chirkov Avatar answered Sep 28 '22 04:09

Vitaly Chirkov