Drupal 8 - Commerce Module - 未找到BC math PHP扩展

时间:2017-06-22 11:31:26

标签: drupal-8 php-extension drupal-commerce commerce bcmath

我正在尝试在Drupal 8中安装Commerce模块但是我收到错误'BC math PHP extension not found'。

我已经搜索过这个问题并尝试了不同的东西,例如通过添加'bcmath.scale = 2'来编辑PHP.ini但是我仍然收到错误消息。

任何帮助都将不胜感激,谢谢。

3 个答案:

答案 0 :(得分:4)

只需为您的php版本安装 bcmath 插件,无需(重新)构建php,如接受的答案所述

# get php version
php -v

# install bcmath based on your version lets assume php 7.1
# for ubuntu
sudo apt install php7.1-bcmath
# for centos 
yum install bcmath

# restart apache 
sudo systemctl restart apache2

使用composer

安装商业或商业kickstart时会出现上述问题

答案 1 :(得分:0)

该错误消息很可能表明您的PHP未使用bcmath支持构建。 --enable-bcmath扩展名通常不作为插件扩展名提供,但在使用bcmath选项编译时会内置到PHP中。 Here是指向安装phpinfo();的相关文档的链接(基本上说,您必须在编译时对其进行配置)。

要检查您的PHP,请在测试页中运行bcmath并搜索$ php -i | grep -i bcmath 。您也可以使用CLI(如果您的Web服务器和CLI来自同一版本)使用

之类的命令执行此操作
BCMath support => enabled

您应该看到类似于bcmath的输出行,或者如果从您的Web服务器的PHP中查看HTML结果,则表示bcmath已启用。

不幸的是,似乎安装public class Customer { /// <summary> /// Name of customer /// </summary> public string Name { get; set; } /// <summary> /// Sex of customer /// </summary> public bool Sex { get; set; } /// <summary> /// List of favourite foods /// </summary> public List<string> FavouriteFoods { get; set; } } 的唯一方法是重建PHP以获得该支持或安装预先构建的版本。我不熟悉你的设置,所以我不能再推测了。

答案 2 :(得分:0)

为 PHP 7.2 添加 BC MATH 扩展

如果您收到此 (https://prnt.sc/sehmd5) 错误,请使用 vagrant ssh 运行以下命令

在 vagrant ssh 的根目录中运行这些命令

  1. sudo add-apt-repository ppa:ondrej/php
  2. sudo apt 更新
  3. sudo apt install php7.2-bcmath
  4. 服务 apache2 重启
  5. 然后打开 php.ini 并搜索 bcmath
  6. 如果 bcmath scale 为 0,则将其更改为 2
  7. 重启php
  8. 重启 Apache
  9. 硬重新加载网站
  10. 安装所需的模块

与任何版本的 PHP 类似,您只需要在第三个命令中更改 PHP 版本即可。