简体   繁体   English

PHP 7卷曲未加载

[英]PHP 7 curl not being loaded

I have installed in my local computer apache 2.4 with PHP 7.1. 我已经在我的本地计算机apache 2.4中安装了PHP 7.1。 I enabled curl in my php.ini (extension=php_curl.dll), but for some reason curl is not being loaded even after i enabled it, i made a phhinfo to check, and nothing, i also made a small script: 我在我的php.ini(extension = php_curl.dll)中启用了curl,但由于某种原因,即使我启用了curl也没有加载,我做了一个phhinfo来检查,什么都没有,我也做了一个小脚本:

function isExtensionLoaded($extension_name){
    return extension_loaded($extension_name);
}

echo isExtensionLoaded('curl');

And nothing, is blank, what it means is not being loaded, is something missing? 没有什么,是空白的,它意味着什么是没有被装载,是缺少什么? Im on Windows 10. 我在Windows 10上。

在我的情况下,当我将nghttp2.dll复制到Apache bin目录时,它也有效

I was looking for a solution a really long time, until I decided to read some comments on the PHP documentation site: http://php.net/manual/de/curl.installation.php 我很长时间都在寻找解决方案,直到我决定在PHP文档站点上阅读一些注释: http//php.net/manual/de/curl.installation.php

I fixed coping the following list files from php folder (in my case C:\\xampp\\php7) 我修复了从php文件夹中处理以下列表文件(在我的情况下为C:\\ xampp \\ php7)

libeay32.dll
libssh2.dll
ssleay32.dll

Some people also had to move nghttp2.dll for it to work. 有些人还不得不移动nghttp2.dll才能正常工作。

To your apache/bin folder (C:\\xampp\\apache\\bin in my case). 到你的apache / bin文件夹(在我的例子中是C:\\ xampp \\ apache \\ bin)。

I also copied those to C:\\Windows\\System32, but I do not think any of these files were loaded. 我也将它们复制到C:\\ Windows \\ System32,但我认为这些文件都没有被加载。

EDIT : I successfully deleted these dlls from system32 folder and was able to run curl afterwards 编辑 :我成功从system32文件夹中删除了这些dll,之后能够运行curl

Make sure you have edited the right file. 确保您已编辑正确的文件。 There should be separate file for CLI, Apache2 and other SAPIs. CLI,Apache2和其他SAPI应该有单独的文件。 After doing so, restart the Apache2 server. 完成后,重新启动Apache2服务器。

It hard to guess why its not running and as I see you don't get error atm. 很难猜到为什么它没有运行,因为我看到你没有得到错误atm。

you should get errors but I am pretty sure you didn't set error-logging in your php.ini 你应该得到错误,但我很确定你没有在你的php.ini中设置错误记录

First we need to activate logging to see why your extensions are not running correctly: 首先,我们需要激活日志记录以查看扩展程序未正确运行的原因:

Please change/add following lines in your php.ini file: 请在php.ini文件中更改/添加以下行:

display_startup_errors = On
error_log = 'c:/php-logs/php-error.log'

Now create the php-logs directory and php-log.log file 现在创建php-logs目录和php-log.log文件

mkdir c:/php-logs
copy NUL c:/php-logs/php-error.log

Now restart the server. 现在重启服务器。 Now you should get the errors and please share the error-code so I can help 现在你应该得到错误,请分享错误代码,以便我可以提供帮助

Update: 更新:

Enable mod_ssl in `httpd.conf`` 在`httpd.conf``中启用mod_ssl

LoadModule ssl_module c:\apache-2.2\modules\mod_ssl.so

It works if you set ssl VERIFYPEER to false 如果您将ssl VERIFYPEER设置为false则它可以正常工作

curl_setopt($get, CURLOPT_SSL_VERIFYPEER, false);

it will works fine . 它会工作正常。 you can also make curl work withe ssl by downloading the cacert.pem from https://curl.haxx.se/docs/caextract.html and Adding the cert to your php.ini file 您也可以通过从https://curl.haxx.se/docs/caextract.html下载cacert.pem并将证书添加到您的php.ini文件来使用ssl进行卷曲工作

curl.cainfo="C:\path\cacert.pem" 
openssl.cafile="C:\path\cacert.pem"

and

curl_setopt($get, CURLOPT_SSL_VERIFYPEER, true);

will work too this way you can prevent man-in-the-middle attacks, check this link for more details http://thisinterestsme.com/php-curl-ssl-certificate-error/ 也可以这样工作,你可以防止中间人攻击,查看此链接了解更多详情http://thisinterestsme.com/php-curl-ssl-certificate-error/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM