简体   繁体   English

php curl 适用于 cli 但不适用于 apache

[英]php curl works from cli but not from apache

I can't get cURL to work from inside Apache by any means.我无法让 cURL 以任何方式从 Apache 内部工作。 It's actually fairly strange too provided that:这实际上也很奇怪,前提是:

  1. I can execute my PHP pages from the CLI and it POSTs my requests perfectly fine我可以从 CLI 执行我的 PHP 页面,它可以很好地发布我的请求
  2. When I look at my error logs, I get "PHP Fatal error: Call to undefined function curl_init()" as if the extension isn't installed at all.当我查看我的错误日志时,我收到“PHP 致命错误:调用未定义的 function curl_init()”,就好像根本没有安装扩展程序一样。 Similarly, a quick `phpinfo()` also yields such as if the extension isn't installed.类似地,如果没有安装扩展,快速的 `phpinfo()` 也会产生。

Additionally, when I built PHP, I opted the "--enable-curl" flag.此外,当我构建 PHP 时,我选择了“--enable-curl”标志。

You are probably not loading the extension in the appropriate php.ini .您可能没有在适当的php.ini中加载扩展。 The file should include something like:该文件应包括以下内容:

[PHP_CURL]
extension=php_curl.dll

Also, --enable-curl is not a PHP configure option.此外, --enable-curl不是 PHP 配置选项。 --with-curl=[DIR] is the one you'd want. --with-curl=[DIR]是您想要的。 Check out the cURL installation instructions .查看cURL 安装说明

php_curl.dll should be inside PHP's ext directory when configured correctly.如果配置正确, php_curl.dll应该在 PHP 的ext目录中。

I had same problem after installing php5-curl.安装 php5-curl 后我遇到了同样的问题。 I rebooted apache and that fixed it.我重新启动了 apache 并修复了它。

sudo /etc/init.d/apache2 restart for ubuntu 12.04 sudo /etc/init.d/apache2 restart for ubuntu 12.04

I had similar problem - worked from cli, silently failed from Apache 2.4我有类似的问题 - 从 cli 工作,从 Apache 2.4 默默失败

I've tried:我试过了:

1) copying ssleay32.dll and libeay32.dll from php folder into apache\bin folder - didn't work 1) 将 ssleay32.dll 和 libeay32.dll 从 php 文件夹复制到 apache\bin 文件夹中 - 无效

2) deleting ssleay32.dll and libeay32.dll from apache\bin folder completely - WORKED. 2)从 apache\bin 文件夹中完全删除 ssleay32.dll 和 libeay32.dll - 工作正常。

You should restart apache server each time you make change to make it work.每次进行更改以使其正常工作时,都应重新启动 apache 服务器。

Also you should install both x86 and x64 versions of C++ Resistributable Visual Studio from Microsoft .您还应该安装Microsoft的 x86 和 x64 版本的 C++ Resistributable Visual Studio。

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

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