It's pretty anoying to implement something special that requires function related to math in your task and that suddenly such feature is available locally but not on your production server. The bcmath extension help you to avoid arbitrary precision errors in PHP, the functions included in this extension allow you to run calculations on numbers of any size and precision because they are represented as strings.
In order to install bcmath in CentOS, you will need to follow these steps:
1. Install with the cli
You can install the bcmath extension with the command line via yum:
yum install php-bcmath
Yum will install automatically the bcmath extension associated to the version of PHP that you have installed, in our case we had the PHP 5.3 version running. Once you execute the command you will get an output similar to:
yum install php-bcmath Loaded plugins: priorities Setting up Install Process PLESK_17_5_3-extras | 2.9 kB 00:00 PLESK_17_PHP56 | 2.9 kB 00:00 base | 3.7 kB 00:00 extras | 3.4 kB 00:00 plesk-migrator | 2.9 kB 00:00 plesk-migrator-tp | 2.9 kB 00:00 plesk11-base | 2.9 kB 00:00 plesk11-thirdparty | 2.9 kB 00:00 plesk11-updates | 2.9 kB 00:00 http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml: [Errno 14] P YCURL ERROR 6 - "Couldn't resolve host 'apt.sw.be'" Trying other mirror. rpmforge | 1.9 kB 00:00 updates | 3.4 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package php-bcmath.x86_64 0:5.3.3-49.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: php-bcmath x86_64 5.3.3-49.el6 base 40 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 40 k Installed size: 29 k Is this ok [y/N]: y Downloading Packages: php-bcmath-5.3.3-49.el6.x86_64.rpm | 40 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : php-bcmath-5.3.3-49.el6.x86_64 1/1 Verifying : php-bcmath-5.3.3-49.el6.x86_64 1/1 Installed: php-bcmath.x86_64 0:5.3.3-49.el6 Complete!
Remember that the command will automatically install the version associated to your current version of PHP (available from the command line).
2. Restart apache/httpd service
After installing the extension, you need to restart the apache service using the following command:
service httpd restart
Happy coding !
Become a more social person