“系统中缺少请求的PHP扩展名BCMATH”。
问候其他开发人员,
我正在尝试将Composer用于我最近启动的开发服务器上的PHP项目,并且由于某种原因无法做到。但是,我成功安装了作曲家,但是,当我尝试运行 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.
我假设这与PHP警告有关,我在运行 Composer时正确收到需要命令,但没有Google搜索结果将我带到正确的方向。
此外,我还提供了我的 /etc/php/7.0/cli/php.ini 该文件中错误的文件。
https://gist.github.com/anonymous/bc5bac59d684cbf575cef931ef36daf6 (I由于帖子的字符限制,因此无法在本文中包含该文件。)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
您可以使用函数 get_loaded_extensions 查看是否
bcmath模量已加载。或在终端
php -m
或php -m | grep name_of_the_modul
您可以根据所使用的操作系统进行安装:
ubuntu
sudo apt apt install php7.0 bcmath
centos> centos
yum安装bcmath bcmath
You can use function get_loaded_extensions to see if
bcmath
modul is loaded. Or in terminalphp -m
orphp -m | grep name_of_the_modul
You can install it depending on what OS you are using:
Ubuntu
sudo apt install php7.0-bcmath
CentOS
yum install bcmath
PHP 7.2
Debian - 杰西
像魅力一样工作:)
PHP 7.2
Debian - jessie
work like a charm :)
如果您使用的是Docker:
docker-php- ext-int-install bcmath bcmath
If you are using Docker:
docker-php-ext-install bcmath
在 Ubuntu 20.04 中
对于 php 7.4.3,
sudo apt install php7.4-bcmath
In Ubuntu 20.04
For php 7.4.3,
sudo apt install php7.4-bcmath
对于 php Centos 中的任何版本,使用
此解决方案对我有用
yum install php-bcmath
PHP 将采用计算机中安装的默认版本,搜索该包并安装它。
如果已经创建了文件composer.lock文件,请删除该文件,然后再次运行,
composer install
如果运行
composer update,
它将更新composer.json中安装的所有默认包这可能会给你带来问题。
For any version in php Centos use
This solution worked for me
yum install php-bcmath
PHP will take the default version installed in the machine, search for that package and install it.
Delete the file composer.lock file if that is already created and then run again,
composer install
If you run
composer update
it will update whatever default packages are installed in composer.json which might create problem for you.
对于php 7.1,以下对我有用:
For PHP 7.1, the following worked for me:
按类型检查您的 php 版本:
php --version
您将看到类似以下内容:
然后
sudo apt install phpX.X-bcmath
其中 XX 是 php 版本,因此对于此 将是sudo apt install php7.2-bcmath
^ 例如,在按类型
php -m | 检查模块是否存在后, grep bcmath
check your php version by type:
php --version
you will see something like this:
then
sudo apt install phpX.X-bcmath
where X.X is php version, so for this ^ example it will besudo apt install php7.2-bcmath
after this check if module existed or not by type
php -m | grep bcmath
php 7.2 如果您有其他版本,只需相应更改即可
对于
CentOS
对于
Ubuntu
php 7.2 if you have other version just change it accordingly
For
CentOS
For
Ubuntu
运行此命令,希望它能有效
Run this command, hope it will works
希望这能解决这个问题。
hope this will fix the problem.
这里奇怪的事情
大个月前,我以相同的方式安装了所有PHP版本。在这里是PHP的4个相同配置的版本:5.6、7.0、7.1、7.2,具有相同的扩展(当做出可能时)。
奇怪的是, bcmath 均为所有PHP版本(不包括7.1)。
在解决方案搜索中,我在此问题中到达这里,逻辑的内容已确认安装BCMATH,但在我的Linode Debian 9服务器中
apt安装php7.1-bcmath
不起作用,带有3条错误消息;
“通过提示和技巧的任何组合,刷新的APT缓存,更改Debian的镜像服务器,安装百胜,等等...
在一些暂时我有照明之后:修改 /etc/etp/apt/sources .LIST 启用默认的Linode存储库,然后在 apt apt Update 之后(立即没有解决方案),我还恢复了/ett /apt/sources.list再次评论linode镜像源。神奇的是,在新的APT更新后,该命令现在正在工作。
我确认: apt install php7.1-bcmath 是正确的命令,但是您的debian可能需要踢屁股
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 bcmath is 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-bcmath
doesn't work, with 3 error messages;
The goals no meet with any combination of tips and trick, refreshing apt cache, change Debian's mirrored server, installing yum, so on...
After some tentatives I had an illumination: modificating of /etc/apt/sources.list enabling 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.
By this I confirm: apt install php7.1-bcmath is the right command, but your Debian can need a kick in the ass
注意:这将在Ubuntu服务器上使用。
首先导航到服务器的根目录:
通过在软件包名称中指定特定的PHP版本,例如PHP 7.4:
成功安装软件包后,重新启动Apache Web服务器以激活更改:
Note: This will work on Ubuntu servers.
Start by navigating to the server's root directory:
Install a particular PHP version, for example, PHP 7.4, by specifying it in the package name:
After successfully installing the package, restart your Apache web server to activate the changes:
使用此命令安装,这对我有用
Install with this command, thats work for me
我尝试了下面的软件包,它在PHP版本5.6中使用
I tried below package and it worked in Php version 5.6
对于那些已经尝试安装BC-MATH和Commoser的人来说,这是错误的。
尝试此命令
肯定会起作用
For those who have already tried installing bc-math and still composer is giving errors.
Try this command
It will definitely work
一个简单的 apt-get install php-bcmath 就可以解决 php 8.3 的问题
A simple
apt-get install php-bcmath
does the trick for php 8.3