Board logo

标题: [Nginx] curl https出现502,lnmp1.5版本,php 5.5.38的 [打印本页]

作者: cs5117155    时间: 2018-7-11 12:05     标题: curl https出现502,lnmp1.5版本,php 5.5.38的

复制内容到剪贴板
代码:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.baidu.com');
// 设置header
curl_setopt($curl, CURLOPT_HEADER, 1);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
// 运行cURL,请求网页数据
$data = curl_exec($curl);
// 关闭cURL请求
curl_close($curl);
// 打印出抓取的测试数据
var_dump($data);
如果是http://www.baid.com就可以,https就不行了


openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.2o  27 Mar 2018
OpenSSL Header Version OpenSSL 1.0.2o  27 Mar 2018




这是我curl信息
curl
cURL support enabled
cURL Information 7.58.0
Age 4
Features
AsynchDNS Yes
CharConv No
Debug No
GSS-Negotiate No
IDN Yes
IPv6 Yes
krb4 No
Largefile Yes
libz Yes
NTLM Yes
NTLMWB Yes
SPNEGO Yes
SSL Yes
SSPI No
TLS-SRP Yes
Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smb, smbs, smtp, smtps, telnet, tftp
Host x86_64-pc-linux-gnu
SSL Version OpenSSL/1.1.0g
ZLib Version 1.2.11   

作者: cs5117155    时间: 2018-7-11 13:24     标题: 补上日志php-fpm日志

php-fpm.log
jingmian@jingmian-TUF:/usr/local/php/var/log$ sudo cat php-fpm.log [11-Jul-2018 13:22:11] WARNING: [pool www] child 20248 exited on signal 11 (SIGSEGV - core dumped) after 5555.544988 seconds from start
[11-Jul-2018 13:22:11] NOTICE: [pool www] child 8578 started
[11-Jul-2018 13:24:15] WARNING: [pool www] child 20261 exited on signal 11 (SIGSEGV - core dumped) after 5679.081480 seconds from start
[11-Jul-2018 13:24:15] NOTICE: [pool www] child 8825 started
jingmian@jingmian-TUF:/usr/local/php/var/log$
作者: licess    时间: 2018-7-11 13:45

相同环境测试没有问题

你可以开慢日志看看,php-fpm只能看到是执行了很长时间超时了
作者: cs5117155    时间: 2018-7-11 14:06     标题: 已经开启慢日志,可以没有被记录到,应该执行,没有超时的,我只要一运行curl https就出错了,如果http就正常

我也修改/usr/local/php/etc/php.ini 将max_execution_time=0

jingmian@jingmian-TUF:/usr/local/php/etc$ cat php-fpm.conf
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice

[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 0
request_slowlog_timeout = 2
slowlog = /usr/local/php/var/log/slow.log
jingmian@jingmian-TUF:/usr/local/php/etc$

jingmian@jingmian-TUF:/usr/local/php/var/log$ sudo cat php-fpm.log
[sudo] jingmian 的密码:
[11-Jul-2018 14:04:49] WARNING: [pool www] child 30680 exited on signal 11 (SIGSEGV - core dumped) after 90.737680 seconds from start
[11-Jul-2018 14:04:49] NOTICE: [pool www] child 31652 started
[11-Jul-2018 14:04:49] WARNING: [pool www] child 30828 exited on signal 11 (SIGSEGV - core dumped) after 89.754000 seconds from start
[11-Jul-2018 14:04:49] NOTICE: [pool www] child 31702 started
[11-Jul-2018 14:04:50] WARNING: [pool www] child 31652 exited on signal 11 (SIGSEGV - core dumped) after 0.975027 seconds from start
[11-Jul-2018 14:04:50] NOTICE: [pool www] child 31749 started
jingmian@jingmian-TUF:/usr/local/php/var/log$
作者: cs5117155    时间: 2018-7-11 20:52

我刚刚测试了,升级php7,curl https就可以了,同样是下面的代码
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.baidu.com');
// 设置header
curl_setopt($curl, CURLOPT_HEADER, 1);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
// 运行cURL,请求网页数据
$data = curl_exec($curl);
// 关闭cURL请求
curl_close($curl);
// 打印出抓取的测试数据
var_dump($data);

而且我试了更新到5.6.40版本也不行,只能在php7才成功,这个问题有办法解决吗?有些代码,我这里不支持php7的
作者: licess    时间: 2018-7-12 12:44

常见问题里有说明
5.6.40,lnmp下测试过没问题




欢迎光临 VPS侦探论坛 (http://bbs.vpser.net/) Powered by Discuz! 6.0.0