如何在Ubuntu for PHP 7.1中安装bcmath

Vaj*_*tha 10 php bcmath ubuntu-server ubuntu-16.04 php-7.1

我正在使用Ubuntu 16服务器进行测试php7.1.我的一个应用程序使用bcadd功能.我知道我需要为此安装bcmath模块,但我无法找到php7.1-bcmath.当我尝试安装时apt install php-bcmath,它只是安装了php7.0-bcmath模块.

我无法php7.1-bcmath在我的服务器上随处找到模块.有人有想法吗?

apt install php7.1-bcmath 返回以下,

E: Unable to locate package php7.1-bcmath

E: Couldn't find any package by glob 'php7.1-bcmath'

E: Couldn't find any package by regex 'php7.1-bcmath'
Run Code Online (Sandbox Code Playgroud)

Vaj*_*tha 31

回答我自己的问题.通过以下repo更新管理以解决此问题.

add-apt-repository ppa:ondrej/php
apt update
apt install php7.1-bcmath
Run Code Online (Sandbox Code Playgroud)

重启apache,一切顺利.

  • 请注意,截至 2020 年,您应该安装 PHP 7.4 版本“apt install php7.4-bcmath”。 (3认同)

Ani*_*ota 13

那些正在寻找 Ubuntu 20.04 的人:

sudo apt install php-bcmath
Run Code Online (Sandbox Code Playgroud)

它将自动安装与您的 PHP 版本兼容的 bcmath。

为了安装特定版本的 bcmath for php,您可以使用以下命令:

sudo apt install php7.x-bcmath
Run Code Online (Sandbox Code Playgroud)


Ana*_*ine 6

安装这个:https : //packages.ubuntu.com/fr/artful/amd64/php7.1-bcmath/download

添加:

deb http://security.ubuntu.com/ubuntu artful-security main universe
Run Code Online (Sandbox Code Playgroud)

到/etc/apt/sources.list

$ sudo apt update

$ sudo apt install php7.1-bcmath
Run Code Online (Sandbox Code Playgroud)