PHP |“的;您的系统中缺少请求的PHP扩展bcmath。”;
各位发展商: 我正在尝试在最近启动的开发服务器上为我的一个PHP项目使用composer,但由于某些原因,我无法使用它。我成功安装了composer,但是,当我尝试运行require命令时,出现以下错误:PHP |“的;您的系统中缺少请求的PHP扩展bcmath。”;,php,web,configuration,composer-php,ini,Php,Web,Configuration,Composer Php,Ini,各位发展商: 我正在尝试在最近启动的开发服务器上为我的一个PHP项目使用composer,但由于某些原因,我无法使用它。我成功安装了composer,但是,当我尝试运行require命令时,出现以下错误: root@webserver:/var/mypersonal/index# composer require php-amqplib/php-amqplib PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/
root@webserver:/var/mypersonal/index# composer require php-amqplib/php-amqplib
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_openssl.dll' - /usr/lib/php/20151012/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^2.6 for php-amqplib/php-amqplib
./composer.json has been created
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
- php-amqplib/php-amqplib v2.6.3 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.1 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.0 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- Installation request for php-amqplib/php-amqplib ^2.6 -> satisfiable by php-amqplib/php-amqplib[v2.6.0, v2.6.1, v2.6.2, v2.6.3].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/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.
Installation failed, deleting ./composer.json.
我假设这与运行composerrequire命令时收到的PHP警告有关,但没有google搜索结果将我引向正确的方向
此外,我还提供了我的/etc/php/7.0/cli/php.ini文件,以防该文件出错
(由于帖子的字符限制,我无法在此帖子中包含该文件。)
谢谢。您可以使用函数查看是否加载了bcmath
模块。或者在终端php-m
或php-m|grep name_的_模块
根据您使用的操作系统,您可以安装它:
Ubuntu
sudo apt安装php7.0-bcmath
森托斯
yum安装bcmath
我尝试了下面的软件包,它在Php版本5.6中工作
yum install php56w-bcmath
对于php Centos中的任何版本,请使用 这个解决方案对我有效 yum安装php-bcmath PHP将采用机器中安装的默认版本,搜索并安装该软件包 删除已创建的文件composer.lock文件,然后再次运行 编写器安装 如果你跑 作曲家更新
它将更新composer.json中安装的任何默认软件包,这可能会给您带来问题。对于PHP 7.1,以下内容对我有用:
sudo apt install php7.1-bcmath
按类型检查您的php版本:
php--version
您将看到如下内容:
PHP 7.2.9-1+ubuntu16.04.1 ....
然后sudo-apt-install phpX.X-bcmath
其中X.X是php版本,因此对于本例,它将是sudo-apt-install php7.2-bcmath
在此之后,按类型检查模块是否存在
php-m | grep bcmath
奇怪的事情
几个月前,我以同样的方式安装了所有PHP版本。下面是4个配置相同的php版本:5.6、7.0、7.1、7.2,具有相同的扩展(当这成为可能时)。奇怪的是,除了7.1之外的所有php版本都存在bcmath。
在解决方案搜索中,我来到了这个问题,在这里,逻辑的东西被确认安装了bcmath,但在我的Linode Debian 9服务器中,命令 apt安装php7.1-bcmath 不工作,有3条错误消息
- E:找不到包php7.1-bcmath
- E:找不到带有glob“php7.1-bcmath”的包
- E:找不到正则表达式为“php7.1-bcmath”的包
经过一些尝试后,我得到了启发:修改/etc/apt/sources.list启用默认的Linode存储库,然后在apt更新后(立即没有解决方案),我恢复了/etc/apt/sources.list,再次注释Linode镜像源。神奇的是,在新的apt更新之后,命令现在开始工作
通过这一点,我确认:apt install php7.1-bcmath是正确的命令,但是您的Debian可能需要一个教训希望这能解决问题 sudo apt安装php-bcmath PHP7.2 德比安-杰西
像一个魔咒一样工作:)对于这个问题,我们应该使用sudo apt安装php bcmathphp 7.2,如果您有其他版本,请相应地更改它 对于
CentOS
sudo yum install php72-bcmath
对于Ubuntu
sudo apt install php7.0-bcmath
运行此命令,希望它能正常工作
sudo apt-get install php-bcmath
如果您使用的是Docker:
- bcmath可以通过在容器中运行以下命令来安装:
docker php ext install bcmath
- 在Ubuntu 20.04中
对于php7.4.3,
sudo apt install php7.4-bcmath
只是安装它的注意事项,如果您运行php-v,您可以检查正在运行的php版本。我的是PHP7.1.8-1ubuntu1。因为我使用的是7.1,所以它必须安装php7.1-bcmath。你确定吗?即使已经多次提到,您也应该添加一个解释,对于php7.2sudo apt install php7.2-bcmath
对于php7.4 sudo apt install php7.4-bcmath,我们只需要根据需要更改命令行代码中的php版本和包名。例如,sudo apt安装php7.3-mbstring
sudo apt-get install php-bcmath