413请求实体太大 - 文件上载问题

时间:2022-10-06 09:10:49

I am trying to upload 30MB file on my server and its not working.

我试图在我的服务器上上传30MB文件,它无法正常工作。

  1. When I upload 30MB file, the page loads "Page Not Found"

    当我上传30MB文件时,页面加载“找不到页面”

  2. When I upload a 3MB file, I receive "413 Request Entity Too Large" with nginx/0.6.32

    当我上传3MB文件时,我收到“413请求实体太大”的nginx / 0.6.32

I am trying to find nginx so I can increase "client_max_body_size" but I am unable to find nginx installed on my server. I even tried running:

我试图找到nginx所以我可以增加“client_max_body_size”,但我无法找到我的服务器上安装的nginx。我甚至试过跑:

vi /etc/nginx/nginx.conf

or

要么

vi /usr/local/nginx/conf/nginx.conf

to check if the config file exists, but I couldnt find it on my server.

检查配置文件是否存在,但我无法在我的服务器上找到它。

Is there anyway to resolve this issue? Or do I have to installed nginx on my server.

反正有没有解决这个问题?或者我必须在我的服务器上安装nginx。

EDIT:

编辑:

I have made all necessary changes in my php.ini files,

我在php.ini文件中做了所有必要的更改,

post_max_size 128M
upload_max_filesize 100M
memory_limit 256M

Thanks, Raju

谢谢,Raju

7 个解决方案

#1


43  

Source: http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/

资料来源:http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/

Edit the conf file of nginx:

编辑nginx的conf文件:

nano /etc/nginx/nginx.conf

Add a line in the http section:

在http部分添加一行:

http {
    client_max_body_size 100M;
}

Doen't use MB it will not work, only the M!

不要使用MB它不会工作,只有M!

Also do not forget to restart nginx

另外别忘了重启nginx

systemctl restart nginx

#2


30  

-in php.ini (inside /etc/php.ini)

-in php.ini(在/etc/php.ini中)

 max_input_time = 24000
 max_execution_time = 24000
 upload_max_filesize = 12000M
 post_max_size = 24000M
 memory_limit = 12000M

-in nginx.conf(inside /opt/nginx/conf)

-in nginx.conf(在/ opt / nginx / conf中)

client_max_body_size 24000M

Its working for my case

它为我的案子工作

#3


5  

First edit the Nginx configuration file (nginx.conf)

首先编辑Nginx配置文件(nginx.conf)

Location: sudo nano /etc/nginx/nginx.conf

地点:sudo nano /etc/nginx/nginx.conf

Add following codes:

添加以下代码:

http {
        client_max_body_size 100M;
}

Then Add the following lines in PHP configuration file(php.ini)

然后在PHP配置文件(php.ini)中添加以下行

Location: sudo gedit /etc/php5/fpm/php.ini

地点:sudo gedit /etc/php5/fpm/php.ini

Add following codes:

添加以下代码:

memory_limit = 128M 
post_max_size = 20M  
upload_max_filesize = 10M

#4


4  

Please enter domain nginx file :

请输入domain nginx文件:

nano /etc/nginx/sites-available/domain.set

Add to file this code

添加到文件中此代码

client_max_body_size 24000M;

If you get error use this command

如果出现错误,请使用此命令

nginx -t

#5


3  

Assuming that you made the necessary changes in your php.ini files:

假设您在php.ini文件中进行了必要的更改:

You can resolve the issue by adding the following line in your nginx.conf file found in the following path:

您可以通过在以下路径中找到的nginx.conf文件中添加以下行来解决此问题:

/etc/nginx/nginx.conf

then edit the file using vim text editor as follows:

然后使用vim文本编辑器编辑文件,如下所示:

vi /etc/nginx/nginx.conf

and add client_max_body_size with a large enough value, for example:

并添加具有足够大值的client_max_body_size,例如:

client_max_body_size 20MB;

After that make sure you save using :xi or :wq

之后,请确保使用:xi或:wq保存

And then restart your nginx.

然后重新启动你的nginx。

That's it.

而已。

Worked for me, hope this helps.

为我工作,希望这会有所帮助。

#6


2  

I got the upload working with above changes. But when I made the changes I started getting 404 response in file upload which lead me to do further debugging and figured out its a permission issue by checking nginx error.log

我上传了上述更改。但是当我进行更改时,我开始在文件上传中获得404响应,这导致我进一步调试并通过检查nginx error.log找出其权限问题。

Solution:

解:

Check the current user and group ownership on /var/lib/nginx.

检查/ var / lib / nginx上的当前用户和组所有权。

$ ls -ld /var/lib/nginx

drwx------. 3 nginx nginx 17 Oct 5 19:31 /var/lib/nginx

drwx ------。 3 nginx nginx 17 Oct 5 19:31 / var / lib / nginx

This tells that a possibly non-existent user and group named nginx owns this folder. This is preventing file uploading.

这告诉可能不存在的用户和名为nginx的组拥有此文件夹。这阻止了文件上传。

In my case, the username mentioned in "/etc/nginx/nginx.conf" was

在我的例子中,“/etc/nginx/nginx.conf”中提到的用户名是

user vagrant; 

Change the folder ownership to the user defined in nginx.conf in this case vagrant.

将文件夹所有权更改为nginx.conf中定义的用户,在这种情况下为vagrant。

$ sudo chown -Rf vagrant:vagrant /var/lib/nginx

