Note: You are currently viewing documentation for Moodle 2.6. Up-to-date documentation for the latest stable version of Moodle may be available here: OPcache.

OPcache: Difference between revisions

From MoodleDocs
(environment template, category)
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Environment}}
{{Environment}}
{{New features}}
{{New features}}
Standard OPCache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory use.
The standard OPcache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory usage.


==Installation==
==Installation==


The OPcache extension is distributed as part of PHP 5.5.0 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache.
The OPcache extension is distributed as part of PHP 5.5.0 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache.
'''NOTE: If you are running PHP 5.3 or 5.4 you can safely ignore the Environment Check message about OpCache. Nonetheless, [https://moodle.org/mod/forum/discuss.php?d=245885 it might be useful] to upgrade Operating System/PHP and get to 5.5 or newer; as there have been all sorts of problems described on PHP 5.2 and 5.3, and upgrading PHP turned out to be the easier solution. '''


==Configuration==
==Configuration==
Line 26: Line 28:
; If something does not work in Moodle
; If something does not work in Moodle
;opcache.revalidate_path = 1 ; May fix problems with include paths
;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
; Experimental for Moodle 2.6 and later
;opcache.fast_shutdown = 1
;opcache.fast_shutdown = 1
;opcache.enable_cli = 1 ; Speeds up CLI cron
;opcache.enable_cli = 1 ; Speeds up CLI cron
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with addons and other apps.
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.
</code>
 
When using non-Windows platforms, you have to use the ''zend_extension'' configuration to load the OPcache extension into PHP by adding to php.ini.
<code ini>
zend_extension=/full/path/to/opcache.so
</code>
 
When using IIS you will need PHP 5.5 and you will need to add the extension for opcache under the ''ExtensionList'' section of the php.ini file. For PHP 5.3 and 5.4 you can download the binaries separately from [http://windows.php.net/downloads/pecl/releases/opcache] and you will also need to enter full absolute path to the module dll in php.ini.
 
<code ini>
[ExtensionList]
...
zend_extension=php_opcache.dll
</code>
</code>


==See also==
==See also==
* [http://pecl.php.net/package/ZendOpcache PECL ZendOPcache]
* [http://pecl.php.net/package/ZendOpcache PECL ZendOPcache]
* [http://windows.php.net/downloads/pecl/releases/opcache/ Windows builds for PHP 5.3-5.4]
Forum discussions:
* [https://moodle.org/mod/forum/discuss.php?d=244133 OPcache: Memory Usage = 100% (is this good or bad?)]
* [https://moodle.org/mod/forum/discuss.php?d=245885 OPCode cache]


[[Category:Environment]]
[[Category:Environment]]

Latest revision as of 15:38, 7 March 2014

New feature
in Moodle 2.6!

The standard OPcache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory usage.

Installation

The OPcache extension is distributed as part of PHP 5.5.0 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache.

NOTE: If you are running PHP 5.3 or 5.4 you can safely ignore the Environment Check message about OpCache. Nonetheless, it might be useful to upgrade Operating System/PHP and get to 5.5 or newer; as there have been all sorts of problems described on PHP 5.2 and 5.3, and upgrading PHP turned out to be the easier solution.

Configuration

PHP.ini settings:

[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.

When using non-Windows platforms, you have to use the zend_extension configuration to load the OPcache extension into PHP by adding to php.ini. zend_extension=/full/path/to/opcache.so

When using IIS you will need PHP 5.5 and you will need to add the extension for opcache under the ExtensionList section of the php.ini file. For PHP 5.3 and 5.4 you can download the binaries separately from [1] and you will also need to enter full absolute path to the module dll in php.ini.

[ExtensionList] ... zend_extension=php_opcache.dll

See also

Forum discussions: