如何编辑 nginx.conf 增加文件大小上传 [英] How to edit nginx.conf to increase file size upload
问题描述
我想增加可以上传的最大文件大小
.
在网上做了一些研究后,我发现你必须编辑文件'nginx.conf'.
我目前可以访问此文件的唯一方法是通过 Putty 并输入以下命令:
I want to increase the maximum file size
that can be uploaded.
After doing some research online, I found that you have to edit the file 'nginx.conf'.
The only way I can currently access this file is by going through Putty and typing in the command:
vi /etc/nginx/nginx.conf
这将打开文件,但我现在有两个问题:
This will open the file but I have 2 questions now:
- 如何编辑此文件?
- 我在网上发现您必须添加以下代码行:
client_max_body_size 8M;
我要把这行代码放在 nginx.conf
的什么位置?
Where would I put this line of code in nginx.conf
?
推荐答案
添加client_max_body_size
现在您正在编辑文件,您需要将行添加到服务器块中,如下所示;
Add client_max_body_size
Now that you are editing the file you need to add the line into the server block, like so;
server {
client_max_body_size 8M;
//other lines...
}
如果您托管多个站点,请将其添加到 http 上下文中;
If you are hosting multiple sites add it to the http context like so;
http {
client_max_body_size 8M;
//other lines...
}
还要更新 php.ini 文件中的 upload_max_filesize
,以便您可以上传相同大小的文件.
And also update the upload_max_filesize
in your php.ini file so that you can upload files of the same size.
完成后,您需要保存,这可以在 vi 中通过按 esc
键并输入 :wq
并返回来完成.
Once you are done you need to save, this can be done in vi with pressing esc
key and typing :wq
and returning.
现在您需要重新启动 nginx 和 php 以重新加载配置.这可以使用以下命令完成;
Now you need to restart nginx and php to reload the configs. This can be done using the following commands;
sudo service nginx restart
sudo service php5-fpm restart
或者不管你的 php 服务叫什么.
Or whatever your php service is called.
这篇关于如何编辑 nginx.conf 增加文件大小上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!