启用/安装 Curl 扩展 (OSX Server/PHP 5.3.3/Apache 2.2)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11241477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:03:49  来源:igfitidea点击:

Enabling/Installing Curl Extension (OSX Server/PHP 5.3.3/Apache 2.2)

phpmacosapache

提问by Jeemusu

I've been having some trouble getting CURL working with PHP on a server I inherited.

在我继承的服务器上使用 PHP 处理 CURL 时遇到了一些麻烦。

So far I have enabled the extension in my php.ini by uncommenting the extension=php_curl.dllline, and restarting apache.

到目前为止,我已经通过取消注释该extension=php_curl.dll行并重新启动 apache 来启用我的 php.ini 中的扩展。

However, I now receive the following error when starting PHP:

但是,我现在在启动 PHP 时收到以下错误:

PHP Warning: PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/php_curl.dll

PHP Warning: PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/php_curl.dll

The php_curl.dll file doesn't exist in the aforementioned directory, and I can't find anywhere legitimate to download it from(doesn't seem to be included in PHP, or Curl).

php_curl.dll 文件不存在于上述目录中,我找不到任何合法的下载它的地方(似乎没有包含在 PHP 或 Curl 中)。



UPDATE
Following the steps provided in the answer here, I was able to compile a new php_curl.so file and install it to the extensions directory.

更新
按照此处答案中提供的步骤,我能够编译一个新的 php_curl.so 文件并将其安装到扩展目录中。

Cudos go to Francois Deschenes!!

Cudos 去Francois Deschenes!!

To compile a curl.so (php_curl.dll) module from scratch:

从头开始编译 curl.so (php_curl.dll) 模块:

  1. Download and extract a new copy of your version of PHP.
  2. Open a terminal window and go to the curl directory (Type cd php-5.3.3/ext/curl/).
  3. Type phpize.
  4. Type ./configure.
  5. Type make.
  6. Type sudo make install.
  7. Uncomment extension=curl.soin your php.ini.
  1. 下载并提取您的 PHP 版本的新副本。
  2. 打开终端窗口并转到 curl 目录(类型cd php-5.3.3/ext/curl/)。
  3. 键入phpize
  4. 键入./configure
  5. 键入make
  6. 键入sudo make install
  7. extension=curl.so在 php.ini 中取消注释。

You should also make sure the extension is commented out before you start the processes, otherwise you may receive an error about the module already existing.

您还应该确保在开始处理之前将扩展名注释掉,否则您可能会收到有关模块已经存在的错误。



采纳答案by Jeemusu

Following the steps provided in the answer here, I was able to compile a new php_curl.so file and install it to the extensions directory.

按照此处答案中提供的步骤,我能够编译一个新的 php_curl.so 文件并将其安装到扩展目录中。

Cudos go to Francois Deschenes!!

Cudos 去Francois Deschenes!!

To compile a curl.so (php_curl.dll) module from scratch:

从头开始编译 curl.so (php_curl.dll) 模块:

  1. Download and extract a new copy of your version of PHP.
  2. Open a terminal window and go to the curl directory (Type cd php-5.3.3/ext/curl/).
  3. Type phpize.
  4. Type ./configure.
  5. Type make.
  6. Type sudo make install.
  7. Uncomment extension=curl.soin your php.ini.
  1. 下载并提取您的 PHP 版本的新副本。
  2. 打开终端窗口并转到 curl 目录(类型cd php-5.3.3/ext/curl/)。
  3. 键入phpize
  4. 键入./configure
  5. 键入make
  6. 键入sudo make install
  7. extension=curl.so在 php.ini 中取消注释。

You should also make sure the extension is commented out before you start the processes, otherwise you may receive an error about the module already existing.

您还应该确保在开始处理之前将扩展名注释掉,否则您可能会收到有关模块已经存在的错误。

回答by Sándor Tóth

Why don't use

为什么不用

sudo port install php5-curl 

(on php54: php54-curl)?

(在 php54 上:php54-curl)?

回答by Harsha

Download the 'port' using the following URL and install it:

使用以下 URL 下载“端口”并安装它:

http://www.macports.org/install.php

http://www.macports.org/install.php

There are different versions and you can select one installation pack for your Mac Version.

有不同的版本,您可以为您的 Mac 版本选择一个安装包。

After installed, open a terminal and type the following command to install directly,

安装好后,打开终端,输入以下命令直接安装,

$ sudo port install php5-curl 

Otherwise - Login to port terminal by just typing

否则 - 只需键入即可登录端口终端

$ sudo port

and type

并输入

> install php5-curl

It will get few minutes to install all the dependancies and finally you will see the following message

安装所有依赖项需要几分钟的时间,最后您将看到以下消息

--->  No broken files found.