Max filesize ubuntu 20.4, apache2, wordpress

Posted May 13, 2021 1.8k views
Ubuntu 20.04

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?

edited by bobbyiliev
1 comment
  • Show comment This comment has been marked as resolved by mpmilestogo.

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.

Submit an Answer
2 answers

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:

postmaxsize = 90M
uploadmaxfilesize = 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

  • @mpmilestogo Thank you for sharing the solution with the community.

    I seem to have the exact same issue as you did.

    Would you be able to explain how to create a user.ini file within the /etc/php/7.4/apache2/conf.d directory? And how to insert your desired values?


    • Hi. I no longer have the droplet since it was for a business test case I abandoned. What I did from memory was navigate to the directory and use a basic text editor like nano there to create the file and then insert the values from my original post. Some of the files have different types of names there but I just created the basic user.ini file and then restarted apache and used a file to check the values and also my Wordpress install. You may have to change permissions to match the other ini files. I don’t recall that part. Once I did those things, I could upload files in any size up to the limit in the user.ini file. I hope this helps.

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!