Increasing PHP’s max_execution_time

Increasing PHP’s max_execution_time

When Moodle processes the PoodLL filter installation file, it performs a validation step (and other steps) which take some time to complete, because PoodLL is larger than most plugins. Your server may time out during this operation. Installing PoodLL is not the only intensive operation in Moodle. Backing up and restoring, and upgrading also can lead to timeouts.

To avoid this timeout occurring you can increase the time allocated to a task before PHP gives up on it. The PHP setting you need to alter is max_execution_time. The default is 30 (seconds) and we recommend that you raise this at a minimum to 90 or ideally to 300. There are two ways to do this. If you have admin level access to the server, you can edit the system’s php.ini. If you have only FTP/CPanel access to the server, you will edit the local php configuration file.

Before you do this however, first confirm the current max_execution_time. To do this, visit your server’s PHP Info page at:
Site Administration -> Server -> PHP Info

And find the entry for max_execution_time.  In this case it is 30.
max_executions_time=30

Editing php.ini

This file can be in different locations, and there may be multiple files on your server.  You can find the correct file by looking in your Moodle server’s PHP Info page. Find that at:
Site Administration -> Server -> PHP Info

There will be an entry for “loaded configuration file” and this will be the path to the php.ini file that you should edit.
loaded-configuration-file

Open this file in text editor, or using a command line tool like “nano” or “vi.” You will need to have admin/root access to write your changes to the file. Search for “max_execution_time” in the resource limits section, and change the value to 90.

php.ini resource limits

Optionally, also change the memory_limit value to 128M or higher. Then save the file. You will need to restart the web server for the changes to take effect. Be sure to check again on your PHP Info page that the changes have been applied.

max_execution_time=90

Editing your local configuration file with CPanel

If you are unable to edit the server’s main php.ini file, you can achieve the same thing by overriding the main file with a local file. Most PHP installations allow you to override the default values from php.ini at a per directory level. To do this you will need to create (or edit) a local config file. The name of the file can vary from server to server. Check again your PHP Info page, and this time look for “user_ini.filename”

User_inti filename

In the case above the file should be named “.user.ini” . Before creating it, have a look in the upper most folders of your web accessible directories to see if one already exists. From here on we will assume it doesn’t. But if it does you should just edit the closest one to your Moodle directory.

First go to CPanel and open the filemanager. It will look different depending on your CPanel theme.

cpanel filemanager

From the file manager turn on the display of “hidden files.” i.e Ones that start with a .
First choose settings, and from the popup dialog check “show hidden files” and save.

show hidden files

From your Moodle directory, or a folder above it, create a new file.

createfile_cpanel

Set the name of the file to the name we saw earlier as the value of user_ini.filename, and press the “create new file” button.

set new file name cpanel

Find the file in the file explorer, and open the file for editing ..

open file for editing cpanel

Add the “max_execution_time” entry as below, and optionally the other entries too

add_init_entries

After saving the file. Return to your Moodle’s PHP Info page. Hopefully you now have a max_execution_time of 90!

max_execution_time=90