If you have installed Moodle directly on a server using PHP, you may need to increase the file upload limit. You can do this by changing the php.ini file settings. Follow these steps to increase the upload limit in Ubuntu.
Step 1: Locate the PHP.ini File
The php.ini file is typically located in:
/etc/php/<version>/apache2/php.ini
Replace <version> with your installed PHP version (e.g., 8.1, 8.2). To check installed PHP versions, use:
ls /etc/php
To confirm the exact php.ini file location, run:
php --ini | grep "Loaded Configuration File"
Step 2: Edit the PHP.ini File
Use a text editor like nano or vim to edit the file:
Find and modify the following settings to increase the upload limit to 150MB:
upload_max_filesize = 150M
post_max_size = 160M; Must be slightly larger than upload_max_filesize
memory limit = 256M; Optional: Increase if needed
"-1" means the app can use as much RAM as it needs. (Recommended if only one app is running on the server.)
Step 3: Restart the Web Server
To apply the changes, restart your web server:
Apache:
sudo systemctl restart apache2
PHP-FPM / NGINX:
sudo systemctl restart php<version>-fpm && sudo systemctl restart nginx
Replace <version> with the appropriate PHP version.
Step 4: Verify the Changes
Check if the new limits are applied using:
php -i | grep -E 'upload_max_filesize|post_max_size'
Step 5: Update Moodle Settings
After updating PHP, log in to Moodle and confirm that the changes are reflected the new limit (150MB)
In the settings:
-
Go to Site Administration > Server > Performance.
-
Ensure the new upload limit (150MB) is displayed.
By following these steps, you can successfully increase the upload file size limit in Moodle through php.ini. This allows users to upload larger files, improving functionality and user experience.