我可以从我的 php 代码中更改 default_socket_timeout 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11682207/
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
Can I change default_socket_timeout from my php code?
提问by Radek
In my php script I restore db2 database backups. They are getting bigger and bigger. So now I was getting 500 Server Error after +-30min after executing the script. There was this line in (mod_fastcgi.c.3352) response not received, request sent: 634 on socket: tcp:127.0.0.1:9090 for /wrational/restoredb.php?mode=restore&database=RATIONAL, closing connectionin php-errors.log file.
在我的 php 脚本中,我恢复了 db2 数据库备份。他们越来越大。所以现在我在执行脚本后 +-30 分钟后收到 500 服务器错误。(mod_fastcgi.c.3352) response not received, request sent: 634 on socket: tcp:127.0.0.1:9090 for /wrational/restoredb.php?mode=restore&database=RATIONAL, closing connection在 php-errors.log 文件中有这一行。
I thought that setting `set_time_limit(6000);1 would solve the issue but it hasn't.
我认为设置 `set_time_limit(6000);1 可以解决问题,但事实并非如此。
Increasing default_socket_timeoutin php.ini file did the trick.
增加default_socket_timeoutphp.ini 文件可以解决问题。
Is there any way to change default_socket_timeoutfrom php code?
有什么办法可以改变default_socket_timeoutphp代码吗?
回答by huysentruitw
With this PHP command:
使用这个 PHP 命令:
ini_set("default_socket_timeout", 6000);
Or add/update the .htaccess file with this line:
或者使用以下行添加/更新 .htaccess 文件:
php_value default_socket_timeout 6000
Check the current value with phpinfo()
检查当前值 phpinfo()
回答by staabm
beware of the fact, that php has a bug with default_socket_timeout and SSL. It will wait endless in case you use HTTPS/SSL.
请注意,php 有一个带有 default_socket_timeout 和 SSL 的错误。如果您使用 HTTPS/SSL,它将无休止地等待。
回答by staabm
you can add/update the .htaccess file line php_value default_socket_timeout 6000
您可以添加/更新 .htaccess 文件行 php_value default_socket_timeout 6000

