PHP 配置:max_execution_time 和 max_input_time
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3758377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP configuration: max_execution_time and max_input_time
提问by aneuryzm
Can I set the following PHP configuration parameters as follows:
我可以如下设置以下PHP配置参数:
max_execution_time = 360 max_input_time 360
最大执行时间 = 360 最大输入时间 360
Is that safe and efficient ?
这样安全有效吗?
I actually need my user to upload large videos with the php-based Content Management System.
我实际上需要我的用户使用基于 php 的内容管理系统上传大型视频。
So, each video upload takes some minutes. Do I need to change both and the values are good ?
因此,每个视频上传都需要几分钟时间。我是否需要更改两者并且值都很好?
thanks
谢谢
回答by Pekka
In my understanding, you have to change neither.
根据我的理解,您不必更改。
If you just store the video files using move_uploaded_file
, you will not need to increase your max_execution_time
as upload time does not count towards execution time.
如果您只是使用 存储视频文件move_uploaded_file
,则无需增加max_execution_time
上传时间,因为上传时间不计入执行时间。
The manualsays the following about max_input_time
(emphasis mine):
该手册说明了以下内容max_input_time
(强调我的):
This sets the maximum time in seconds a script is allowed to parseinput data, like POST, GET and file uploads.
这设置了允许脚本解析输入数据(如 POST、GET 和文件上传)的最长时间(以秒为单位)。
I have not tested this, but to me this sounds like it doesn'tinclude the actual time the client spends uploading the file, just the time it takes to copy it to the temporary directory. I can't vouch for this though, and I can't find any info on it. The default of 60 seconds should be ample time to parse many hundreds of megabytes of files.
我没有测试过这个,但对我来说这听起来不包括客户端上传文件的实际时间,只是将它复制到临时目录所需的时间。不过我不能保证这一点,我也找不到任何关于它的信息。默认的 60 秒应该有足够的时间来解析数百兆字节的文件。
I'd recommend to find out the perfect value using real-life tests. If your connection is too fast, use a tool to slow it down. See this SO question for suggestions:
我建议使用现实生活中的测试找出完美的价值。如果您的连接速度太快,请使用工具减慢速度。请参阅此 SO 问题以获取建议:
回答by Liu Kc
In my case, max_input_time
doesaffect my move_uploaded_file
function. I failed to upload a 3GB file with default setting (max_input_time=60
) but it succeeded with a larger value (max_input_time=300
).
就我而言,max_input_time
确实会影响我的move_uploaded_file
功能。我无法使用默认设置 ( max_input_time=60
)上传 3GB 文件,但它以更大的值 ( max_input_time=300
)成功上传。
My PHP version is 7.2.19on LAMPenviroment.
我的PHP版本是7.2.19在LAMP环境。
回答by Jayden
By default my server has max_input_time as -1. I'm assuming that means infinite.
默认情况下,我的服务器的 max_input_time 为 -1。我假设这意味着无限。