Enable opcache for php in wamp - php

I try to enable opcache on wamp but it doesnt work. I changed the settings like this :
[opcache]
zend_extension=C:/wamp/bin/php/php5.5.12/ext/php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
I always have the red exclamation mark in the extension of php for opcache
whats wrong? some help pls
And it is in the the phpinfo()
Zend OPcache
Opcode Caching Up and Running
Optimization Enabled
Startup OK
Shared memory model win32
Cache hits 0
Cache misses 1
Used memory 483608
Free memory 133734120
Wasted memory 0
Cached scripts 1
Cached keys 2
Max keys 7963
OOM restarts 0
Hash keys restarts 0
Manual restarts 0
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli Off Off
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.fast_shutdown 1 1
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 8 8
opcache.load_comments 1 1
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 4000 4000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 128 128
opcache.mmap_base no value no value
opcache.optimization_level 0xFFFFFFFF 0xFFFFFFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 60 60
opcache.revalidate_path Off Off
opcache.save_comments 1 1
opcache.use_cwd On On
opcache.validate_timestamps On On
I found this If you want to know if it works : https://github.com/rlerdorf/opcache-status/blob/master/opcache.php

In PHP5.5.12 opcache is delivered as a zend extension but it is found in the standard ext folder.
You would therefore load it just like any other PHP extension, apart from using the zend_extension rather than extension paramter, so edit your php.ini file using the wampmanager menus to make sure you edit the right file like so :-
wampmanager -> PHP -> php.ini
First check that this parameter is set correctly :
extension_dir = "C:/wamp/bin/php/php5.5.12/ext/"
Now where you have loaded the OpCache dll in your example, do it like this and it will be loaded from the default extension folder just like a normal extension= would be :-
zend_extension=php_opcache.dll
You could do it like this :-
zend_extension="C:/wamp/bin/php/php5.5.12/ext/php_opcache.dll"
but there is no need to specify the full path as it is loaded from the standard ext folder.
Warning
If you are still developing you almost definitely don't what this turned on as it won't add any benefit and could add time to a standard compilation, recaching after every code change, and possibly not re-compiling and using the cached code when you don't want it to.

Since you are working on windows i think you should set the path like this
zend_extension=C:\path\to\php_opcache.dll (win) [Note the slash]
for your case:
zend_extension=C:\wamp\bin\php\php5.5.12\ext\php_opcache.dll
Note that when the path contains spaces you should wrap it in quotes:
zend_extension="C:\Program Files\PHP5.5\ext\php_opcache.dll"
Try it out and see if it helps

Related

How to detect if PHP JIT is enabled

What is the simplest way to detect if PHP is compiled with JIT and JIT is enabled from the running script?
You can query the opcache settings directly by calling opcache_get_status():
opcache_get_status()["jit"]["enabled"];
or perform a lookup in the php.ini:
ini_get("opcache.jit")
which is an integer (returned as string) where the last digit states the status of the JIT:
0 - don't JIT
1 - minimal JIT (call standard VM handlers)
2 - selective VM handler inlining
3 - optimized JIT based on static type inference of individual function
4 - optimized JIT based on static type inference and call tree
5 - optimized JIT based on static type inference and inner procedure analyses
Source: https://wiki.php.net/rfc/jit#phpini_defaults
opcache_get_status() will not work when JIT is disabled and will throw Fatal error.
echo (function_exists('opcache_get_status')
&& opcache_get_status()['jit']['enabled']) ? 'JIT enabled' : 'JIT disabled';
We must have following settings for JIT in php.ini file.
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1 //optional, for CLI interpreter
opcache.jit_buffer_size=32M //default is 0, with value 0 JIT doesn't work
opcache.jit=1235 //optional, default is "tracing" which is equal to 1254
php -i | grep "opcache"
checking:
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.jit => tracing => tracing

Yii 1.1.12 : How to confiure OpCache : I upgraded PHP from 5.3 to 5.5

