解决Apache 2.4+PHP5.6不支持CURL

跑一个demo,突然发现,服务器上最普通的Apache 2.4+PHP5.6组合,不支持curl,报告没有curl_init函数;而php.ini里面已经打开了php_curl.dll,而且php -i的输出是正常的,说明curl是可以执行的。

折腾了半天百思不得其解,最后索性把php5.6、apache2.4以及对应的svn_mod,都升级到最新,发现仍然不好用,但是error.log报错了:

PHP Warning:  PHP Startup: Unable to load dynamic library 'D:/services/web/php56/ext/php_curl.dll' - \xef\xbf\xbd\xd2\xb2\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xd6\xb8\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xc4\xb3\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\r\n in Unknown on line 0

按照老规矩转换为byte[]然后输出字符串发现是乱码...各种码都白搭,怎么也转不出来,心好累。

后来google了一下,发现

http://stackoverflow.com/questions/16424117/php-unable-to-load-php-curl-dll-extension

里面说的比较靠谱:

写道
Make sure to have your apache SSH dlls loading correctly. On a fresh install I had to download and load into my apache bin directory the following dll "libssh2.dll"

After ssl dll was loaded cURL was able to load with no issues.

You can download it from the link below:

http://windows.php.net/downloads/pecl/releases/ssh2/0.12/

 下载php_ssh2-0.12-5.5-ts-vc11-x64.zip之后,试了一下这个libssh2.dll要放入php目录的lib下面,再启动apache curl工作正常!

话说nginx+fastcgi的模式仍然是生产环境php运行的首选模式,没有了程序之间的互相依赖问题还是会少很多而且更容易解决。

相关推荐