nextcloud 设置文件最大上传限制
nextcloud 设置文件最大上传限制
官方文档| Uploading big files > 512MB — Nextcloud 14 Administration Manual 14 documentation
nginx
从nginx 1.7.11开始,fastcgi_request_buffering提供了一个新的配置选项。在 nginx 配置中将此选项设置为可能有助于在上传过程中出现超时。此外,如果您系统的tmp分区上的磁盘空间不足,它会有所帮助。fastcgi_request_buffering off;
注意
确保它指向一个分区,该分区具有足够的空间来容纳您的上载文件大小,并且与 或 位于同一分区上(见下文)。为获得最佳性能,请将这些硬盘放在专用于交换和临时存储的单独硬盘上。client_body_temp_path``upload_tmp_dir``tempdirectory
如果您的站点位于 nginx 前端后面(例如负载均衡器):
默认情况下,由于前端和在前端上,下载将被限制为 1GB。proxy_buffering``proxy_max_temp_file_size
- 如果可以访问前端的配置,请禁用proxy_buffering或从默认的 1GB 增加proxy_max_temp_file_size。
- 如果您无权访问前端,请在后端服务器上将X-Accel-Buffering标头设置为。
add_header X-Accel-Buffering no;
配置 PHP
如果您不想使用Nextcloud或文件,则可以改用PHP。如果您输入了任何与上传大小相关的行,请确保注释掉任何行。.htaccess``.user.ini``.htaccess
如果您在 32 位系统上运行 Nextcloud,则需要注释掉文件中的任何指令。open_basedir``php.ini
在 中设置以下两个参数,使用您自己的所需文件大小值:php.ini
upload_max_filesize = 16G
post_max_size = 16G
告诉 PHP 您希望它使用哪个临时目录:
upload_tmp_dir = /var/big_temp_file/
必须在 或 中关闭输出缓冲,否则 PHP 将返回与内存相关的错误:.htaccess``.user.ini``php.ini
output_buffering = 0
配置下一个云
作为PHP的替代方案(例如,如果您无权访问您的),您还可以使用您的设置为上传的文件配置临时位置(请参阅配置参数)。upload_tmp_dir``php.ini``tempdirectory``config.php
如果已在(请参阅配置参数)文件中配置了该设置,请确保它不会太低。此设置需要至少配置为最长上载所需的时间(以秒为单位)。如果不确定,请从配置中完全删除此设置,以将其重置为 中显示的默认值。session_lifetime``config.php``config.sample.php
在 GUI 中配置上载限制
如果本文档中描述的所有先决条件都已准备就绪,则管理员可以使用 Nextcloud 管理后端中的输入框按需更改上传限制。File handling
根据您的环境,您可能会收到为此输入框显示的权限不足消息。
为了能够使用此输入框,您需要确保:
- 您的Web服务器能够使用Nextcloud提供的文件(仅限Apache)
.htaccess
- 您的 Web 服务器正在运行的用户对文件具有写入权限,并且
.htaccess``.user.ini
nginx
Since nginx 1.7.11 a new config option fastcgi_request_buffering is availabe. Setting this option to in your nginx config might help with timeouts during the upload. Furthermore it helps if you’re running out of disc space on the tmp partition of your system.fastcgi_request_buffering off;
Note
Make sure that points to a partition with adequate space for your upload file size, and on the same partition as the or (see below). For optimal performance, place these on a separate hard drive that is dedicated to swap and temp storage.client_body_temp_path``upload_tmp_dir``tempdirectory
If your site is behind a nginx frontend (for example a loadbalancer):
By default, downloads will be limited to 1GB due to and on the frontend.proxy_buffering``proxy_max_temp_file_size
- If you can access the frontend’s configuration, disable proxy_buffering or increase proxy_max_temp_file_size from the default 1GB.
- If you do not have access to the frontend, set the X-Accel-Buffering header to on your backend server.
add_header X-Accel-Buffering no;
Configuring PHP
If you don’t want to use the Nextcloud or file, you may configure PHP instead. Make sure to comment out any lines pertaining to upload size, if you entered any..htaccess``.user.ini``.htaccess
If you are running Nextcloud on a 32-bit system, any directive in your file needs to be commented out.open_basedir``php.ini
Set the following two parameters inside , using your own desired file size values:php.ini
upload_max_filesize = 16G
post_max_size = 16G
Tell PHP which temp directory you want it to use:
upload_tmp_dir = /var/big_temp_file/
Output Buffering must be turned off in or or , or PHP will return memory-related errors:.htaccess``.user.ini``php.ini
output_buffering = 0
Configuring Nextcloud
As an alternative to the of PHP (e.g. if you don’t have access to your ) you can also configure a temporary location for uploaded files by using the setting in your (See Configuration Parameters).upload_tmp_dir``php.ini``tempdirectory``config.php
If you have configured the setting in your (See Configuration Parameters) file then make sure it is not too low. This setting needs to be configured to at least the time (in seconds) that the longest upload will take. If unsure remove this completely from your configuration to reset it to the default shown in the .session_lifetime``config.php``config.sample.php
Configuring upload limits within the GUI
If all prerequisites described in this documentation are in place an admin can change the upload limits on demand by using the input box within the administrative backend of Nextcloud.File handling
Depending on your environment you might get an insufficient permissions message shown for this input box.
To be able to use this input box you need to make sure that:
- your Web server is able to use the file shipped by Nextcloud (Apache only)
.htaccess
- the user your Web server is running as has write permissions to the files and
.htaccess``.user.ini