RT.需要用PHP进行一些数学计算,但是PHP提供的数学库函数不够用,所以下载安装gmp插件。
第一步 下载GMP library并编码
参考链接:http://php.net/manual/en/gmp.requirements.php
下载地址: https://gmplib.org/#DOWNLOAD
下载命令:wget
解压命令:tar
编码命令:/configure && make && make install
第二步 重新编译Directadmin PHP
参考链接:http://help.directadmin.com/item.php?id=252
1、配置customcustombuild
cd /usr/local/directadmin/custombuild mkdir -p custom/ap2 cp -fp configure/ap2/configure.php55 custom/ap2/configure.php55
注意:我在安装Directadmin时选择的是CustomBuild 2.0版本,且php版本为5.5,故拷贝的配置文件为configure.php55.
2、配置custom/ap2/configure.php55文件
配置方法:添加所需要编译的--with-module 组建名称到该文件中。除了最后一行省略‘\’符号之外,其它行都应该保留‘\’符号。(有‘\’符号目的表示继续查找)
我的custom/ap2/configure.php55配置完成如下:
#!/bin/sh
./configure
--with-apxs2
--with-config-file-scan-dir=/usr/local/lib/php.conf.d
--with-curl=/usr/local/lib
--with-gd
--enable-gd-native-ttf
--with-gettext
--with-jpeg-dir=/usr/local/lib
--with-freetype-dir=/usr/local/lib
--with-libxml-dir=/usr/local/lib
--with-kerberos
--with-openssl
--with-mcrypt
--with-mhash
--with-mysql=mysqlnd
--with-mysql-sock=/var/lib/mysql/mysql.sock
--with-mysqli=mysqlnd
--with-pcre-regex=/usr/local
--with-pdo-mysql=mysqlnd
--with-pear
--with-gmp
--with-png-dir=/usr/local/lib
--with-xsl
--with-zlib
--with-zlib-dir=/usr/local/lib
--enable-zip
--with-iconv=/usr/local
--enable-bcmath
--enable-calendar
--enable-ftp
--enable-sockets
--enable-soap
--enable-mbstring
--with-icu-dir=/usr/local/icu
--enable-intl
3、编译PHP
./build php n (n表示需要php版本,我的是55)
4、重启apache
RedHat: /sbin/service httpd restart FreeBSD: /usr/local/etc/rc.d/httpd restart
4、应用设置
./build used_configs
常见错误如:/usr/local/directadmin/custombuild/custom/ap2/configure.php5: line 32: --with-module: command not found
第三步 配置php.ini文件
1、添加
extension=gmp.so
到php.ini文件中
2、重启apache
第四部 验证
1、验证方法是,创建以下内容文件并调用。出现long long long int似的数字,代表安装成功
function fact($x)
{
$return = 1;
for ($i=2; $i <= $x; $i++) {
$return = gmp_mul($return, $i);
}
return $return;
}
echo gmp_strval(fact(1000)) . "n";
2、验证方法二
创建phpinfo文件,如果出现gmp组建,并能看见gmp版本号,表示安装成功
phpinfo();