PHP | “您的系统中缺少请求的 PHP 扩展 bcmath。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45049601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP | "The requested PHP extension bcmath is missing from your system."
提问by Coelho
Greetings fellow developers,
问候开发人员,
I am trying to use composer for a PHP project of mine on a development server I recently booted up and for some reason I am unable to. I successfully installed composer, however, when I try to run the requirecommand I get the following error:
我正在尝试在我最近启动的开发服务器上为我的 PHP 项目使用作曲家,但由于某种原因我无法使用。我成功安装了 composer,但是,当我尝试运行require命令时,出现以下错误:
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.
I'm assuming it's something to do with the PHP warning I recieve right when running the composer requirecommand but no google search results lead me to the correct direction.
我假设这与我在运行composer require命令时收到的 PHP 警告有关,但没有谷歌搜索结果引导我找到正确的方向。
Additionally, I have provided my /etc/php/7.0/cli/php.inifile incase of an error in that file.
此外,我还提供了我的/etc/php/7.0/cli/php.ini文件,以防该文件中出现错误。
https://gist.github.com/anonymous/bc5bac59d684cbf575cef931ef36daf6(I couldn't include the file in this post due to the character limit on posts.)
https://gist.github.com/anonymous/bc5bac59d684cbf575cef931ef36daf6 (由于帖子的字符限制,我无法在这篇文章中包含该文件。)
Thank you.
谢谢你。
回答by JTC
You can use function get_loaded_extensionsto see if bcmathmodul is loaded. Or in terminal php -mor php -m | grep name_of_the_modul
您可以使用函数get_loaded_extensions来查看bcmath模块是否已加载。或在终端php -m或php -m | grep name_of_the_modul
You can install it depending on what OS you are using:
您可以根据您使用的操作系统安装它:
Ubuntu
Ubuntu
sudo apt install php7.0-bcmath
sudo apt install php7.0-bcmath
CentOS
CentOS
yum install bcmath
yum install bcmath
回答by chebaby
PHP 7.2
PHP 7.2
Debian - jessie
Debian - 杰西
apt-get update apt-get install php7.2-bcmath
apt-get update apt-get install php7.2-bcmath
work like a charm :)
像魅力一样工作:)
回答by Sayan Biswas
For any version in php Centos use
对于 php Centos 中的任何版本使用
This solution worked for me
这个解决方案对我有用
yum install php-bcmath
yum 安装 php-bcmath
PHP will take the default version installed in the machine, search for that package and install it.
PHP 将采用机器中安装的默认版本,搜索该软件包并安装它。
Delete the file composer.lock file if that is already created and then run again,
如果已经创建,请删除文件 composer.lock 文件,然后再次运行,
composer install
作曲家安装
If you run
如果你跑
composer update
作曲家更新
it will update whatever default packages are installed in composer.json which might create problem for you.
它将更新 composer.json 中安装的任何默认包,这可能会给您带来问题。
回答by eVagabond
For PHP 7.1, the following worked for me:
对于 PHP 7.1,以下对我有用:
sudo apt install php7.1-bcmath
回答by Khaled Alam
check your php version by type: php --version
按类型检查您的 php 版本: php --version
you will see something like this:
你会看到这样的事情:
PHP 7.2.9-1+ubuntu16.04.1 ....
then sudo apt install phpX.X-bcmathwhere X.X is php version, so for this ^ example it will be sudo apt install php7.2-bcmath
那么sudo apt install phpX.X-bcmathXX是php版本,所以对于这个^示例,它将是 sudo apt install php7.2-bcmath
after this check if module existed or not by type php -m | grep bcmath
在此之后按类型检查模块是否存在 php -m | grep bcmath
回答by Hamza Zymawy
php 7.2 if you have other version just change it accordingly
php 7.2 如果您有其他版本,请相应地更改它
For CentOS
为了 CentOS
sudo yum install php72-bcmath
For Ubuntu
为了 Ubuntu
sudo apt install php7.0-bcmath
回答by Hasib Kamal
Run this command, hope it will works
运行这个命令,希望它会起作用
sudo apt-get install php-bcmath
回答by sh6210
hope this will fix the problem.
希望这能解决问题。
sudo apt install php-bcmath
sudo apt 安装 php-bcmath
回答by Amir Zandieh
For this problem we should use sudo apt install php-bcmath
对于这个问题,我们应该使用sudo apt install php-bcmath
回答by iodurocarburo
Strange thing here
Some month ago I have installed all PHP version in the same manner. In here are the 4 identically configured version of php: 5.6, 7.0, 7.1, 7.2, with the same extensions ( when this was made possible ).
The strange thing was that bcmathis present for all php version excluding 7.1.
In the solution search I arrive here in this question, where the logic's things was confirmed installing bcmath, but in my Linode Debian 9 server the command
apt install php7.1-bcmathdoesn't work, with 3 error messages;
奇怪的事情
几个月前,我以相同的方式安装了所有 PHP 版本。这里有 4 个相同配置的 php 版本:5.6、7.0、7.1、7.2,具有相同的扩展(当这成为可能时)。
奇怪的是,除了 7.1 之外的所有 php 版本都存在bcmath。
在解决方案搜索中,我到达了这个问题,其中逻辑的事情被确认安装 bcmath,但在我的 Linode Debian 9 服务器中,命令
apt install php7.1-bcmath不起作用,有 3 条错误消息;
- E: Impossible to find the package php7.1-bcmath
- E: Impossible to find some package with glob "php7.1-bcmath"
- E: Impossible to find a package with the regular expression "php7.1-bcmath"
- E: 找不到包 php7.1-bcmath
- E: 无法找到一些带有 glob "php7.1-bcmath" 的包
- E:无法找到带有正则表达式“php7.1-bcmath”的包
The goals no meet with any combination of tips and trick, refreshing apt cache, change Debian's mirrored server, installing yum, so on...
目标没有达到任何提示和技巧的组合,刷新apt缓存,更改Debian的镜像服务器,安装yum,等等......
After some tentatives I had an illumination: modificating of /etc/apt/sources.listenabling the default Linode repository, then after an apt update(with no solution in the immediate), I have restored the /etc/apt/sources.list commenting out the Linode mirror sources again. Magically, after the new apt update the command now are working.
经过一些尝试后,我得到了启发:修改/etc/apt/sources.list启用默认的 Linode 存储库,然后在apt 更新后(立即没有解决方案),我恢复了 /etc/apt/sources.list再次注释掉 Linode 镜像源。神奇的是,在新的 apt 更新之后,命令现在正在运行。
By this I confirm: apt install php7.1-bcmathis the right command, but your Debian can need a kick in the ass
通过这一点我确认:apt install php7.1-bcmath是正确的命令,但你的 Debian 可能需要一个踢屁股

