How to install bcmath in Ubuntu for PHP 7.1
Asked Answered
E

4

29

I'm using an Ubuntu 16 server for testing with php7.1. One of my app uses bcadd function. I know that I need to install bcmath module for that but I'm unable to find php7.1-bcmath. When I tried to install apt install php-bcmath, it simply installed php7.0-bcmath module.

I was unable to find php7.1-bcmath module anywhere to install on my server. Does anybody has an idea?

apt install php7.1-bcmath returned following,

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'
Endo answered 11/5, 2017 at 2:36 Comment(0)
E
64

Answering my own question. Managed to fix this issue with following repo update.

add-apt-repository ppa:ondrej/php
apt update
apt install php7.1-bcmath

Restart apache and all good to go.

Endo answered 11/5, 2017 at 3:8 Comment(2)
How could you install php7.1 originally if you don't have a ppa with it? o_OIntercellular
Note that as of 2020, you should be installing the PHP 7.4 version, apt install php7.4-bcmath.Tanika
L
15

install this : https://packages.ubuntu.com/fr/artful/amd64/php7.1-bcmath/download

add this :

deb http://security.ubuntu.com/ubuntu artful-security main universe

to /etc/apt/sources.list

$ sudo apt update

$ sudo apt install php7.1-bcmath
Longwinded answered 11/5, 2017 at 2:37 Comment(2)
security.ubuntu.com/ubuntu/dists/artful-security/universe/… -> 404 Not Found. Didn't worked for meCicala
Thanks this works for me on 7.3 i used - sudo apt install php7.3-bcmathHemocyte
A
13

Those who are looking for Ubuntu 20.04:

sudo apt install php-bcmath

It will automatically install the bcmath compatible with your version of PHP.

In order to install the specific version of bcmath for php, you can use following command:

sudo apt install php7.x-bcmath
Aliciaalick answered 14/5, 2021 at 11:44 Comment(0)
C
1

For Ubuntu 16.04: Add this ppa http://ppa.launchpad.net/jczaplicki/xenial-php74-temp/ubuntu Open synaptic, and then uninstall any bcmath module already installed. Then reinstall php7.4 and php7.4-xxx modules

Cacogenics answered 28/1, 2022 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.