FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
PHP
Increase file upload size limit in PHP-Nginx
Topics
On this page
-
- Getting Started
- Git and File-System Layout (non-default setup)
- Version Constraints
- Managing Themes and Plugins (for entire WordPress site)
- Updating Themes and Plugins (for entire WordPress site)
- Adding Composer Support to Your Own Themes and Plugins (for developers)
- Using Composer to Manage Own Theme/Plugin Dependencies (for developers)
-
- Assigning Multiple IP Addresses to Single LAN Card
- Disable IPv6 on Ubuntu 12.04
- dsh – distributed shell
- fdupes – find & replace duplicate files with hardlinks
- GPG Keys Cheatsheet
- Increase "Open Files Limit"
- kill all php, nginx, mysql or any kind of processes
- Passwordless Authentication for SSH
- Screen
- search replace in multiple files useing grep xargs sed
- Setup sftp
- sysctl.conf
- Timezone Sync
- Using Google Public DNS on Ubuntu Server
- Using openssl to match private key, cerificate and CSR
- Configure Postfix to Use Gmail SMTP on Ubuntu
- Logrotate Example for Custom Logs
- PHP 5.5, MySQL, Postfix, Nginx and WordPress on Ubuntu
- Serverdensity
- Upgrade Ubuntu 10.04 to 12.04
- Using find and sed to replace strings in multiple files
- Webmin
-
- .my.cnf – mysql user & password
- Analyse slow-query-log using Anemometer
- Improving MySQL Query Cache
- MySQL Query Profiling
- Reset MySQL root password
- tuning-primer.sh – an alternative for mysqltuner
- Using MariaDB 10
- Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS
- Change WordPress Domain Name
- Character Sets and Collations
- Enable innodb_file_per_table
- Enable Remote Access (Grant)
- Installing Percona Toolkit
- Using tmpfs for temporary folder creation
- YARPP and InnoDB
- Convert MyISAM to InnoDB
- Using tmpfs for mysqldump & mysqlimport
- Convert from INNODB to MYISAM
- Analyse slow-query-log using mysqldumpslow & pt-query-digest
- mysqlcheck with cron to optimize automatically
- Using MySQLTuner to Optimize MySQL configuration
-
-
- Directly connect to PHP-FPM
- Generating core-dump for php5-fpm
- GeoIP
- Having php5 and php7 on same system.
- Install Xdebug and configure it with webgrind
- Installation of PHP Code Review Tools
- memcache
- PHP's Zend Opcache Config & Web Viewer
- Setting Sqlite support with PHP
- Using HHVM with PHP-FPM Fallback
- Using Redis for PHP Sessions on Ubuntu Server
- Installing PhpMyAdmin Quickly
- Moving PHP's session storage to tmpfs
- Install Xdebug and configure it with Netbeans
- Nginx – Enable PHP-FPM Status Page
- PHP-FPM: Socket vs TCP/IP and sysctl tweaking
- APC Cache Optimization & Monitoring Using Web Interface
- Checking if PHP/WordPress can send mails
- Debugging PHP Scripts Using slow_log and more
- Increase file upload size limit in PHP-Nginx
- Increase PHP script execution time with Nginx
-
- Performance Optimization
- Remove Query string of css/js files
- Setup ElasticSearch with ElasticPress
- Using Redis for WordPress Object-Cache
- WooCommerce Window Shopping Caching Technique
- Moving WordPress To New Server (Faster)
- Better wp-cron using linux's crontab
- 404 error- Page not Found!!!
- Debugging WordPress with Nginx
Changes in php.ini
Change in Nginx config
Changes in WordPress-Multisite
More…
Increase file upload size limit in PHP-Nginx
If Nginx aborts your connection when uploading large files, you will see something like below in Nginx’s error logs:
[error] 25556#0: *52 client intended to send too large body:
This means, you need to increase PHP file-upload size limit. Following steps given below will help you troubleshoot this!
Changes in php.ini
To change max file upload size to 100MB
Edit…
vim /etc/php5/fpm/php.ini
Set…
upload_max_filesize = 100M
post_max_size = 100M
Notes:
- Technically, post_max_size should always be larger than upload_max_filesize but for large numbers like 100M you can safely make them equal.
- There is another variable max_input_time which can limit upload size but I have never seen it creating any issue. If your application supports uploads of file-size in GBs, you may need to adjust it accordingly. I am using PHP-FPM behind Nginx from very long time and I think in such kind of setup, its Nginx to which a client uploads file and then Nginx copies it to PHP. As Nginx to PHP copying will be local operation max_input_time may never create issue. I also believe Nginx may not copy the file but merely hand-over the location of file or descriptor records to PHP!
You may like to read these posts which explains PHP file upload related config in some details.
Change in Nginx config
Add following line to http{..} block in nginx config:
http {
#...
client_max_body_size 100m;
#...
}
Note: For very large files, you may need to change value of client_body_timeout parameter. Default is 60s.
Reload PHP-FPM & Nginx
service php5-fpm reload
service nginx reload
Changes in WordPress-Multisite
If you are running WordPress Multisite setup, then you may need to make one more change at the WordPress end.
Go to: Network Admin Dashboard >> Settings. Look for Upload Settings
Also change value for Max upload file size

