本文主要是介绍增加php的amqp扩展,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前言:本脚本仅仅适用于通过宝塔面板安装的php,使用的是amqp.1.10.2,仅仅支持php5.6以上,pear1.4版本以上
目前只测试了CentOS7的系统,后续会对此进行兼容其他操作系统
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#说明:amqp.1.10.2仅适用于php5.6版本以上,pear1.4版本以上public_file=/www/server/panel/install/public.sh
[ ! -f $public_file ] && wget -O $public_file http://download.bt.cn/install/public.sh -T 5;publicFileMd5=$(md5sum ${public_file}|awk '{print $1}')
md5check="66c89de255c11b64d5215be67dc4fdc6"
[ "${publicFileMd5}" != "${md5check}" ] && wget -O $public_file http://download.bt.cn/install/public.sh -T 5;. $public_file
download_Url=$NODE_URL
srcPath='/root';#安装amqp需要安装librabbitmq依赖
System_Lib(){if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ] ; theninstallPack="librabbitmq-devel"fi[ "${installPack}" != "" ] && ${PM} install ${installPack} -y
}
#amqp.1.10.2适合使用的php版本
Ext_Path(){case "${version}" in '56')extFile="/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/amqp.so";;'70')extFile="/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/amqp.so";;'71')extFile="/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/amqp.so";;'72')extFile="/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/amqp.so";;'73')extFile='/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/amqp.so';;'74')extFile='/www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902/amqp.so';;esac
}Install_librabbitmq()
{ #下载smbclient客户端cd $srcPathwget https://pecl.php.net/get/amqp-1.10.2.tgztar zxvf amqp-1.10.2.tgzcd $srcPath/amqp-1.10.2/www/server/php/$version/bin/phpize./configure --with-php-config=/www/server/php/$version/bin/php-config make && make installif [ ! -d /www/server/php/$version ];thenreturn;fiif [ ! -f "/www/server/php/$version/bin/php-config" ];thenecho "php-$vphp 未安装,请选择其它版本!"echo "php-$vphp not install, Plese select other version!"returnfiisInstall=`cat /www/server/php/$version/etc/php.ini|grep 'amqp.so'`if [ "${isInstall}" != "" ];thenecho "php-$vphp 已安装过amqp,请选择其它版本!"echo "php-$vphp is already install amqp, Plese select other version!"returnfiecho "extension=amqp.so" >> /www/server/php/$version/etc/php.ini/etc/init.d/php-fpm-$version reloadecho '==============================================='echo 'successful!'/etc/init.d/php-fpm-$version reloadrm -rf $srcPath/amqp*/www/server/php/${version}/bin/php -m|grep amqp
}Uninstall_librabbitmq()
{if [ ! -d /www/server/php/$version ];thenrm -rf $srcPath/amqp*fiif [ ! -f "/www/server/php/$version/bin/php-config" ];thenecho "php-$vphp 未安装,请选择其它版本!"echo "php-$vphp not install, Plese select other version!"returnfiisInstall=`cat /www/server/php/$version/etc/php.ini|grep 'amqp.so'`if [ "${isInstall}" = "" ];thenecho "php-$vphp 未安装amqp,请选择其它版本!"echo "php-$vphp not install amqp, Plese select other version!"returnfirm -f ${extFile}sed -i '/amqp.so/d' /www/server/php/$version/etc/php.ini/etc/init.d/php-fpm-$version reloadecho '==============================================='echo 'successful!'
}
Bt_Check(){checkFile="/www/server/panel/install/check.sh"wget -O ${checkFile} ${download_Url}/tools/check.sh . ${checkFile}
}
actionType=$1
version=$2
vphp=${version:0:1}.${version:1:1}
if [ "$actionType" == 'install' ];thenExt_PathInstall_librabbitmqBt_Check
elif [ "$actionType" == 'uninstall' ];thenExt_PathUninstall_librabbitmq
fi
使用方法:
git clone https://github.com/breakmyself/shell.git
例如php7.4
将此脚本保存服务器上,进入到shell目录执行
bash dapao_amqp.sh install 74
这篇关于增加php的amqp扩展的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!