Enable Upload Large File on PHP + Nginx

     

  1. Open file php.ini (should be located at /etc/php5/fpm/php.ini if you are using PHP-FPM. Otherwise, just find it using: sudo updatedb && locate php.ini)
  2. Edit these 3 variables:
    1. upload_max_filesize => 2M to (whatever you want. I tend use 128M)
    2. post_max_size => 2M to (same as above. just note if you expect to upload multiple files, set this variable higher than above)
    3. max_input_time => 60 to (your client's expected maximum upload time. should be max file size divided by minimum client's upload speed)
  3. Open your nginx configuration, add this parameters:
    1. client_max_body_size xxM; (same as post_max_size)
    2. fastcgi_read_timeout xxM; (same as max_input_time)
  4. Restart PHP-FPM and nginx: sudo service php5-fpm restart && sudo service nginx restart
  5. That's all folks!