简体   繁体   English

无法在Ubuntu Linux上安装libcurl PHP

[英]Can't Install libcurl PHP on Ubuntu Linux

I am trying to use the new facebook api and it requires libcurl PHP. 我正在尝试使用新的facebook api,它需要libcurl PHP。 I used 我用了

sudo apt-get install php5-curl
sudo apachectl -k restart

And it didn't work. 而且它没有用。 I get the same error and the phpinfo() page says nothing about libcurl. 我收到相同的错误,并且phpinfo()页面未对libcurl进行任何说明。

The source of this problem is probably that I built some of the tools from source (apache2, php), but then I got bored so installed a lot of the extensions with the package manager. 这个问题的根源可能是我从源代码中构建了一些工具(apache2,php),但是后来我很无聊,因此用软件包管理器安装了很多扩展。 But I'm not exactly how to go about diagnosing the point of failure. 但是我并不是确切地去诊断故障点。

The apt-get install for curl definitely worked, and can be found in 肯定可以使用curl的apt-get安装,可以在以下位置找到

/usr/lib/php5/20060613/curl.so /usr/lib/php5/20060613/curl.so

I think a lot of my confusion stems from not knowing which files go where, and what purpose they have. 我认为我的很多困惑源于不知道哪些文件放在何处以及它们有什么用途。 Any help would be appreciated, and please tell me if I need to provide more information. 任何帮助将不胜感激,如果我需要提供更多信息,请告诉我。

edit: The specific error I get is: 编辑:我得到的具体错误是:

Exception: Facebook needs the CURL PHP extension.

from line 从线

if (!function_exists('curl_init')) {
  throw new Exception('Facebook needs the CURL PHP extension.');
}

Ubuntu: 9.10 Ubuntu的:9.10

PHP: 5.2.13 PHP:5.2.13

Loaded Configuration File: /etc/php5/apache2/php.ini 加载的配置文件:/etc/php5/apache2/php.ini

Answer of Questions 回答问题

What version of Ubuntu? 什么版本的Ubuntu?

What version of PHP? 什么版本的PHP?

How is Apache and PHP set up? Apache和PHP如何设置?

What ini files does phpinfo() say is parsed? phpinfo()会解析哪些ini文件? (should be near the top) (应该在顶部附近)

In general it's a bad idea to mix and match software from your distribution's package manager with stuff you've built yourself. 通常,将发行包的程序包管理器中的软件与您自己构建的东西混合并匹配是一个坏主意。 The package manager will not know anything about the stuff you've built yourself and so can get confused. 打包管理器不会对您自己构建的东西一无所知,因此可能会感到困惑。

Not only that but who's to say the stuff from the package manager is even binary compatible with the stuff you've built yourself? 不仅如此,谁能说软件包管理器中的内容甚至与您自己构建的内容二进制兼容? If you build it all yourself then at least you know it will all be compatible. 如果您自己构建它,那么至少您会知道它们都是兼容的。

Sounds to me like you should uninstall the extensions and build them yourself. 在我看来,您应该卸载扩展程序并自己构建它们。 If you can't or don't want to do that then go back and install apache and friends through your package manager but I would recommend having patience and going for the former option. 如果您不能执行此操作,请回去并通过软件包管理器安装apache和朋友,但是我建议您耐心等待,选择前一种方法。

Perhaps apt failed to properly modify your php.ini file to load the curl extension? 也许apt未能正确修改您的php.ini文件以加载curl扩展名?

Check out your php.ini and see if you have line like: 检查您的php.ini,看看是否有像这样的行:

extension=curl.so

or maybe: 或者可能:

extension=/usr/lib/php5/20060613/curl.so

To check if php-curl is installed please follow these steps: 要检查是否已安装php-curl,请按照以下步骤操作:

  1. Create a file in your web server (in Ubuntu it would be in /var/www folder), name it info.php 在您的Web服务器中创建一个文件(在Ubuntu中,它将在/ var / www文件夹中),并将其命名为info.php
  2. Open that file and type this command: 打开该文件并键入以下命令:

     <?php phpinfo(); ?> 
  3. Save that file 保存该文件

  4. Open your favorite browser and open that file (ex: http://localhost/info.php ) 打开您喜欢的浏览器并打开该文件(例如: http://localhost/info.php
  5. Now you will see the Information about your PHP installation 现在,您将看到有关PHP安装的信息
  6. Search for Curl, and if you cannot find it, it mean your php doesn't have curl installed. 搜索Curl,如果找不到,则表示您的php没有安装curl。

To install php-curl please follow these steps: 要安装php-curl,请按照以下步骤操作:

  1. Open your terminal and type this command: 打开终端并输入以下命令:

     sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt 
  2. After it finish open php.ini file (mine is at /etc/php5/apache2/php.ini ) and add this command: extension=curl.so 完成后,打开php.ini文件(我的文件位于/etc/php5/apache2/php.ini)并添加以下命令:extension = curl.so

  3. Save the file and restart apache with this command: 保存文件并使用以下命令重新启动apache:

     /etc/init.d/apache2 restart 
  4. Check the PHP information page again, you will find PHP-CURL installed 再次检查PHP信息页面,您会发现已安装PHP-CURL
  5. That's it 而已

Source: http://www.ivankristianto.com/os/ubuntu/howto-install-curl-in-php-apache/379/ 来源: http//www.ivankristianto.com/os/ubuntu/howto-install-curl-in-php-apache/379/

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

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