Running LAMP with a WordPress installation. I’ve updated my php.ini file under /etc/php/8.0/cli/php.ini and /etc/php/8.0/cli/php.ini and /etc/php/7.4/cli/php.ini, as well as added information to my WP php.ini and .htaccess and I’m still seeing the value as 2MB instead of the 20MB that I require.
I’ve run php -i | grep php.ini and get
Configuration File (php.ini) Path => /etc/php/8.0/cli
Loaded Configuration File => /etc/php/8.0/cli/php.ini
I just can’t figure out why it’s not updating the upload_max_filesize = 20M
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello, @eastonparkwiki
In order to make sure that you’re updating the correct php.ini file you can create a phpinfo file and check the loaded configuration file.
You can create a file named info.php (the name doesn’t really matter) and put the following content in the file:
- <?php
- phpinfo();
Then check for the current value of upload_max_filesize and also check which is the configuration file - php.ini that is currently used.
Then you can apply the changes there (if the site using the global php.ini file and you change the values for these settings this will make the changes globally for all sites).
upload_max_filesize = 64M
Hope this helps! Regards, Alex
It sounds like you might be modifying the wrong php.ini file. The configuration you updated (/etc/php/8.0/cli/php.ini) is for the CLI (Command Line Interface) version of PHP, which is used when running PHP from the command line, not for web requests.
For your WordPress site running on a LAMP stack, PHP is being used by the web server (typically through PHP-FPM or Apache’s mod_php). This requires you to update the php.ini file used by the web server version of PHP, not the CLI version.
Here’s how you can resolve this:
Locate the Correct php.ini for the Web Server:
phpinfo(); to determine the correct php.ini file that is being loaded by the web server.info.php) with the following content:<?php phpinfo(); ?>
http://yourdomain.com/info.php).php.ini is being used by the web server.Update the Correct php.ini File:
php.ini, open it and update the following settings:upload_max_filesize = 20M
post_max_size = 20M
The post_max_size value must be at least as large as upload_max_filesize because it limits the size of the entire HTTP request, which includes file data and form fields.
Restart the Web Server:
sudo systemctl restart apache2
- If you’re using PHP-FPM, you may also need to restart PHP-FPM:
sudo systemctl restart php8.0-fpm
- Adjust the version number (`php8.0-fpm`) to match your installation.
Check .htaccess or wp-config.php:
.htaccess or wp-config.php file does not contain conflicting settings. If you have entries like:@ini_set('upload_max_filesize', '2M');
Update them to the desired value (`20M`) or remove them if they conflict with the `php.ini` settings.
Remove info.php File:
info.php file to avoid exposing sensitive information about your server.After following these steps, try uploading your file again to confirm if the new limit has been applied. If you still face issues, double-check other configuration overrides that might be in effect (e.g., .user.ini, .htaccess).
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.