17

I've seen a PHP BC-MATH installation for YUM but not apt-get. Does one know of a working apt-get solution?

Unfortunately, from this SO thread, apt-get install php5-bcmath gives the error Unable to locate package php5-bcmath.

tim peterson
  • 2,285

5 Answers5

20

If you use Ondřej Surý's PHP PPA you can install bcmath with either

sudo apt install php5.6-bcmath
sudo apt install php7.0-bcmath
sudo apt install php-bcmath

There are instructions on the PPA page on how to add this source to Ubuntu.

Thomas
  • 301
14

If you want to install bcmath extension, Please try below commands :

For PHP5.6

sudo apt install php5.6-bcmath

For PHP7.0

sudo apt install php7.0-bcmath

For other PHP versions

sudo apt install php-bcmath
Zanna
  • 70,465
  • I found that sudo apt install php-bcmath worked on PHP7.0 too (it automatically gets the 7.0 one) and if you do that then it likely works better when you later upgrade PHP. – AdamS Jun 16 '18 at 09:42
9

php5-fpm in Precise and later (as well as the Apache equivalent libapache2-mod-php5 package for Apache built-in PHP5 modules) is listed as having bcmath built in to it as an included module. This information is written in the package description file (debian/control) in the package itself when extracted and being viewed as the raw source package, containing source code and a debian/ directory which contains directives to debian build systems to build packages.

Given that the php5-fpm system as well as the libapache2-mod-php5 plugin for Apache has it included by default, I don't think you have to install any additional packages or plugins to get bcmath.


In case my word isn't enough and you want to see the evidence of this, then...

This is a list of links to the debian/rules file which defines which extensions are enabled in PHP at the time of building for each currently supported release at the time of this post (there may be updates after this post that are not reflected here). You can click each of these to see the ./configure arguments that are passed to php5 during the building process for those packages. Note that this will show you specifically where bcmath is enabled for all php5 binaries in those releases:

Thomas Ward
  • 74,764
4
sudo apt-get install php5.5-bcmath

worked for me.

Videonauth
  • 33,355
  • 17
  • 105
  • 120
DriesKn
  • 41
  • 2
    At least on 16.04 this package doesn't exist in the default sources. What exists is php-bcmath – dufte Jun 08 '16 at 07:30
  • For 16.04 I used `sudo apt-get install php7.0-bcmath' and it worked. I'm presuming it will work for any given version of php (though I haven't tested). – bmacnaughton Aug 15 '16 at 17:38
0

If you are using Docker run this command in your PHP container shell:

docker-php-ext-install bcmath

Or add this line in your Dockerfile:

RUN docker-php-ext-install bcmath
campsjos
  • 101