You've edited /etc/php5/fpm/php.ini
with correct values:
upload_max_filesize = 20M
post_max_size = 25M
Yet phpinfo()
stubbornly shows 8M upload and 2M POST limits. Let's troubleshoot this systematically.
PHP-FPM on Ubuntu uses multiple configuration files:
/etc/php5/fpm/php.ini (main config)
/etc/php5/fpm/conf.d/*.ini (additional settings)
/etc/php5/fpm/pool.d/*.conf (pool-specific overrides)
First, confirm which ini file PHP-FPM is actually using:
php5-fpm -i | grep "Loaded Configuration File"
php5-fpm -i | grep "Additional .ini files parsed"
Check for conflicting settings in pool configuration:
grep -r "upload_max_filesize\|post_max_size" /etc/php5/fpm/
Even with correct PHP settings, Nginx needs matching client limits:
# In your nginx server block
client_max_body_size 25M;
client_body_buffer_size 128k;
Proper restart sequence matters:
sudo service php5-fpm restart
sudo service nginx reload
For temporary testing or specific applications:
# In .htaccess (if using Apache compatibility)
php_value upload_max_filesize 20M
php_value post_max_size 25M
# Runtime override in PHP
ini_set('upload_max_filesize', '20M');
ini_set('post_max_size', '25M');
Verify settings without web server interference:
php -r "phpinfo();" | grep -E "upload_max_filesize|post_max_size"
- Verify active php.ini path in phpinfo() output
- Check for duplicate settings in conf.d directory
- Ensure proper file permissions (644 for config files)
- Inspect PHP-FPM error logs:
/var/log/php5-fpm.log
- Test with a fresh browser session (no PHP opcache issues)
After modifying /etc/php5/fpm/php.ini
with:
upload_max_filesize = 20M
post_max_size = 25M
You'd expect the changes to reflect immediately after restarting services. However, many developers find phpinfo()
still showing default values (typically 8M for post and 2M for upload). Let's troubleshoot this systematically.
PHP-FPM uses multiple configuration files that can override each other. Check all possible locations:
# Main configuration
/etc/php5/fpm/php.ini
# Pool-specific overrides
/etc/php5/fpm/pool.d/www.conf
# CLI configuration (won't affect FPM but good to know)
/etc/php5/cli/php.ini
Create a test script to locate the actual loaded INI file:
<?php
phpinfo(INFO_CONFIGURATION | INFO_MODULES);
?>
Look for "Loaded Configuration File" in the output. This reveals which file is actually being used.
1. Multiple php.ini Files: Ubuntu maintains separate configurations for different SAPIs. Ensure you're editing the FPM-specific file.
2. Pool Directives Override: Some settings in www.conf
can override php.ini. Check for these lines:
php_admin_value[upload_max_filesize] = 20M
php_admin_value[post_max_size] = 25M
3. Permission Issues: After modifying files, ensure proper permissions:
sudo chown root:root /etc/php5/fpm/php.ini
sudo chmod 644 /etc/php5/fpm/php.ini
Don't just restart - do a full reload sequence:
sudo service php5-fpm stop
sudo service nginx stop
sudo service php5-fpm start
sudo service nginx start
Even with correct PHP settings, Nginx has its own limits:
client_max_body_size 25M;
Add this to your server block or nginx.conf
.
Verify settings without creating PHP files:
php -i | grep -E 'upload_max_filesize|post_max_size'
For FPM-specific values:
php-fpm5.6 -i | grep -E 'upload_max_filesize|post_max_size'
Here's how settings cascade in a typical setup:
# /etc/php5/fpm/php.ini (base)
upload_max_filesize = 20M
# /etc/php5/fpm/pool.d/www.conf (override)
; This would override php.ini
php_admin_value[upload_max_filesize] = 15M
The pool-specific value takes precedence.
For Docker or custom environments, you might need:
env[PHP_UPLOAD_MAX_FILESIZE] = 20M
env[PHP_POST_MAX_SIZE] = 25M
Add these to your pool configuration.
After making changes, verify with:
sudo php5-fpm -t # Test configuration
sudo service php5-fpm reload
sudo tail -f /var/log/php5-fpm.log