我目前在 10.04 Lucid 中安装了 PHP 5.3 和 Apache。如何添加 PHP Curl 库?我需要为 curl 安装任何其他依赖项吗?
答案1
我相信 php5-curl 软件包应该可以解决问题。使用您选择的软件包管理器,deps 应该会得到处理。
sudo apt-get install php5-curl
之后您将需要重新启动服务器:
sudo service apache2 restart
或者,如果你正在使用 php-fpm,则需要重新启动 php5-fpm
sudo service php5-fpm restart
答案2
对于 subversion php5.6,使用以下命令(针对 Ubuntu 14.04 测试):
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5.6
php — version
sudo apt-get install php5.6-curl
答案3
我的配置:Ubuntu 11.10,已经安装了mysql,php5和apache2,在终端中安装php5-curl之前我做了:
编辑源列表如下:
sudo -H gedit /etc/apt/sources.list
您可以检查您的配置http://repogen.simplylinux.ch/
下一个命令:
apt-get install aptitude
下一个命令:
aptitude install php5-curl
你会得到类似这样的结果:
The following NEW packages will be installed:
php5-curl{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.1 kB of archives. After unpacking 127 kB will be used.
The following packages have unmet dependencies:
php5-curl: Depends: php5-common (= 5.3.6-13ubuntu3.1) but 5.3.6-13ubuntu3.8 is installed.
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php5-curl [Not Installed]
Accept this solution? [Y/n/q/?] n
你的答案是 n
打印出下一行:
The following actions will resolve these dependencies:
Downgrade the following packages:
1) libapache2-mod-php5 [5.3.6-13ubuntu3.8 (now) -> 5.3.6-13ubuntu3.1 (oneiric)]
2) php5 [5.3.6-13ubuntu3.8 (now) -> 5.3.6-13ubuntu3.1 (oneiric)]
3) php5-cli [5.3.6-13ubuntu3.8 (now) -> 5.3.6-13ubuntu3.1 (oneiric)]
4) php5-common [5.3.6-13ubuntu3.8 (now) -> 5.3.6-13ubuntu3.1 (oneiric)]
5) php5-gd [5.3.6-13ubuntu3.8 (now) -> 5.3.6-13ubuntu3.1 (oneiric)]
6) php5-mysql [5.3.6-13ubuntu3.8 (now) -> 5.3.6-13ubuntu3.1 (oneiric)]
Accept this solution? [Y/n/q/?] y
您的答案是 y。
在浏览器中打开 phpinfo(),检查属性:
extension_dir /usr/lib/php5/20090626+lfs
在那个文件夹中你现在应该有curl 库
编辑 php.ini
nano /etc/php5/apache2/php.ini
找到“动态扩展”添加以下代码:
extension=curl.so
之后重新启动 apache2 并检查 phpinfo(),必须启用 curl
答案4
您需要安装 php5-curl 包。
sudo apt-get install php5-curl