PHP: how to install bcmath module on CentOS


Read more: How to install repository remi-safe on CentOS

Step 1: find php-bcmath package

[root@tutorialspots /]# yum list|grep bcmath
php-bcmath.x86_64                          7.1.22-1.el7.remi          remi-php71
php54-php-bcmath.x86_64                    5.4.45-15.el7.remi         remi-safe
php55-php-bcmath.x86_64                    5.5.38-9.el7.remi          remi-safe
php56-php-bcmath.x86_64                    5.6.38-1.el7.remi          remi-safe
php70-php-bcmath.x86_64                    7.0.32-1.el7.remi          remi-safe
php71-php-bcmath.x86_64                    7.1.22-1.el7.remi          remi-safe
php72-php-bcmath.x86_64                    7.2.10-1.el7.remi          remi-safe
php73-php-bcmath.x86_64                    7.3.0~rc1-1.el7.remi       remi-safe

Step 2: find php version

[root@tutorialspots ~]# php -v
PHP 7.1.20 (cli) (built: Jul 19 2018 10:10:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.20, Copyright (c) 1999-2018, by Zend Technologies

Step 3: install php-bcmath
yum install php-bcmath -y

[root@CentOS-75-64-minimal /]# yum install php-bcmath -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                     |  29 kB     00:00
 * base: mirror.wiuwiu.de
 * epel: mirror.wiuwiu.de
 * extras: mirror.wiuwiu.de
 * remi-php71: mirror.23media.de
 * remi-safe: mirror.23media.de
 * updates: mirror.wiuwiu.de
base                                                     | 3.6 kB     00:00
epel                                                     | 3.2 kB     00:00
extras                                                   | 3.4 kB     00:00
mariadb                                                  | 2.9 kB     00:00
nginx                                                    | 2.9 kB     00:00
nodesource                                               | 2.5 kB     00:00
remi-php71                                               | 2.9 kB     00:00
remi-safe                                                | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/5): extras/7/x86_64/primary_db                          | 187 kB   00:00
epel/x86_64/primary            FAILED
http://mirror.23media.de/epel/7/x86_64/repodata/6772c88ca398a0090eec24bb3ee26c34
490d0ac5816d1a594fb192fa4792c262-primary.xml.gz: [Errno 14] HTTP Error 404 - Not
 Found
Trying other mirror.
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.cent
os.org/.

(2/5): epel/x86_64/updateinfo                              | 943 kB   00:00
(3/5): remi-php71/primary_db                               | 222 kB   00:00
(4/5): epel/x86_64/primary                                 | 3.6 MB   00:00
(5/5): remi-safe/primary_db                                | 1.3 MB   00:00
epel                                                                12687/12687
Resolving Dependencies
--> Running transaction check
---> Package php-bcmath.x86_64 0:7.1.22-1.el7.remi will be installed
--> Processing Dependency: php-common(x86-64) = 7.1.22-1.el7.remi for package: p
hp-bcmath-7.1.22-1.el7.remi.x86_64
--> Running transaction check
---> Package php-common.x86_64 0:7.1.20-1.el7.remi will be updated
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-mcrypt-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-pdo-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-json-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-cli-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-gmp-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-soap-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-ldap-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-fpm-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-enchant-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-gd-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-mbstring-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-process-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-opcache-7.1.20-1.el7.remi.x86_64
--> Processing Dependency: php-common(x86-64) = 7.1.20-1.el7.remi for package: p
hp-xml-7.1.20-1.el7.remi.x86_64
---> Package php-common.x86_64 0:7.1.22-1.el7.remi will be an update
--> Running transaction check
---> Package php.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-cli.x86_64 0:7.1.20-1.el7.remi will be updated
--> Processing Dependency: php-cli(x86-64) = 7.1.20-1.el7.remi for package: php-
devel-7.1.20-1.el7.remi.x86_64
---> Package php-cli.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-enchant.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-enchant.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-fpm.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-fpm.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-gd.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-gd.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-gmp.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-gmp.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-json.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-json.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-ldap.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-ldap.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-mbstring.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-mbstring.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-mcrypt.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-mcrypt.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-opcache.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-opcache.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-pdo.x86_64 0:7.1.20-1.el7.remi will be updated
--> Processing Dependency: php-pdo(x86-64) = 7.1.20-1.el7.remi for package: php-
mysqlnd-7.1.20-1.el7.remi.x86_64
---> Package php-pdo.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-process.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-process.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-soap.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-soap.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-xml.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-xml.x86_64 0:7.1.22-1.el7.remi will be an update
--> Running transaction check
---> Package php-devel.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-devel.x86_64 0:7.1.22-1.el7.remi will be an update
---> Package php-mysqlnd.x86_64 0:7.1.20-1.el7.remi will be updated
---> Package php-mysqlnd.x86_64 0:7.1.22-1.el7.remi will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch         Version                 Repository        Size
================================================================================
Installing:
 php-bcmath         x86_64       7.1.22-1.el7.remi       remi-php71        69 k
