简体   繁体   中英

PHP 5.5 OPCache not working on apache

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

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.

WINDOWS PHP 7 SOLUTION

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 !

Make sure that you have "opcache" in your phpinfo(); report. By default :

A DLL for this PECL extension is currently unavailable. See also the building on Windows section.

Can you confirm that the extension is loaded?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM