Max filesize ubuntu 20.4, apache2, wordpress

Hi all. I followed the digitalocean tutorials for installing the core ubuntu 20.4 server, then installed lamp stack with apache2 and mysql to serve up Wordpress. I would like to change the max file upload size in php so I can upload bigger files. I’ve tried to do this where info.php points me to which is the php.ini file in /etc/php/7.4/apache2. Now the file says this:

Maximum allowed size for uploaded files:

upload_max_filesize = 32M

I also created an info.php file to see where the core configuration files are coming from and its here. yet when I try to upload a file bigger than 2m in WordPress, I get an error that the max file size is 2mb and I cannot upload the file. These are smaller images I wish to test on a development WordPress install. The image is 4mb in size. the info.php file says this:

upload_max_filesize	2M	2M

Now I am not sure where this value is coming from since I edited the php.ini file that the info.php declares. I’ve tried a few other methods and even a plugin for Wordpress but this limitation has me stymied. I’ve done this countless times in the past on ubuntu and it just worked with a restart of apache2. I also rebooted the server just to make sure it’s okay.

Any pointers on where to look to adjust this 2m to 32mb for my testing and development work?

Show comments

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello all,

You can create a PHP info file in order to check the current values and check which is the php.ini file in use. Create the following file in your public_hmtl folder - phpinfo.php and put the following code inside it:


You can also use the following command in order to find the location of the php.ini file:

php -i | grep php.ini

The output will be:

Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini

Then check for the current value of upload_max_filesize you can also check which is the configuration file - php.ini that is currently used and 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). Ideally, you would like to have the following values:

upload_max_filesize = 64M

You also need to restart your web server in order for the changes to take effect.

Hope that this helps! Regards, Alex

This question was answered by @mpmilestogo:

Hi all. After some research I found an answer. Perhaps its the answer. It seems that my ubuntu 20.04 droplet will not allow changes to maximum file size by editing the php.ini files at all. No matter what I did the max file size limit remained until I created a user.ini file in /etc/php/7.4/apache2/conf.d and inserted these values:

post_max_size = 90M upload_max_filesize = 50M

I just used these values from a snippet I found somewhere. Then I restarted apache2 and checked my info.php file and it added the user.ini file as a configuration file and the max file size had changed and I could upload a larger image file to Wordpress.

I don’t believe I have run into this before. Perhaps it will help someone else :-)

View the original comment