Updating for dependencies:
 php                x86_64       7.1.22-1.el7.remi       remi-php71       3.0 M
 php-cli            x86_64       7.1.22-1.el7.remi       remi-php71       4.6 M
 php-common         x86_64       7.1.22-1.el7.remi       remi-php71       1.0 M
 php-devel          x86_64       7.1.22-1.el7.remi       remi-php71       1.1 M
 php-enchant        x86_64       7.1.22-1.el7.remi       remi-php71        49 k
 php-fpm            x86_64       7.1.22-1.el7.remi       remi-php71       1.6 M
 php-gd             x86_64       7.1.22-1.el7.remi       remi-php71        75 k
 php-gmp            x86_64       7.1.22-1.el7.remi       remi-php71        67 k
 php-json           x86_64       7.1.22-1.el7.remi       remi-php71        60 k
 php-ldap           x86_64       7.1.22-1.el7.remi       remi-php71        66 k
 php-mbstring       x86_64       7.1.22-1.el7.remi       remi-php71       578 k
 php-mcrypt         x86_64       7.1.22-1.el7.remi       remi-php71        58 k
 php-mysqlnd        x86_64       7.1.22-1.el7.remi       remi-php71       231 k
 php-opcache        x86_64       7.1.22-1.el7.remi       remi-php71       241 k
 php-pdo            x86_64       7.1.22-1.el7.remi       remi-php71       123 k
 php-process        x86_64       7.1.22-1.el7.remi       remi-php71        77 k
 php-soap           x86_64       7.1.22-1.el7.remi       remi-php71       206 k
 php-xml            x86_64       7.1.22-1.el7.remi       remi-php71       209 k

Transaction Summary
================================================================================
Install  1 Package
Upgrade             ( 18 Dependent packages)