More…
- You may need to change PHP max execution time limit also.
- More optimization tips for WordPress-Nginx setup
Debugging PHP Scripts Using slow_log and more
PREVIOUS
Increase PHP script execution time with Nginx
NEXT
Comments
-
That final line was the one I needed, no other articles mention it. This should be the top result in Google. Cheers!
-
Thanks for appreciation. 🙂
-
-
Mike
Hey I’m having this same issue and I can’t figure it out to save my self I want to be able to upload files up to 300mb but my server doesn’t let me. Please help.
-
Apart from steps mentioned in above article, you may need to change
memory_limitinphp.inifile.Better would be to check error logs. You will see exact reason why 300MB files are not uploading properly. It might be the case that they are getting uploaded but are failing to process.
-
-
Thanks for the tips on how to increase file limit on nginx server. At first I edited php.ini file but it didn’t work properly. After checking your tips I just edited nginx.conf file and now it’s working perfectly.
Thanks!
-
There are few more things where PHP & Nginx both need changes. Coming from Apache background, most of the time its hard to anticipate! I had spent hours myself when I was new to nginx to find out this.
Glad to know it helped. 🙂
-
-
the multisite config had slipped my attention – many thanks… very helpful!
-
We use multisite setup for on many client server. That’s how we managed to find out that setting.
Glad to know it helped. 🙂
-
-
I just HAD to leave a comment to say how much this helped me. I’ve been scouring the web for a solution to my 413 error and just knew it had something to do with nginx. Much appreciated.
-
Glad to know it helped. 🙂
-
-
Works beautifully. Thanks for the concise and easy-to-understand instructions for a nginx novice like me.
-
Glad to know it helped. 🙂
-
-
Gold. This site has been invaluable for getting ramped up on Nginx and solving little quirks along the way. Thanks!
-
Thanks for appreciation. I hope you will find other tutorials in this series useful as well.
-
-
Salved my magento, thank you very much
-
I tried it. But its didn’t works.
I tried it in http {} and server {}
my php setting is huge.
Maximum HTTP POST size === 200M Maximum file upload size == 100M Maximum execution time == 30000 Maximum input parsing time = 60000Nginx config
client_max_body_size 100m;uploading file size is 3 MB
-
Did you restart PHP-FPM and Nginx?
If yes, please check for error log. There could be some other issue.
-
-
Nikolay
very GOOD !!!
-
This is a good tutorial – thanks.
-
Thanks
I just comment to say thank you Rahul..it save me lot of hours finding solution in the web.your solution is easy to follow and concise nothing i find in google like yours,everyone is just copy cat with other website lol!.again thank so much for your time and effort.peace!
Features
- Server Setup & Management
- Site Creation & Management
- Create WP Cloud Sites
- Speed & Caching
- Firewall Protection
- Backups & Recovery
- Logs & Monitoring
- Deployments & Developer Tools
- Team Access & User Permissions
Useful Links
Product
Other Products
Subscribe for curated product updates, tips, and announcements.
"*" indicates required fields
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.