Verify that it actually changed.

验证它确实已更改。

$ ls -ld /var/lib/nginx
drwx------. 3 vagrant vagrant 17 Oct  5 19:31 /var/lib/nginx

Reload nginx and php-fpm for safer sade.

重新加载nginx和php-fpm以获得更安全的sade。

$ sudo service nginx reload
$ sudo service php-fpm reload

The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).

许可被拒绝错误现在应该消失。检查error.log(基于nginx.conf error_log位置)。

$ sudo nano /path/to/nginx/error.log

#7


0  

Open file/etc/nginx/nginx.conf Add or change client_max_body_size 0;

打开文件/ etc / nginx / nginx.conf添加或更改client_max_body_size 0;

#1


43  

Source: http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/

资料来源:http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/

Edit the conf file of nginx:

编辑nginx的conf文件:

nano /etc/nginx/nginx.conf

Add a line in the http section:

在http部分添加一行:

http {
    client_max_body_size 100M;
}

Doen't use MB it will not work, only the M!

不要使用MB它不会工作,只有M!

Also do not forget to restart nginx

另外别忘了重启nginx

systemctl restart nginx

#2


30  

-in php.ini (inside /etc/php.ini)

-in php.ini(在/etc/php.ini中)

 max_input_time = 24000
 max_execution_time = 24000
 upload_max_filesize = 12000M
 post_max_size = 24000M
 memory_limit = 12000M

-in nginx.conf(inside /opt/nginx/conf)

-in nginx.conf(在/ opt / nginx / conf中)

client_max_body_size 24000M

Its working for my case

它为我的案子工作

#3


5  

First edit the Nginx configuration file (nginx.conf)

首先编辑Nginx配置文件(nginx.conf)

Location: sudo nano /etc/nginx/nginx.conf

地点:sudo nano /etc/nginx/nginx.conf

Add following codes:

添加以下代码:

http {
        client_max_body_size 100M;
}

Then Add the following lines in PHP configuration file(php.ini)

然后在PHP配置文件(php.ini)中添加以下行

Location: sudo gedit /etc/php5/fpm/php.ini

地点:sudo gedit /etc/php5/fpm/php.ini

Add following codes:

添加以下代码:

memory_limit = 128M 
post_max_size = 20M  
upload_max_filesize = 10M

#4


4  

Please enter domain nginx file :

请输入domain nginx文件:

nano /etc/nginx/sites-available/domain.set

Add to file this code

添加到文件中此代码

client_max_body_size 24000M;

If you get error use this command

如果出现错误,请使用此命令

nginx -t

#5


3  

Assuming that you made the necessary changes in your php.ini files:

假设您在php.ini文件中进行了必要的更改:

You can resolve the issue by adding the following line in your nginx.conf file found in the following path:

您可以通过在以下路径中找到的nginx.conf文件中添加以下行来解决此问题:

/etc/nginx/nginx.conf

then edit the file using vim text editor as follows:

然后使用vim文本编辑器编辑文件,如下所示:

vi /etc/nginx/nginx.conf

and add client_max_body_size with a large enough value, for example:

并添加具有足够大值的client_max_body_size,例如:

client_max_body_size 20MB;

After that make sure you save using :xi or :wq

之后,请确保使用:xi或:wq保存

And then restart your nginx.

然后重新启动你的nginx。

That's it.

而已。

Worked for me, hope this helps.

为我工作,希望这会有所帮助。

#6


2  

I got the upload working with above changes. But when I made the changes I started getting 404 response in file upload which lead me to do further debugging and figured out its a permission issue by checking nginx error.log

我上传了上述更改。但是当我进行更改时,我开始在文件上传中获得404响应,这导致我进一步调试并通过检查nginx error.log找出其权限问题。

Solution:

解:

Check the current user and group ownership on /var/lib/nginx.

检查/ var / lib / nginx上的当前用户和组所有权。

$ ls -ld /var/lib/nginx

drwx------. 3 nginx nginx 17 Oct 5 19:31 /var/lib/nginx

drwx ------。 3 nginx nginx 17 Oct 5 19:31 / var / lib / nginx

This tells that a possibly non-existent user and group named nginx owns this folder. This is preventing file uploading.

这告诉可能不存在的用户和名为nginx的组拥有此文件夹。这阻止了文件上传。

In my case, the username mentioned in "/etc/nginx/nginx.conf" was

在我的例子中,“/etc/nginx/nginx.conf”中提到的用户名是

user vagrant; 

Change the folder ownership to the user defined in nginx.conf in this case vagrant.

将文件夹所有权更改为nginx.conf中定义的用户,在这种情况下为vagrant。

$ sudo chown -Rf vagrant:vagrant /var/lib/nginx

Verify that it actually changed.

验证它确实已更改。

$ ls -ld /var/lib/nginx
drwx------. 3 vagrant vagrant 17 Oct  5 19:31 /var/lib/nginx

Reload nginx and php-fpm for safer sade.

重新加载nginx和php-fpm以获得更安全的sade。

$ sudo service nginx reload
$ sudo service php-fpm reload

The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).

许可被拒绝错误现在应该消失。检查error.log(基于nginx.conf error_log位置)。

$ sudo nano /path/to/nginx/error.log

#7


0  

Open file/etc/nginx/nginx.conf Add or change client_max_body_size 0;

打开文件/ etc / nginx / nginx.conf添加或更改client_max_body_size 0;