Running NGINX web server along with php5-fpm scripting language is an excellent choice for hosting any type of websites in a VPS. Being NGINX as web server, it can handle huge number of traffic compared to any other web server. In a typical first installation of LEMP stack i.e. Linux, Nginx, MySQL and PHP, the file upload limit is 2MB by default.
To increase file upload limit in Nginx and php5-fpm environment you need to change few php5 settings as well as nginx settings. Here is what you need to change to increase the file upload limit.
Increase file upload limit by editing php.ini
To change upload limit in php.ini you need to open the file. The typical location of the file is:
/etc/php5/fpm/php.ini
or
/etc/php5/cgi/php.ini
Run the following command:-
sudo nano /etc/php5/cgi/php.ini
Find “max_filesize” by pressing Ctrl+W and change the default value to this:
upload_max_filesize = 50M
if you need to change the upload limit to 50MB.
Again find “post_max” by pressing Ctrl+W and change the default value.
post_max_size = 50M
Increase file upload limit by editing nginx.conf
There is one more thing you need to change from nginx.conf
Run:
sudo nano /etc/nginx/nginx.conf
Add the following inside http block:
client_max_body_size 50m;
Finally restart php5-fpm and nginx so that the changes take effect.
sudo service nginx restart sudo service php5-fpm restart
or reboot from your hosting provider’s end.