本文概述
在任务中实现一些需要与数学相关的功能的特殊功能, 而突然之间这种功能在本地可用, 而在生产服务器上却不可用, 这很烦人。 bcmath扩展帮助你避免PHP中的任意精度错误, 此扩展中包含的函数使你可以对任何大小和精度的数字进行计算, 因为它们以字符串表示。
为了在CentOS中安装bcmath, 你将需要遵循以下步骤:
1.使用cli安装
你可以通过yum通过命令行安装bcmath扩展:
yum install php-bcmath
Yum将自动安装与你已安装的PHP版本相关的bcmath扩展名, 在本例中, 我们正在运行PHP 5.3版本。执行命令后, 你将获得类似于以下内容的输出:
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!
请记住, 该命令将自动安装与你当前的PHP版本相关的版本(可从命令行获得)。
2.重新启动apache / httpd服务
安装扩展程序后, 需要使用以下命令重新启动apache服务:
service httpd restart
编码愉快!
评论前必须登录!
注册