【问题标题】:nginx throws "504" gateway error when trying to run a phantomjs script from php尝试从 php 运行 phantomjs 脚本时,nginx 抛出“504”网关错误
【发布时间】:2015-04-10 15:21:47
【问题描述】:

我正在尝试像这样运行 phantomjs 脚本:

$max_time = ini_get('max_execution_time');
set_time_limit(0);
$result = shell_exec($path_to_phantomjs);
// Do stuff with result here...
set_time_limit($max_time);

这是一个抓取脚本,需要几分钟才能完成,但我想等待它的结果并在我的服务器上对其进行操作。对我来说,这个脚本将从客户端运行并返回一些结果以供分析等对我来说也很重要。

这会因 nginx 的 504 错误而失败,应该注意的是,相同的代码在我的(本地)apache 服务器上运行良好。

【问题讨论】:

    标签: php linux nginx phantomjs server


    【解决方案1】:

    504 错误表示 nginx 从后端 (php) 获取页面时超时。要解决此问题,您应该将 php 代理位置中以下变量的值增加到高于执行脚本的时间(以秒为单位):

    fastcgi_read_timeout

    proxy_read_timeout

    【讨论】:

    • 我猜只有其中一个,可能是第一个。
    猜你喜欢
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 2011-04-08
    • 1970-01-01
    • 2019-09-29
    • 2016-06-19
    • 2019-01-20
    相关资源
    最近更新 更多