Configuring php.ini

Configuring php.ini

by Rachel Horst -
Number of replies: 10


I was checking my moodle version (3.1.2) & PHP environment (5.6.31) and found this warning:

PHP setting should be changed.

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

This directed me to a page on how to configure the php.ini file. 

First question is: Where can I find the php.ini file? 


Second bigger question.... once I've found the file do I make sure it says the following (as per the instructions on the link) by adding and deleting text?:

PHP.ini settings:

[opcache]
opcache.enable = 1
opcache.memory_consumption = 64
opcache.max_accelerated_files = 8000
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.


Third question. I am using a non-Windows platform. Below are instructions. Do I add that text to the bottom of the settings listed above?

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

I feel way out of my depth here! Thanks in advance for your help!!


Best,

Rachel

Average of ratings: -
In reply to Rachel Horst

Re: Configuring php.ini

by Lalit Chandwani -

OPcache needs to first be installed in your system/server first. I have CENTOS, so this link was useful : https://www.webfoobar.com/index.php/node/31

php.ini file can be found in your server folder, it depends what you have installed. If you are using XAMPP then it is located in opt/lampp/etc

Once you install OPcache, then in php.ini you will automatically find zend_extension=[some path]. It could be commented, remove the comment and set the value to opcache.so

As far as your second question, I believe those details need to be updated in opcache.ini

Restart Apache and MySQL server and you should be good to go smile

In reply to Rachel Horst

Re: Configuring php.ini

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

What's your operating system?  How was PHP installed?

You can actually ignore the message, however... In Moodle, if you go to Site administration > Server > PHP Info, the resulting information page show you the location of php.ini (it may be split into lots of files) right near the top. 

In reply to Rachel Horst

Re: Configuring php.ini

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

As Howard said, you can ignore opcache and your moodle will work fine.

To find php.ini, if your moodle is running, go to Site Admin, Server, php info, and look at the 6th and 7th lines.  This shows where your php.ini is located.

Depending upon your server configuration, you might need to enable ZendOpcache for any of this to work.  Enabling ZendOpcache can be tricky, or easy depending upon your server tools and your skills at all of this.

When you can verify your php.ini location, and verify that you have enabled ZendOpcache, come back for more help.  (ZendOpcache should show in the php info webpage that shows the php.ini location (as mentioned above.)  It should appear something like my screen shot, below.

Attachment Zend.jpg
In reply to Rick Jerz

Re: Configuring php.ini

by Rachel Horst -

Thanks everyone,

I think I will ignore it as the moodle seems to be working fine and my skills at this point aren't that great.

My site does seem to be moving very slowly though. Might resolving this issue improve my speed? Is there any way to check why it's running so slow?


Thanks in advance!


Rachel

In reply to Rachel Horst

Re: Configuring php.ini

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

It's very unlikely that this will make much difference to the page load time (if that's what you mean). It tends to reduce the *load* which is still a good thing...

To help we'll need to know a lot more about your server setup. Is this hosted? Some cheaper hosting isn't really up to the job of running Moodle.

In reply to Rick Jerz

Re: Configuring php.ini

by Rachel Horst -

Hi again,

I'm realizing that I don't have access to the php files, I only have moodle site administration privileges but not server access. Is there anything I can do at this level to improve the speed of my site?



Thanks!



In reply to Rachel Horst

Re: Configuring php.ini

by Lalit Chandwani -

I don't know if you can do anything about it if you do not have access to php files. I don't think so at least. But yes solving OPcache issue does improve speed a bit. But not mandatory to fix, it is just a warning and not really an error.

In reply to Rachel Horst

Re: Configuring php.ini

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

You haven't told us where you are hosting your site, so it is difficult to provide any more help.  We also need to know how you installed your moodle.

In reply to Rick Jerz

Re: Configuring php.ini

by Rachel Horst -

Thanks for your reply! So I am a high school teacher at an alternative school. The school has a main moodle site but I created a seperate program site in order to have more ability to tailor it, explore plugins, themes, functionalities etc. and have the access to do so. My site is hosted by the same server as the school's main moodle site, which is the district server and should be pretty solid. I didn't install the moodle myself as I don't have access. At the moment it's 3.1.6 but I've asked it to be upgraded. They recently updated the main site to 3.2 as well with some difficulties and they seem to be having similar problems with my site. They have duplicated the site to do this so I am still live and able to work on it. (School is starting up soon!)  I am using the eguru theme. My site runs much slower than the school moodle site though at that time we were still using the same moodle version....  Here's a link to the site. http://sd46online.ca/moodleflex/

Thanks in advance for your help! 

Rachel

In reply to Rachel Horst

Re: Configuring php.ini

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

Okay. You might have to convince your IT staff of the value of making some of these php.ini changes.  The changes will benefit all.  The changes seem out of your control, so you are stuck.

Depending upon the size of your classes, you might be able to use MoodleCloud

Pretty use of purple on the site!