How to install bcmath in Ubuntu for PHP 7.1

Vajira Lasantha picture Vajira Lasantha · May 11, 2017 · Viewed 57.5k times · Source

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'

Answer

Vajira Lasantha picture Vajira Lasantha · May 11, 2017

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.