I'm in charge of the opcode cache exchange here in my company, we're moving from eaccelerator to the Zend OPCache shipped with PHP 5.5.
When I access PHP in CLI, it seems like the OPCache is working fine:
PHP 5.5.5 (cli) (built: Oct 15 2013 10:29:13)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
But when I access my website via Apache, the benchmarks show no improvements compared to the same pages using no opcode cache. Also, get_loaded_extensions(true)
returns an empty array.
Can anyone answer me why on earth it isn't working?
I'm using windows 7, Apache 2.4.6 from Apache Lounge, PHP 5.5.5 from windows.php.net.
EDIT:
As requested, my OPCache configuration:
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
opcache.revalidate_freq=60
;opcache.revalidate_path=0
;opcache.save_comments=1
;opcache.load_comments=1
opcache.fast_shutdown=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
OPcache can only be compiled as a shared extension. If you have disabled the building of default extensions with --disable-all, you must compile PHP with the --enable-opcache option for OPcache to be available. Once compiled, you can use the zend_extension configuration directive to load the OPcache extension into PHP.
To check if the caching engine works properly, just look at the percentages at the “Overview” tab at the opcache-gui page. If the memory usage and hit rate values are greater than zero, it means that the OpCache is caching the PHP code and the cached files are being used to handle the requests.
8. If your server has PHP 5.5 or higher, you will see an in the admin bar to Purge OPcache. You can read on the PHP manual to know more about OPcache: OPCache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
Found the answer!
zend_extension
extensions must set the complete path, not a relative one.
In this case, zend_extension="C:\Apache24\php\ext\php_opcache.dll"
solved my problems.
By default there are opcache settings in php.ini files like opcache.eneable but enabling opcache does not take effect unless you add:
zend_extension=php_opcache.dll
to your config file. Remember it is zend_extension and not regular exstension !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With