Nginx + php file size configuration

Source: Internet
Author: User

For business purposes, you need to upload music. Nginx has a limit on uploading, which should be no more than 2 mb. Therefore, you need to reconfigure it.

First, Configure nginx. Find the nginx. conf configuration file and modify the php module in http. The complete code is as follows:

# Pass the PHP scripts to FastCGI server listening on Fig: 9000
        #
Location ~ . Php $ {
Root/var/www/html/webroot;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/home/www/htdocs $ fastcgi_script_name;
Include fastcgi_params;
 
Client_max_body_size 35 m; # set the size of the uploaded file on the client to 35 M.
Client_body_temp_path/var/www/html/nginx_temp; # set a temporary directory
 }


Tip:

Client_max_body_size 35 m; # set the size of the uploaded file on the client to 35 M.

Client_body_temp_path/var/www/nginx_temp; # set a temporary directory


Second, because nginx and php need to be connected using fpm, and php itself has restrictions on uploading in php. ini, you need to modify the php. ini code as follows:

Upload_max_filesize = 8 M
Post_max_size = 10 M
Memory_limit = 20 M
Max_execution_time= 300
File_uploads = On


After the above two steps are completed, we need to restart php-fpm. If it is not restarted, php. ini will not be reloaded.

Find php-fpm and execute the following command in the command line:

/Etc/rc. d/init. d/php-fpm restart

Restart nginx again.

Kill the nginx process and run nginx to start it.

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.