Total download size: 13 M
Downloading packages:
No Presto metadata available for remi-php71
(1/19): php-bcmath-7.1.22-1.el7.remi.x86_64.rpm            |  69 kB   00:00
(2/19): php-7.1.22-1.el7.remi.x86_64.rpm                   | 3.0 MB   00:00
(3/19): php-common-7.1.22-1.el7.remi.x86_64.rpm            | 1.0 MB   00:00
(4/19): php-cli-7.1.22-1.el7.remi.x86_64.rpm               | 4.6 MB   00:00
(5/19): php-enchant-7.1.22-1.el7.remi.x86_64.rpm           |  49 kB   00:00
(6/19): php-devel-7.1.22-1.el7.remi.x86_64.rpm             | 1.1 MB   00:00
(7/19): php-gd-7.1.22-1.el7.remi.x86_64.rpm                |  75 kB   00:00
(8/19): php-gmp-7.1.22-1.el7.remi.x86_64.rpm               |  67 kB   00:00
(9/19): php-json-7.1.22-1.el7.remi.x86_64.rpm              |  60 kB   00:00
(10/19): php-ldap-7.1.22-1.el7.remi.x86_64.rpm             |  66 kB   00:00
(11/19): php-fpm-7.1.22-1.el7.remi.x86_64.rpm              | 1.6 MB   00:00
(12/19): php-mbstring-7.1.22-1.el7.remi.x86_64.rpm         | 578 kB   00:00
(13/19): php-mcrypt-7.1.22-1.el7.remi.x86_64.rpm           |  58 kB   00:00
(14/19): php-mysqlnd-7.1.22-1.el7.remi.x86_64.rpm          | 231 kB   00:00
(15/19): php-opcache-7.1.22-1.el7.remi.x86_64.rpm          | 241 kB   00:00
(16/19): php-pdo-7.1.22-1.el7.remi.x86_64.rpm              | 123 kB   00:00
(17/19): php-process-7.1.22-1.el7.remi.x86_64.rpm          |  77 kB   00:00
(18/19): php-xml-7.1.22-1.el7.remi.x86_64.rpm              | 209 kB   00:00
(19/19): php-soap-7.1.22-1.el7.remi.x86_64.rpm             | 206 kB   00:00
--------------------------------------------------------------------------------
Total                                               28 MB/s |  13 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : php-common-7.1.22-1.el7.remi.x86_64                         1/37
  Updating   : php-json-7.1.22-1.el7.remi.x86_64                           2/37
  Updating   : php-cli-7.1.22-1.el7.remi.x86_64                            3/37
  Updating   : php-pdo-7.1.22-1.el7.remi.x86_64                            4/37
  Updating   : php-mysqlnd-7.1.22-1.el7.remi.x86_64                        5/37
  Updating   : php-7.1.22-1.el7.remi.x86_64                                6/37
  Updating   : php-devel-7.1.22-1.el7.remi.x86_64                          7/37
  Updating   : php-enchant-7.1.22-1.el7.remi.x86_64                        8/37
  Updating   : php-ldap-7.1.22-1.el7.remi.x86_64                           9/37
  Installing : php-bcmath-7.1.22-1.el7.remi.x86_64                        10/37
  Updating   : php-mcrypt-7.1.22-1.el7.remi.x86_64                        11/37
  Updating   : php-process-7.1.22-1.el7.remi.x86_64                       12/37
  Updating   : php-xml-7.1.22-1.el7.remi.x86_64                           13/37
  Updating   : php-fpm-7.1.22-1.el7.remi.x86_64                           14/37
  Updating   : php-gd-7.1.22-1.el7.remi.x86_64                            15/37
  Updating   : php-soap-7.1.22-1.el7.remi.x86_64                          16/37
  Updating   : php-opcache-7.1.22-1.el7.remi.x86_64                       17/37
  Updating   : php-mbstring-7.1.22-1.el7.remi.x86_64                      18/37
  Updating   : php-gmp-7.1.22-1.el7.remi.x86_64                           19/37
  Cleanup    : php-7.1.20-1.el7.remi.x86_64                               20/37
  Cleanup    : php-devel-7.1.20-1.el7.remi.x86_64                         21/37
  Cleanup    : php-cli-7.1.20-1.el7.remi.x86_64                           22/37
  Cleanup    : php-gmp-7.1.20-1.el7.remi.x86_64                           23/37
  Cleanup    : php-mbstring-7.1.20-1.el7.remi.x86_64                      24/37
  Cleanup    : php-opcache-7.1.20-1.el7.remi.x86_64                       25/37
  Cleanup    : php-soap-7.1.20-1.el7.remi.x86_64                          26/37
  Cleanup    : php-mysqlnd-7.1.20-1.el7.remi.x86_64                       27/37
  Cleanup    : php-pdo-7.1.20-1.el7.remi.x86_64                           28/37
  Cleanup    : php-gd-7.1.20-1.el7.remi.x86_64                            29/37
  Cleanup    : php-fpm-7.1.20-1.el7.remi.x86_64                           30/37
  Cleanup    : php-xml-7.1.20-1.el7.remi.x86_64                           31/37
  Cleanup    : php-process-7.1.20-1.el7.remi.x86_64                       32/37
  Cleanup    : php-mcrypt-7.1.20-1.el7.remi.x86_64                        33/37
  Cleanup    : php-ldap-7.1.20-1.el7.remi.x86_64                          34/37
  Cleanup    : php-enchant-7.1.20-1.el7.remi.x86_64                       35/37
  Cleanup    : php-json-7.1.20-1.el7.remi.x86_64                          36/37
  Cleanup    : php-common-7.1.20-1.el7.remi.x86_64                        37/37
  Verifying  : php-7.1.22-1.el7.remi.x86_64                                1/37
  Verifying  : php-cli-7.1.22-1.el7.remi.x86_64                            2/37
  Verifying  : php-enchant-7.1.22-1.el7.remi.x86_64                        3/37
  Verifying  : php-ldap-7.1.22-1.el7.remi.x86_64                           4/37
  Verifying  : php-bcmath-7.1.22-1.el7.remi.x86_64                         5/37
  Verifying  : php-mcrypt-7.1.22-1.el7.remi.x86_64                         6/37
  Verifying  : php-devel-7.1.22-1.el7.remi.x86_64                          7/37
  Verifying  : php-process-7.1.22-1.el7.remi.x86_64                        8/37
  Verifying  : php-json-7.1.22-1.el7.remi.x86_64                           9/37
  Verifying  : php-common-7.1.22-1.el7.remi.x86_64                        10/37
  Verifying  : php-xml-7.1.22-1.el7.remi.x86_64                           11/37
  Verifying  : php-fpm-7.1.22-1.el7.remi.x86_64                           12/37
  Verifying  : php-gd-7.1.22-1.el7.remi.x86_64                            13/37
  Verifying  : php-mysqlnd-7.1.22-1.el7.remi.x86_64                       14/37
  Verifying  : php-soap-7.1.22-1.el7.remi.x86_64                          15/37
  Verifying  : php-opcache-7.1.22-1.el7.remi.x86_64                       16/37
  Verifying  : php-mbstring-7.1.22-1.el7.remi.x86_64                      17/37
  Verifying  : php-gmp-7.1.22-1.el7.remi.x86_64                           18/37
  Verifying  : php-pdo-7.1.22-1.el7.remi.x86_64                           19/37
  Verifying  : php-pdo-7.1.20-1.el7.remi.x86_64                           20/37
  Verifying  : php-enchant-7.1.20-1.el7.remi.x86_64                       21/37
  Verifying  : php-cli-7.1.20-1.el7.remi.x86_64                           22/37
  Verifying  : php-common-7.1.20-1.el7.remi.x86_64                        23/37
  Verifying  : php-mcrypt-7.1.20-1.el7.remi.x86_64                        24/37
  Verifying  : php-json-7.1.20-1.el7.remi.x86_64                          25/37
  Verifying  : php-devel-7.1.20-1.el7.remi.x86_64                         26/37
  Verifying  : php-ldap-7.1.20-1.el7.remi.x86_64                          27/37
  Verifying  : php-soap-7.1.20-1.el7.remi.x86_64                          28/37
  Verifying  : php-fpm-7.1.20-1.el7.remi.x86_64                           29/37
  Verifying  : php-process-7.1.20-1.el7.remi.x86_64                       30/37
  Verifying  : php-opcache-7.1.20-1.el7.remi.x86_64                       31/37
  Verifying  : php-mysqlnd-7.1.20-1.el7.remi.x86_64                       32/37
  Verifying  : php-gmp-7.1.20-1.el7.remi.x86_64                           33/37
  Verifying  : php-xml-7.1.20-1.el7.remi.x86_64                           34/37
  Verifying  : php-gd-7.1.20-1.el7.remi.x86_64                            35/37
  Verifying  : php-mbstring-7.1.20-1.el7.remi.x86_64                      36/37
  Verifying  : php-7.1.20-1.el7.remi.x86_64                               37/37

