CentOs 6,Php7.1,libevent,Nginx返回502 [英] CentOs 6, Php7.1, libevent, nginx returns 502
问题描述
我正在将laravel Web应用程序从php5.6升级到php7.1,这使我升级了libevent模块.应用程序是基于React库的异步响应.
I am upgrading laravel web application from php5.6 to php7.1 which leads me to upgrading libevent module. Application is async ans based on react library.
所以我结束了安装:PHP 7.1.12,libevent:2.1.8 + expressif/pecl-event-libevent.而且我有稳定的"502错误网关"来自nginx.没有libevent(ReactStreamLoop)或PHP 5.6 + libevent:1.4都可以正常工作.请求登陆到index.php,稍后在启动应用程序内部发生某些事情.
So I ended with installed: PHP 7.1.12, libevent: 2.1.8 + expressif/pecl-event-libevent. And I have stable "502 Bad Gateway" from nginx. Without libevent (ReactStreamLoop) or on PHP 5.6 + libevent:1.4 works fine. Request lands to index.php and something happens later, inside of starting application.
nginx日志:
2017/11/24 10:41:24 [错误] 24985#0:* 7 recv()失败(104:对等重置连接),同时从上游读取响应标头,客户端:14.183.16.180,服务器:173.199.117.122,请求:"GET/HTTP/1.1",上游:"fastcgi://127.0.0.1:9000",主机:"173.199.117.122"
2017/11/24 10:41:24 [error] 24985#0: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 14.183.16.180, server: 173.199.117.122, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "173.199.117.122"
2017/11/24 10:41:25 [错误] 24985#0:* 7 recv()失败(104:对等连接重置),同时从上游读取响应头,客户端:14.183.16.180,服务器:173.199.117.122,请求:"GET/HTTP/1.1",上游:"fastcgi://127.0.0.1:9000",主机:"173.199.117.122"
2017/11/24 10:41:25 [error] 24985#0: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 14.183.16.180, server: 173.199.117.122, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "173.199.117.122"
php-fpm日志:
php-fpm log:
[24-Nov-2017 10:41:24]警告:[池www]子项22300在启动39.486978秒后退出信号11(SIGSEGV)
[24-Nov-2017 10:41:24] WARNING: [pool www] child 22300 exited on signal 11 (SIGSEGV) after 39.486978 seconds from start
[2017年11月24日10:41:24]注意:[pool www]子代22331已启动
[24-Nov-2017 10:41:24] NOTICE: [pool www] child 22331 started
[2017年11月24日10:41:25]警告:[池www]子项22301在启动40.205103秒后退出信号11(SIGSEGV)
[24-Nov-2017 10:41:25] WARNING: [pool www] child 22301 exited on signal 11 (SIGSEGV) after 40.205103 seconds from start
[2017年11月24日10:41:25]注意:[pool www]子代22332已启动
[24-Nov-2017 10:41:25] NOTICE: [pool www] child 22332 started
更新:如果强制使用ReactStreamLoop,则可以使用.
UPDATE: works if force usage ReactStreamLoop.
更新:在类似的配置上本地复制.找到了这样的示例,该示例与LibEventLoop一起崩溃,但与StreamSelectLoop一起工作.
UPDATE: Reproduced locally on similar config. Found such example that crashes with LibEventLoop but works with StreamSelectLoop.
require_once __DIR__.'/../vendor/autoload.php';
$loop = new \React\EventLoop\LibEventLoop();
//$loop = new \React\EventLoop\StreamSelectLoop();
$config = array(
'host' => '127.0.0.1',
'port' => '3306',
'dbname' => 'mysql',
'user' => 'root',
'passwd' => 'root',
'charset' => 'utf8',
);
$client = new \React\MySQL\Connection($loop, $config);
$client->connect(function() {});
$client->query('select 8 as cnt', function () {
echo "inside\n";
});
echo "start\n";
$loop->run();
输出:
#php ./tests/test.php
start
Segmentation fault (core dumped)
推荐答案
您使用的扩展名与PHP 7及更高版本不兼容.您必须使用其他事件循环实现之一,例如基于 stream_select()
的事件实现或受支持的扩展之一.
The extension you're using is not compatible with PHP 7 and up. You have to use one of the other event loop implementations, such as the one based on stream_select()
or one of the supported extensions.
请参见 https://github.com/reactphp/event-loop/pull/62 了解更多信息.
这篇关于CentOs 6,Php7.1,libevent,Nginx返回502的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!