我无法加载curl.so而且我得到一个:undefined function curl_init()

时间:2016-03-16 08:51:31

标签: php curl

我正在尝试使用curl_init(),但我收到以下错误:

( ! ) Fatal error: Call to undefined function curl_init()

所以,我激活了curl.so扩展名,但是当我重新启动apache时,我得到以下错误日志:

[16-Mar-2016 09:18:48 Europe/Zurich] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/curl.so' - dlopen(/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/curl.so, 9):
  Library not loaded: /usr/local/php5/lib/libcurl.4.dylib
  Referenced from: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/curl.so
  Reason: Incompatible library version: curl.so requires version 8.0.0 or later, but libcurl.4.dylib provides version 7.0.0 in Unknown on line 0
[16-Mar-2016 09:18:48 Europe/Zurich] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/oauth.so' - dlopen(/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/oauth.so, 9):
  Library not loaded: /usr/local/php5/lib/libcurl.4.dylib
  Referenced from: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/oauth.so
  Reason: Incompatible library version: oauth.so requires version 8.0.0 or later, but libcurl.4.dylib provides version 7.0.0 in Unknown on line 0
[16-Mar-2016 09:18:48 Europe/Zurich] PHP Warning:  Cannot load module 'solr' because required module 'curl' is not loaded in Unknown on line 0

我已更新curllibcurl.4.dylib,当我检查此库时:

$ otool -L /usr/local/php5/lib/libcurl.4.dylib

我得到以下追踪:

/usr/local/php5/lib/libcurl.4.dylib:
    /usr/local/opt/curl/lib/libcurl.4.dylib (compatibility version 8.0.0, current version 8.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1153.18.0)
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57031.20.26)
    /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

正如你所看到的那样,我说libcurl.4.dylib(compatibility version 8.0.0, current version 8.0.0)一样,所以我不明白我从apache那里得到错误日志的错误。

如果我检查curl,我会得到以下描述:

$ which curl
/usr/bin/curl
$ otool -L /usr/bin/curl
/usr/bin/curl:
    /usr/local/Cellar/curl/7.42.1/lib/libcurl.4.dylib (compatibility version 8.0.0, current version 8.0.0)
    /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57031.20.26)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1153.18.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

对错误可能是什么或如何让curl_init()起作用的任何想法?

我正在使用:

  • OSX Yosemite:10.10.3
  • Apache:2.4.10
  • 卷曲:7.42.1
  • PHP:5.3.29

1 个答案:

答案 0 :(得分:0)

要解决此问题,我必须更新curl并从PHP源重新编译php_curl.so。