Daily Shaarli

All links of one day in a single page.

April 6, 2023

How2: Edit php.ini file for Moodle instances running php fast package manager.

Find the php.ini file you need.
locate php.ini | grep fpm

This will return a variety of files like the examples below:

/etc/php/7.2/apache2/php.ini
/etc/php/7.2/cli/php.ini
/etc/php/7.2/fpm/php.ini
/etc/php/7.3/apache2/php.ini
/etc/php/7.3/cli/php.ini
/etc/php/7.3/fpm/php.ini
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/apache2/php.ini.ucf-dist
/etc/php/7.4/cli/php.ini
/etc/php/7.4/fpm/php.ini
/etc/php/8.0/apache2/php.ini
/etc/php/8.0/cli/php.ini
/etc/php/8.0/fpm/php.ini

Choose the specific file you will need to edit. If you are running PHP Fast Package Manager, it will be the /etc/php/X.X/fpm/php.ini file where X.X is whatever version of PHP you currently have set for the Moodle site.

sudo vim /etc/php/X.X/fpm/php.ini

use the find feature in vim (/) to look for and edit the following values with the suggested minimums:

post_max_size = 256M
upload_max_filesize = 128M
max_input_vars = 7000
memory_limit =1024M
max_execution_time =300
max_input_time = 600

Save the file and exit vim (:wq)

Restart the PHP Fast Package Manager for the specific PHP version
sudo service phpX.X-fpm restart

Restart Apache
sudo service apache2 restart

You can create an info.php file in the webroot of the site with the following contents to check and verify that your changes were successful.

<?php
phpinfo();
?>

After viewing the info.php page, change the file to prevent exposing sensitive information about your site.
mv info.php info.php.bkp