What does this post cover?
In this post I cover how to update the php maximum file upload size. Although this post is php-fpm specific the same variables will need to be edited in what ever version of PHP you are using. I also cover updating nginx.conf which is nginx specific.
Why this topic?
I manage the server for a client that is hosting WordPress on a Linode VPS. Recently they’ve decided to start doing a pod cast. When my client went to upload the audio for the podcast they encountered the following error in WordPress.
Maximum upload file size: 8mb
8mb is the default post_max_size set in the php.ini that is part of the php5-fpm package for Ubuntu 14.04 other distributions may see a similar error but with a different value
After checking and updating all of the relevant values it was suggested, and I agreed to write a brief blog post about what needs to be updated.
So if you’re encountering an error like “Maximum upload file size: 8M” here’s the solution.
you will need to edit the following two variables in your php.ini
The default location for the php.ini on Ubuntu 14.04 with the php5-fpm package is /etc/php5/fpm/php.ini
post_max_size = 100M
upload_max_filesize = 100M
In the above example i’ve set the size to 100M for 100 mega bytes. For 100 kilobytes you would use 100K and if you wanted to set the values to 1 giga byte you could use 1G. So the value is a number followed by K, M or G without a space. You should only set the size to a maximum file size that you are likely to upload. Although it’s tempting to set the values to an enormous size this could result in the exustion of all system resources and crashing your server, so be reasonable. The value for “upload_max_filesize” is only valid up to the the limit imposed by “post_max_size”. In practice you will most likely set them both to the same value.
You will also need to edit your nginx.conf located by default at /etc/nginx/nginx.conf on Ubuntu 14.04 when Nginx is installed via apt-get.
edit the the “client_max_body_size” in the http block of your nginx.conf
You will need to restart php5-fmp before the changes take effect. Here’s how to do that on Ubuntu.
sudo service php5-fmp restart
You will need to reload the ngixn.conf before the changes that you’ve made take effect. Here’s how you reload the nginx.conf
sudo service nginx reload
That’s it. You should now be able to upload your files without encountering the error “Maximum upload file size: 8mb”
After reading through all of this you’ve decided that you would rather leave the management of you server in the hands of professionals have a look at
If you were encountering this error I hope that this post has been helpful. If you have any comments, questions, or suggestions please let me know in the comments section below. If you would like to have me answer your individual questions please join my mailing list by submitting the form on the right hand navigation of this page.