Report this

What is the reason for this report?

php.ini settings not updating

Posted on July 17, 2021

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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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:

  1. <?php
  2. 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:

  1. Locate the Correct php.ini for the Web Server:

    • Run phpinfo(); to determine the correct php.ini file that is being loaded by the web server.
    • Create a simple PHP file in the root of your WordPress directory (e.g., info.php) with the following content:
<?php phpinfo(); ?>
    • Access this file from your browser (http://yourdomain.com/info.php).
    • Search for “Loaded Configuration File” in the output to see which php.ini is being used by the web server.
  • Update the Correct php.ini File:

    • Once you locate the correct 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.

  1. Restart the Web Server:

    • After making changes, restart the web server to apply the new configuration.
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.
  1. Check .htaccess or wp-config.php:

    • Make sure your .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.
  1. Remove info.php File:

    • After verifying, remove the 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).

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.