moodle.ini configuration file.
Default PHP configuration
The PHP settings are defined in the Dockerfile and written to/usr/local/etc/php/conf.d/moodle.ini:
Dockerfile:30-36
Configuration parameters
max_input_vars
Maximum number of input variables allowed in a single requestMoodle forms with many fields (like course settings or quiz configuration) require higher values than PHP’s default (1000).Recommended: 5000 or higher for large Moodle installations
memory_limit
Maximum amount of memory a script can allocateMoodle’s course backup, restore, and grade operations can be memory-intensive. The 512M limit handles most scenarios.Increase to 1024M or higher if:
- Backing up very large courses (1000+ students)
- Processing large CSV imports
- Running complex reports
upload_max_filesize
Maximum size of an uploaded fileAllows students and teachers to upload large files like videos, presentations, or course backups.Note: Must be coordinated with Nginx’s
client_max_body_size (also set to 512M)post_max_size
Maximum size of POST dataMust be equal to or greater than
upload_max_filesize since file uploads are sent via POST requests.Set this slightly larger than
upload_max_filesize to account for other form datamax_execution_time
Maximum time in seconds a script can run before being terminated600 seconds (10 minutes) allows for long-running operations like:
- Course backups and restores
- Large file processing
- Quiz report generation
- Batch user enrollments
fastcgi_read_timeout is set to 300 secondsModifying PHP settings
Option 1: Rebuild the Docker image
For permanent changes, modify the Dockerfile:Option 2: Runtime configuration with volume mount
For temporary testing without rebuilding:PHP extensions
The Dockerfile installs all PHP extensions required by Moodle:Dockerfile:26-27
Installed extensions
| Extension | Purpose |
|---|---|
intl | Internationalization support for multiple languages |
soap | Web services integration |
zip | Course backup/restore compression |
pgsql | PostgreSQL database driver |
pdo_pgsql | PDO driver for PostgreSQL |
exif | Image metadata reading |
opcache | PHP bytecode caching for performance |
bcmath | Arbitrary precision math for grading |
sockets | Network communication |
mbstring | Multi-byte string handling (UTF-8) |
sodium | Modern cryptography library |
gd | Image manipulation (configured lines 22-23) |
Opcache configuration
Opcache is enabled by default in PHP 8.2-FPM. For production optimization, add opcache settings:Checking current configuration
View all PHP settings
Check specific settings
View loaded configuration files
Performance tuning
PHP-FPM worker processes
The default PHP-FPM configuration uses dynamic process management. For high-traffic sites, create a customwww.conf:
Adjust
pm.max_children based on available memory. Rule of thumb: (Total RAM - RAM for other services) / average memory per PHP processMonitor PHP-FPM status
Enable the status page inwww.conf:
Troubleshooting
'Maximum execution time exceeded' errors
'Maximum execution time exceeded' errors
- Increase
max_execution_timein Dockerfile - Increase Nginx
fastcgi_read_timeoutinnginx/Default.conf - Rebuild and restart both app and web containers
File upload fails with 'file too large'
File upload fails with 'file too large'
Check that all three values are aligned:
- PHP
upload_max_filesize(Dockerfile:33) - PHP
post_max_size(Dockerfile:34) - Nginx
client_max_body_size(nginx/Default.conf:8)
Out of memory errors during course backup
Out of memory errors during course backup
- Increase
memory_limitto 1024M or higher - Check available container memory:
docker stats moodle_app - Consider increasing Docker resource limits if needed
Next steps
Nginx configuration
Align web server timeouts and upload limits
Custom PHP extensions
Add additional PHP extensions
Performance monitoring
Monitor PHP-FPM performance
Database configuration
Optimize PostgreSQL settings