OPCode cache

OPCode cache

by Kevin Burton -
Number of replies: 18

During installation it is sugested that I add the php extension for opcode cacheing. PHP was installed with WAMP and I don't see that in the list of extensions to add. It is also listed as a PHP setting. Also I am not sure what to add. Ideas? Thank you.

Average of ratings: -
In reply to Kevin Burton

Re: OPCode cache

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

(not strictly true but...) you should be running at least PHP 5.5 before we go any further. If you are not you can ignore the warning.  Otherwise...

http://docs.moodle.org/26/en/OPcache

Average of ratings: Useful (2)
In reply to Howard Miller

Re: OPCode cache

by Kevin Burton -

The documentation mentions changes to php.ini. For the WAMP server there is also a phpForApache.ini. Should I make the changes there as well?

In reply to Howard Miller

Re: OPCode cache

by Kevin Burton -

The only way that I was able to get opcache to show up in phpinfo was by adding the line:

zend_extension=php_opcache.dll

This line had to be added before the 'extension=' section. This was through trial and error and was not readily apparent from the documentation.

Thank you.

 

Average of ratings: Useful (4)
In reply to Kevin Burton

Re: OPCode cache

by Ken Task -
Picture of Particularly helpful Moodlers

Thank you!  Thank you!  Have been struggling with an 'older' CentOS 5.x, PHP 5.3 box with 2 Gig  memory that will never be upgraded (trying to keep it alive).  Found it was possible to get zend opcache installed on it, but could never get it to load.  Duh!  Adding zend_ in front of the .so location line in the self-created opcache.ini in php.d did the trick.  Am now able to compare APC with ZendOpCache.

Again ... many thanks!

'spirit of sharing', Ken

 

Average of ratings: Useful (1)
In reply to Ken Task

Re: OPCode cache

by Mark Hayes -

Ken, can you expand a bit further on exactly what you did?

I am using Ubuntu Server 12.04 LTS, which includes PHP 5.3.10. Trying to get Zend OPcache to work.

If I add the following lines to /etc/php5/apache2/php.ini, I can see Zend OPcache when I invoke phpinfo.php, but moodle 2.2.11 stops working altogether - "No data received" message in the browser.  If I remove the lines from php.ini, moodle works again.

[zendopcache]

zend_extension=/usr/lib/php5/20090626/opcache.so
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

; 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

In reply to Mark Hayes

Re: OPCode cache

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Personally - I would upgrade your OS/PHP and get to PHP 5.5 (or newer). I had all sorts of problems on PHP 5.2 and 5.3. Upgrading PHP turned out to be the easier solution. 

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: OPCode cache

by Ken Task -
Picture of Particularly helpful Moodlers

Well, I could, but it was with a CentOS 5.9 boxen ... whose upstream repo doesn't offer anything higher than 5.3.3.xxx just yet.  While what I did might be similar, there's enough of a difference where it might not apply with a Ubuntu system.

I'll have to write up notes and post ... but like I said ... similar but not same.

'spirit of sharing', Ken

In reply to Ken Task

Re: OPCode cache

by sara HHH -

i have also the same question.

PHP setting should be changed.

PHP opcode caching improves performance and lowers memory requirements, OPcache extension is recommended and fully supported.

my PHP -v  is PHP 5.4.16 i red in moodle NOTE: If you are running PHP 5.3 or 5.4 you can safely ignore the Environment Check message about OpCache''.
shall i ignore it or not?

Many Thanks

In reply to sara HHH

Re: OPCode cache

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can ignore it. Nothing bad will happen.

You should, however, consider upgrading PHP to 5.5 (or 5.6)  which comes with Opcache bundled in. I don't want to overstate the benefit but you typically see the load come down a bit on the server which is no bad thing. 