Installed:
  php-bcmath.x86_64 0:7.1.22-1.el7.remi

Dependency Updated:
  php.x86_64 0:7.1.22-1.el7.remi
  php-cli.x86_64 0:7.1.22-1.el7.remi
  php-common.x86_64 0:7.1.22-1.el7.remi
  php-devel.x86_64 0:7.1.22-1.el7.remi
  php-enchant.x86_64 0:7.1.22-1.el7.remi
  php-fpm.x86_64 0:7.1.22-1.el7.remi
  php-gd.x86_64 0:7.1.22-1.el7.remi
  php-gmp.x86_64 0:7.1.22-1.el7.remi
  php-json.x86_64 0:7.1.22-1.el7.remi
  php-ldap.x86_64 0:7.1.22-1.el7.remi
  php-mbstring.x86_64 0:7.1.22-1.el7.remi
  php-mcrypt.x86_64 0:7.1.22-1.el7.remi
  php-mysqlnd.x86_64 0:7.1.22-1.el7.remi
  php-opcache.x86_64 0:7.1.22-1.el7.remi
  php-pdo.x86_64 0:7.1.22-1.el7.remi
  php-process.x86_64 0:7.1.22-1.el7.remi
  php-soap.x86_64 0:7.1.22-1.el7.remi
  php-xml.x86_64 0:7.1.22-1.el7.remi

Complete!

Now you can see file bcmath.so and 20-bcmath.ini

[root@tutorialspots /]# find -name bcmath.so
./usr/lib64/php-zts/modules/bcmath.so
./usr/lib64/php/modules/bcmath.so
[root@tutorialspots /]# find -name *bcmath.ini
./etc/php.d/20-bcmath.ini
./etc/php-zts.d/20-bcmath.ini

Step 4 (optinal) if not exists bcmath.so in /usr/lib64/php/modules/ : create symbolic links if there aren’t these files in folder /usr/lib64/php/modules/ and /etc/php.d/

ln -s /opt/remi/php71/root/usr/lib64/php/modules/bcmath.so /usr/lib64/php/modules/bcmath.so
ln -s /etc/opt/remi/php71/php.d/20-bcmath.ini /etc/php.d/20-bcmath.ini

Step 5 (optinal): restart php-fpm if not exist bcmath module in php -m

service php-fpm restart

Done, check php -m

Leave a Reply