问题描述
我的服务器是nginx + php-fpm
My server is nginx + php-fpm
代码将导致错误
file_get_contents('https://github.com');
或
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://github.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch); //crash here
curl_close($ch);
网页显示502错误
nginx日志是
fpm日志是
7月03 00:37:37.619926 [警告] fpm_children_bury孩子3567(池默认)退出信号11 SIGSEGV(核心转储)从开始417.576755秒后
Jul 03 00:37:37.619926 [WARNING] fpm_children_bury(), line 215: child 3567 (pool default) exited on signal 11 SIGSEGV (core dumped) after 417.576755 seconds from start
7月03 00:37:37.620807 [注意] fpm_children_make 352:child 4193(pool default)started
Jul 03 00:37:37.620807 [NOTICE] fpm_children_make(), line 352: child 4193 (pool default) started
如果请求网址以http://开头,一切正常。
If the request url starts with http:// , everything is OK .
php configure命令是
php configure command is
'./configure' '--prefix=/www/nginx_php-5.2.17' '--with-config-file-path=/www/nginx_php-5.2.17/etc' '--with-mysql=/www/mysql' '--with-iconv=/usr' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-discard-path' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-ftp' '--enable-sockets' '--enable-zip' '--enable-fastcgi' '--enable-fpm' '--with-fpm-conf=/www/etc/php-fpm.conf'
推荐答案
尝试添加以下两项:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
他们会阻止SSL证书的验证。问题,因为验证可能失败。除非必须验证来源,在使用 cURL
下载数据时,始终添加这两行。
They will prevent the verification of the SSL certificate. This might be the issue as the verification might fail. Unless it's mandatory to verify the source, always add these 2 lines when downloading data with cURL
.
PS :
这篇关于当curl或file_get_contents请求https url时,php-fpm崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!