如何在Linux Debian上安装PHP cURL?

时间:2013-11-19 14:06:26

标签: php linux curl

如何在Linux Debian上安装PHP cURL? 我尝试了以下代码并得到了以下错误

apt-get update
apt-get install curl libcurl3 php5-curl

错误:

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/binary-i386/Packages  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/binary-i386/Packages  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/main/i18n/Translation-en_US  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/main/i18n/Translation-en  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/i18n/Translation-en_US  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/i18n/Translation-en  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/restricted/i18n/Translation-en_US  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/restricted/i18n/Translation-en  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/i18n/Translation-en_US  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://zm.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/i18n/Translation-en  Something wicked happened resolving 'zm.archive.ubuntu.com:http' (-5 - No address associated with hostname)

E: Some index files failed to download. They have been ignored, or old ones used instead.

我解决了这个问题。我的Linux框无法浏览和解析主机名。 添加适当的根后,问题就解决了。

3 个答案:

答案 0 :(得分:43)

以root身份键入控制台:

apt-get update && apt-get install php5-curl

或sudo:

sudo apt-get update && sudo apt-get install php5-curl

抱歉,我想念。

1,检查您的DNS配置,以及是否可以ping任何主机,

ping google.com
ping zm.archive.ubuntu.com

如果不起作用,请检查/etc/resolv.conf/etc/network/resolv.conf,如果没有,请将您的apt-source更改为其他来源。

/etc/apt/sources.list

镜子:http://www.debian.org/mirror/list

你不应该在Debian上使用Ubuntu源,反之亦然。

答案 1 :(得分:3)

我在topis上写了一篇文章如何[在debian linu上手动安装curl] [1] x。

[1]:http://www.jasom.net/how-to-install-curl-command-manually-on-debian-linux。这是它的捷径:

  1. cd / usr / local / src
  2. wget http://curl.haxx.se/download/curl-7.36.0.tar.gz
  3. tar -xvzf curl-7.36.0.tar.gz
  4. rm * .gz
  5. cd curl-7.6.0
  6. ./配置
  7. 使
  8. make install
  9. 重启Apache。如果您在第6点遇到错误,请尝试运行 apt-get install build-essential

答案 2 :(得分:1)

无论采用何种方法,最后都要确保您拥有curl和libcurl的更新版本。您可以curl --version查看版本。

以下是我在Ubuntu中安装最新curl版本所做的工作:

  1. sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu wily main"
  2. sudo apt-get update
  3. sudo apt-get install curl