An error occurred while uploading the large image through nginx php-fpm.

Source: Internet
Author: User
Tags file upload fpm ini memory usage php file php file upload

1. Install the gd Library

Yum-y install gd
Restart fpm

2. By default, the maximum image upload limit for nginx is relatively small.

Modify post_max_size upload_max_filesize max_execution_time max_input_time in PHP. ini
Open the php. Ini file and restart the server after modification. Upload a file .... (Hey, did you upload a large file ?)
1. Temporary directory for storing files during File upload. It must be a directory that can be written by the PHP process owner. If this parameter is not specified, PHP uses the default value of upload_tmp_dir in the php. Ini file to describe the temporary directory of the file uploaded by PHP.
To upload a file, make sure that the server does not have the permission to close the temporary file and write the folder.
2. max_execution_time
The max_execution_time variable sets the time for PHP to wait for the script to be executed before the script is forcibly terminated. The time is calculated in seconds. This variable is useful when the script enters an infinite loop state. However, when there is a legal activity that takes a long time to complete (such as uploading large files), this function will also cause operation failure. In this case, you must consider adding the value of this variable to avoid PHP closing the script when the script is executing an important process.
Changed to max_execution_time = 800.
3. file_uploads = On (you don't need to set it when you open it)
4. Change upload_max_filesize = 2 MB to 800 MB.
5. A variable related to form submission is post_max_size, which controls the maximum data size that PHP can receive in a form submission using the POST method. It seems unlikely that the default 8 MB size needs to be increased. Instead, it should be appropriately reduced to a more practical value. If you want to use the php file upload function, you need to change this value to a value greater than upload_max_filesize.
Also changed to: post_max_size = 900 M
6. max_input_time
This variable can be used to limit the time when data is received through POST, GET, and PUT in seconds. If the running environment of the application is on the low-speed link, you need to add this value to adapt to the more time required to receive data.
Changed to max_input_time = 900.
7. memory_limit = 10 M
To avoid using a large amount of available memory by running scripts, PHP allows you to define the memory usage limit. Use the memory_limit variable to specify the maximum memory capacity that a single script program can use.
Value of the variable memory_limit (do not exceed the maximum size of the server)
Modified to: memory_limit = 128 M

3. nginx has a 413 Request Entity Too Large error. This error usually occurs when uploading files. Open the nginx main configuration file nginx conf and find the http {} segment, the solution is to open the nginx main configuration file nginx conf, usually in usr local ngin

Open the nginx main configuration file nginx. conf. Generally, find the http {} segment at/usr/local/nginx/conf/nginx. conf, modify or add

Client_max_body_size 2 m;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.