Also, you should note that PHP 5.4 ceases to be supported in September (http://php.net/supported-versions.php)

PS. Better not to raise threads from the grave. It would have been better to create a new one. 

In reply to Mark Hayes

Re: OPCode cache

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up ...

Got the directions for a CentOS 5.9 boxen (2 gig memory - not a virtual environment) from:

http://www.adrianworlddesign.com/Knowledge-Base/Web-Hosting/Zend-Guard/Zend-Guard-Loader-on-CentOS

As the URL tells ya, had to install Zend-Guard-Loader and to get the zend_opcache to actually talk to the Apache server.

Also, the so I downloaded was really a dev for php 5.3.3 - highest version available from php.net (also require registration on their system to download). OpCache 7.0.3-dev.

I used the /etc/php.d/ route with a zendguardloader.ini (this came with ZGL) and had to place the .so in a directory for my system.

; Enable ZendGuard loader module
; zend_extension=/usr/lib64/php/modules/ZendGuardLoader.so
zend_extension=/usr/lib/php/modules/ZendGuardLoader.so

; Enables loading encoded scripts. The default value is On
zend_loader.enable=1

; Disable license checks (for performance reasons)
zend_loader.disable_licensing=0

; The Obfuscation level supported by Zend Guard Loader. The levels are detailed in the official Zend Guard Documentation.
; 0 - no obfuscation is enabled
zend_loader.obfuscation_level_support=0

; Path to where licensed Zend products should look for the product license. For more information on how to create a license file,
; see the Zend Guard User Guide
; zend_loader.license_path=

Again using /etc/php.d/ an opcache.ini

[root@moodle php.d]# cat opcache.ini
zend_extension=/usr/lib/php/modules/opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1

The key for me was this: zend_extension.   Before I had extension= like other extensions and forgot that zend extensions needed to be id'd as zend extensions ... thus zend_extension=

php -m now shows:

[Zend Modules]
Zend Guard Loader
Zend OPcache

And can use ocp.php and/or opcache.php now to view/reset.

Again ... don't know if Zend Guard Loader needed for Ubuntu ... but it was for CentOS 5.x.  My situation was such that the entity will not spring for more memory chips (2 Gig memory not a virtual environment) nor opt to upgrade the OS to a higher version of anything.

Am in agreement with Howard ... if you can upgrade the OS or at least the PHP as the newer PHP  it does come with zend opcache built in.   Working to keep an old (somewhat out of date hardware wise) server is at best limited ... life/etc..

'spirit of sharing', Ken

 

 

In reply to Ken Task

Re: OPCode cache

by Mark Hayes -

thanks Ken and Howard -

just spotted the following at the moodle tracker. seems like i should i do as Howard suggests and bump Ubuntu to latest, or at least the PHP. i was trying to stick with LTS bundles as they tend to be more stable?

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: OPCode cache

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well... they are "long term support" which (to possibly be pedantic) is not more stable. What it means is that patches will continue to be made for (iirc) 5 years. This is significant if you are running a bunch of server boxes with high availability and you don't want to touch the OS for the life of the boxes (hopefully). You are not really in that position, you are on the pointy-edge of running Moodle and so you need reasonably up to date OS components. It's a compromise. If you can live with some down-time it's reasonably easy to upgrade from one Ubuntu release to another every 6 months. OR... if you can wait a bit, there's another LTS release coming along with 14.04 in April.

Average of ratings: Useful (2)
In reply to Howard Miller

Re: OPCode cache

by Mark Hayes -

ok, i follow all that Howard. i am fiddling on my own laptop which has ubuntu 13.10.
i noticed that 13.10, in addition to php 5.5, includes apache 2.4
have been using apache 2.2 all along. some changes there also.

looks like some of the apache 2.2. config needs to be tweaked for 2.4
some of my 2.2 sites are no longer accessible via apache 2.4

 

In reply to Kevin Burton

Re: OPCode cache

by Dhinesh Radhakrishnan -

While Installing I had an error,

Opcache error


My php Version is 5.5, I copied the following code to xampp/php/php.ini in  "Module Settings"

But still I get the same error, If i skip the error and continue installing, it installs successfully and creates admin user and moves to Edit Profile Settings Page

From that page I cant able to go to any page if I select the link

In reply to Dhinesh Radhakrishnan

Re: OPCode cache

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

As mentioned above, you might also need to tweak "zend".  Below is the line that I added to my php.ini.  Maybe this will help.


; Need to specify this

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20121212/opcache.so



In reply to Rick Jerz

Re: OPCode cache

by Dhinesh Radhakrishnan -

Thanks for replying Rick, I tried it and installation was completed successfully,

But now I am getting an error, if I try to access moodle again

Here is the Link on the error

In reply to Dhinesh Radhakrishnan

Re: OPCode cache

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It is not an error, just a suggestion/recommendation.