I am using Yii 1.1.12 and recently upgraded my PHP from 5.3 to 5.5 and have found that APC is no longer to be used because OpCache has been made part of PHP5.5. In my Yii main.config file, I have the following entry:
'cache'=>array(
'class'=>'system.caching.CApcCache',
),
Two questions:
I am not able to find what should I change the above entry to so
that Yii takes it as its cache? I am extensivly using following in my code
Yii::app()->cache->set('some data to be cached', $CACHE_VARIABLES);
$get_var=Yii::app()->cache->get($CACHE_VARIABLES);
Am I on the right track or missing
something else?
Output of PhpInfo shows following Zend Opcache variables (Local and Master values are mentioned in front of each varaible:
Zend OPcache
Opcode Caching Up and Running
Optimization Enabled
Startup OK
Shared memory model win32
Cache hits 731
Cache misses 144
Used memory 4487992
Free memory 62545312
Wasted memory 75560
Cached scripts 138
Cached keys 261
Max keys 3907
OOM restarts 0
Hash keys restarts 0
Manual restarts 0
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli On On
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.fast_shutdown 0 0
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 4 4
opcache.load_comments 0 0
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 2000 2000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 64 64
opcache.mmap_base no value no value
opcache.optimization_level 0xFFFFFFFF 0xFFFFFFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 2 2
opcache.revalidate_path Off Off
opcache.save_comments 0 0
opcache.use_cwd On On
opcache.validate_timestamps On On
Thanks.

redeclare class condition_info

I upgrade my moodle from 2.6.4 to 2.7.1. After upgrading I've got blank (white) screen. Then I turn on debug display in config.php
$CFG->debug = 32767;
$CFG->debugdisplay = true;
After that I receive an error: Fatal error: Cannot redeclare class condition_info in /home/moodle/public_html/lib/conditionlib.php on line 105.
Then I search and found that might be a problem with opcache (https://tracker.moodle.org/browse/MDL-45797). So I follow this doc - http://docs.moodle.org/27/en/admin/environment/php_setting/opcache.enable and enable opcache in php.ini:
[opcache]
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 4000
opcache.revalidate_freq = 60
; Required for Moodle
opcache.use_cwd = 1
opcache.validate_timestamps = 1
opcache.save_comments = 1
opcache.enable_file_override = 0
; If something does not work in Moodle
;opcache.revalidate_path = 1 ; May fix problems with include paths
;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487
; Experimental for Moodle 2.6 and later
;opcache.fast_shutdown = 1
;opcache.enable_cli = 1 ; Speeds up CLI cron
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.
Reload apache and it still doesn't work. I also try to comment out part ; If something does not work in Moodle and error still occurs. Any idea what might be wrong?
I also read that might be a problem with themes. Before I upgrade I switch theme to Clean which is default theme in 2.7.
I have ubuntu 14.04 with PHP 5.5.9-1ubuntu4.3 (cli) (built: Jul 7 2014 16:36:58)
This might be a bug or an incompatibility with the opcache system.
i would suggest to turn the opcache off: opcache.enable = 0. The opcache is only good, if everything works and you want to gain some additional performance.
restart PHP
restart Apache
Finally try one of these downloads:
2.7 - https://github.com/moodle/moodle/archive/v2.7.1.tar.gz
master [latest] - https://github.com/moodle/moodle/archive/master.zip
If the problem persists: please open a new bug report over at moodle and reference the report you found. it is clearly related.

Symfony 2 | OPcache | Warning: filemtime(): stat failed for Acme-DemoBundle-Controller-SecuredController.cache.php in FileCacheReader.php

I have installed Symfony 2 and I have activated the opcache (ZendOPtimizer) extension and when I intent to generate the cache of a web page O've got this error :
Warning: filemtime(): stat failed for C:/Apache24/htdocs/symfony/app/cache/dev/annotations/Acme-DemoBundle-Controller-SecuredController.cache.php in C:\Apache24\htdocs\symfony\vendor\doctrine\common\lib\Doctrine\Common\Annotations\FileCacheReader.php line 97
This is my opcache config :
zend_extension="c:\php\ext\php_opcache.dll"
opcache.enable=1
opcache.use_cwd=0
opcache.validate_timestamps=0 ; file stat
opcache.revalidate_freq=2 ; seconds
opcache.revalidate_path=0
opcache.save_comments=0
opcache.load_comments=0
opcache.dups_fix=0
opcache.inherited_hack=0
opcache.log_verbosity_level=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.enable_file_override=1
opcache.max_wasted_percentage=5 ; percent waste until restart
opcache.consistency_checks=0
opcache.force_restart_timeout=180
opcache.blacklist_filename=paypal.php
opcache.fast_shutdown=1
opcache.optimization_level=0xffffffff
opcache.enable_slow_optimizations=1
opcache.max_file_size=0
When I disable this extension, the generation of the cache works
Versions :
Symfony 2.3.3
PHP 5.5
Apache 2.4.6 For Windows
I had exactly the same problem on my Mac, using the homebrew php55 version.
As mentioned in the Optimizer documentation, the option opcache.enable_file_override=1 may break some frameworks. It seems that is the case for Symfony2. Switching the value to 0 solved the problem.
1 - Make sure you have disabled APC or it'll create conflicts.
2 - Make sure you've restarted apache entirely after activating opcache.

APC & Wordpress: Server down if enable APC

Some basic information:
Linux: 2.6.32 (64bit)
PHP: 5.4.15
Apache: 2.4.4
MySQL: 5.6.11
APC: 3.1.9
Wordpress: 3.5.1, with Woocommerce(2.0.10)
The problem is, when I enable APC, the following errors occur:
Warning: register_shutdown_function(): Invalid shutdown callback 'wpdb::__destruct' passed in /usr/local/httpd/htdocs/wp-includes/wp-db.php on line 537
Fatal error: Call to undefined method wpdb::init_charset() in /usr/local/httpd/htdocs/wp-includes/wp-db.php on line 542
Here is my APC config in php.ini:
[APC]
; Reference: http://www.php.net/manual/en/apc.configuration.php
extension=apc.so
apc.enabled=1
apc.shm_segments=1
; 32MB per Wordpess install. Ref: http://gregrickaby.com/the-perfect-apc-configuration/
apc.shm_size=320M
;Relative to the number of cached files (you may need to watch your stats for a day or two to find out a good number)
apc.num_files_hint=10000
;Relative to the size of WordPress
apc.user_entries_hint=10000
;The number of seconds a cache entry is allowed to idle in a slot before APC dumps the cache
apc.ttl=7200
apc.user_ttl=7200
apc.gc_ttl=3600
;Setting this to 0 will give you the best performance, as APC will
;not have to check the IO for changes. However, you must clear
;the APC cache to recompile already cached files. If you are still
;developing, updating your site daily in WP-ADMIN, and running W3TC
;set this to 1
apc.stat=1
;This MUST be 0, WP can have errors otherwise!
apc.include_once_override=0
;Only set to 1 while debugging
apc.enable_cli=0
;Allow 2 seconds after a file is created before it is cached to prevent users from seeing half-written/weird pages
apc.file_update_protection=2
;Leave at 2M or lower. WordPress does't have any file sizes close to 2M
apc.max_file_size=2M
;Ignore files
apc.filters = "/usr/local/httpd/htdocs/apc.php,/usr/local/httpd/htdocs/phpinfo.php,wp-cache-config"
apc.cache_by_default=1
apc.use_request_time=1
apc.slam_defense=0
;apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.stat_ctime=1
apc.canonicalize=1
apc.write_lock=1
apc.report_autofilter=0
apc.rfc1867=0
apc.rfc1867_prefix =upload_
apc.rfc1867_name=APC_UPLOAD_PROGRESS
apc.rfc1867_freq=0
apc.rfc1867_ttl=3600
apc.lazy_classes=0
apc.lazy_functions=0
apc.file_md5=0
Here are some combination of what I tried:
apc.stat = 0, apc.stat_ctime=0
apc.stat = 1, apc.stat_ctime=1
apc.stat = 0, apc.stat_ctime=1
apc.stat = 0, apc.stat_ctime=0
However, APC still cannot be used. Only when I disable APC, the site works properly.
Can anyone please tell me what is the problem?
Thank you in advance.
APC config in image
Probably APC does not interpret that syntaxis of register_shutdown_function correctly. There are two ways of defining static method callbacks with this function:
register_shutdown_function('someClass::someMethod');
register_shutdown_function(array('someClass', 'someMethod'));
You could refer to the documantation and commetns for more information: http://php.net/manual/en/function.register-shutdown-function.php
Wordpress also worked for me when I disabled apc from php.ini

Categories