Increasing PHP File Upload Size on nginx

I am running nginx + php-fpm. I was posting new products to my newly set up Magento website, however when I was uploading the product image I got the “HTTP Upload Error.” I searched only, but did not find the answer to my problem. It turns out that the “HTTP Upload Error” meant that you uploaded a file passed the maximum allowed by php-fpm.

To boost up the file limit, you can simply set to the following on:

# /etc/php.ini
upload_max_filesize= 5M
post_max_size = 10M #Usually double the "upload_max_filesize
max_input_time = 100 #This one set the time spend for the php service to get your file before it closes its connection with you. It is better to set a higher number if you upload large size files. I set mine to 100 seconds, it should be enough time for me to upload a 5MB file. 

# one of your nginx *.conf that contains your domain config
# /etc/nginx/conf.d/virtual.conf
# add the code below within server {}
client_max_body_size 5m;

Now simply reboot php-fpm and nginx to take effect:

service nginx restart
service php-fpm restart

 

Leave a Reply