Composer 安装缺少 curl-ext
Posted
技术标签:
【中文标题】Composer 安装缺少 curl-ext【英文标题】:Composer install missing curl-ext 【发布时间】:2016-10-27 18:06:27 【问题描述】:我正在 Ubuntu 14.04.4 LS 上开发一些 php。运行composer install
失败了,我想不通。这在我使用 PHP 5.5.9 时可以正常工作,但我必须至少更新到 5.6 才能安装 phpunit。
运行php -v
输出:
PHP 5.6.23-1+deb.sury.org~trusty+2 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
运行which php
输出:
/usr/bin/php
这有点可疑,因为它不匹配 php -v
(/usr/bin 有:“php”、“php5”和“php5.6”)
这是我的 composer.json:
"require-dev":
"phpunit/phpunit": "5.4.*"
,
"require":
"silex/silex": "~1.3",
"stripe/stripe-php": "3.*"
运行 composer install
创建此输出:
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- stripe/stripe-php v3.9.2 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.9.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.9.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.8.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.7.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.7.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.6.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.5.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.4.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.3.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.2.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.14.3 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.14.2 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.14.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.14.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.13.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.12.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.12.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.11.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.10.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.10.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.1.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.0.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- stripe/stripe-php v3.14.2 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- Installation request for stripe/stripe-php 3.* -> satisfiable by stripe/stripe-php[v3.0.0, v3.1.0, v3.10.0, v3.10.1, v3.11.0, v3.12.0, v3.12.1, v3.13.0, v3.14.0, v3.14.1, v3.14.2, v3.14.3, v3.2.0, v3.3.0, v3.4.0, v3.5.0, v3.6.0, v3.7.0, v3.7.1, v3.8.0, v3.9.0, v3.9.1, v3.9.2].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/5.6/cli/php.ini
- /etc/php/5.6/cli/conf.d/10-opcache.ini
- /etc/php/5.6/cli/conf.d/10-pdo.ini
- /etc/php/5.6/cli/conf.d/20-calendar.ini
- /etc/php/5.6/cli/conf.d/20-ctype.ini
- /etc/php/5.6/cli/conf.d/20-exif.ini
- /etc/php/5.6/cli/conf.d/20-fileinfo.ini
- /etc/php/5.6/cli/conf.d/20-ftp.ini
- /etc/php/5.6/cli/conf.d/20-gettext.ini
- /etc/php/5.6/cli/conf.d/20-iconv.ini
- /etc/php/5.6/cli/conf.d/20-json.ini
- /etc/php/5.6/cli/conf.d/20-phar.ini
- /etc/php/5.6/cli/conf.d/20-posix.ini
- /etc/php/5.6/cli/conf.d/20-readline.ini
- /etc/php/5.6/cli/conf.d/20-shmop.ini
- /etc/php/5.6/cli/conf.d/20-sockets.ini
- /etc/php/5.6/cli/conf.d/20-sysvmsg.ini
- /etc/php/5.6/cli/conf.d/20-sysvsem.ini
- /etc/php/5.6/cli/conf.d/20-sysvshm.ini
- /etc/php/5.6/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
我遵循了这些说明,但它不起作用:Composer install error - requires ext_curl when it's actually enabled
运行php -i | grep php.ini
输出:
Configuration File (php.ini) Path => /etc/php/5.6/cli
Loaded Configuration File => /etc/php/5.6/cli/php.ini
运行:sudo apt-get install php5-curl
输出:
php5-curl is already the newest version.
运行curl -V
输出:
curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
感谢任何帮助。
【问题讨论】:
输入dpkg -l | grep 'php5-curl'
输出:ii php5-curl 5.6.23+dfsg-1+deprecated+dontuse+deb.sury.org~trusty+1 amd64 CURL module for php5
【参考方案1】:
执行这个:
sudo apt-get install php-curl
【讨论】:
相关答案。感谢发帖【参考方案2】:如果 ubuntu 不是服务器版本,并且网络服务器是用tasksel
安装的
尝试安装php
apt-get install php
【讨论】:
【参考方案3】:一些注意事项:
运行php -i
很好。它会显示您使用的php.ini
,以便您知道要编辑哪个文件。
不需要运行curl -v
,因为这是在 CLI 上使用的独立 curl,与 PHP 扩展 curl 无关。
您检查了php5-curl
,这是所需的包。好的。
缺少什么?您需要确保扩展也被 PHP 加载!
编辑您的/etc/php/5.6/cli/php.ini
,搜索extension
,查找php_curl
并启用它:extension=php_curl.so
。
然后在 CLI 上运行 php -m
以查看已加载模块的列表并确保已加载 curl。
最后,重新运行您的composer install
。
【讨论】:
感谢您的回复。 php.ini 文件没有 php_curl.so —— 它有 php_curl.dll,但这是针对 Windows 的,我在 Ubuntu 上。启用此行不起作用。该文件只有两个 .so 提及,都是针对 mysql 的。我从 phpinfo() 获得了“extensions_dir”,并且该目录中有一个“curl.so”。我也按照这里的说明进行操作:***.com/questions/23233460/… 并且文件 /etc/php5/mods-available/curl.ini 确实存在,并且其中确实包含“extension=curl.so”。更新上面的问题。 对,在 Linux/Ubuntu 上,您需要启用.so
文件。当您已经在扩展文件夹中找到 php_curl.so
文件时,我想知道为什么启用它不起作用。如果已加载,请与php -m
核对。 -- 如果未加载,我认为您仍在为 CLI 上使用的 PHP 编辑错误的php.ini
。请记住,有不同的 php.ini 文件 - 用于 Web 请求和 CLI。
php -m
没有列出 curl。命令php -i | grep php.ini
让我觉得我正在编辑正确的php.ini 文件。在那个 php.ini 文件中,我添加了extension=/path/to/extensions/curl.so
(从phpinfo()
的输出中获取路径),现在php -m
列出了curl。现在,当我运行 composer install
时,我收到一个关于另一个丢失包(ext-mbstring)的错误,所以这似乎有效。
但我不断收到错误的事实让我觉得有些不对劲。输入dpkg -l | grep 'php5-curl'
输出:ii php5-curl 5.6.23+dfsg-1+deprecated+dontuse+deb.sury.org~trusty+1 amd64 CURL module for php5
。请注意,那里有“不推荐使用+不使用”。在升级我的 PHP 版本时,它并不顺利,我看到了这个“已弃用”的消息,并再次升级到更高版本。也许我会卸载所有 PHP 并重新开始。
很高兴它成功了。 |好吧,如果 curl 扩展被正确加载,并且在 PHP 扩展和 PHP 核心之间没有显示 API 冲突,那么当你运行 PHP 时,它就可以正常工作——即使它被标记为已弃用。 |如果您遇到 API 不匹配,那么重新安装带有扩展的 PHP 可能会清除这种情况。以上是关于Composer 安装缺少 curl-ext的主要内容,如果未能解决你的问题,请参考以下文章
Docker 缺少 PHP 扩展的 Composer 安装(自己的容器)
安装 Laravel 时出现 Composer 错误:缺少“mbstring”?