Home > Backend Development > PHP Tutorial > Modify Nginx+PHP upload file size limit

Modify Nginx+PHP upload file size limit

WBOY
Release: 2016-07-25 08:54:39
Original
1075 people have browsed it
Introducing the method of modifying the size limit of PHP upload files in nginx and PHP environments to solve the limitation that PHP upload files cannot be larger than 2M. Friends in need can refer to it.

To upload files with php, first modify the settings of php.ini, then change the server environment (using nginx+php), and find that slightly larger files cannot be uploaded.

The reason is: 413 error caused by nginx’s client_max_body_size configuration option value.

Problem description: The upload_max_filesize in the php.ini configuration file is set to 50M The value set by post_max_size is 100M But uploading files exceeding 10 megabytes will return an uploaderror 413 error.

Server environment: centos5.7 32-bit nginx1.0.8 php5.2.17

Solution: 1. If the upload file limit is 50MB, first modify php.ini upload_max_filesize 50M post_max_size 100M 2. Then modify the nginx configuration file: The value of this configuration option defaults to 1m and can be increased to 8m to increase the file size limit.

This is directly modified to 100. The specific situation can be set according to your own needs. (Reference: The client_max_body_size size should be consistent with or slightly larger than the maximum value in upload_max_filesize and post_max_size in php.ini, so that there will be no errors due to inconsistent submitted data sizes.)

client_max_body_size 100m;

Summary

When encountering the problem of PHP upload file size limit, in addition to considering the configuration of PHP itself, you should also consider factors of the current server environment, such as related configuration items in nginx or apache.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template