当前位置:   article > 正文

增加php的amqp扩展_宝塔php 5.6 安装amqp扩展

宝塔php 5.6 安装amqp扩展

前言:本脚本仅仅适用于通过宝塔面板安装的php,使用的是amqp.1.10.2,仅仅支持php5.6以上,pear1.4版本以上

目前只测试了CentOS7的系统,后续会对此进行兼容其他操作系统

  1. #!/bin/bash
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3. export PATH
  4. #说明:amqp.1.10.2仅适用于php5.6版本以上,pear1.4版本以上
  5. public_file=/www/server/panel/install/public.sh
  6. [ ! -f $public_file ] && wget -O $public_file http://download.bt.cn/install/public.sh -T 5;
  7. publicFileMd5=$(md5sum ${public_file}|awk '{print $1}')
  8. md5check="66c89de255c11b64d5215be67dc4fdc6"
  9. [ "${publicFileMd5}" != "${md5check}" ] && wget -O $public_file http://download.bt.cn/install/public.sh -T 5;
  10. . $public_file
  11. download_Url=$NODE_URL
  12. srcPath='/root';
  13. #安装amqp需要安装librabbitmq依赖
  14. System_Lib(){
  15. if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ] ; then
  16. installPack="librabbitmq-devel"
  17. fi
  18. [ "${installPack}" != "" ] && ${PM} install ${installPack} -y
  19. }
  20. #amqp.1.10.2适合使用的php版本
  21. Ext_Path(){
  22. case "${version}" in
  23. '56')
  24. extFile="/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/amqp.so"
  25. ;;
  26. '70')
  27. extFile="/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/amqp.so"
  28. ;;
  29. '71')
  30. extFile="/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/amqp.so"
  31. ;;
  32. '72')
  33. extFile="/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/amqp.so"
  34. ;;
  35. '73')
  36. extFile='/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/amqp.so'
  37. ;;
  38. '74')
  39. extFile='/www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902/amqp.so'
  40. ;;
  41. esac
  42. }
  43. Install_librabbitmq()
  44. {
  45. #下载smbclient客户端
  46. cd $srcPath
  47. wget https://pecl.php.net/get/amqp-1.10.2.tgz
  48. tar zxvf amqp-1.10.2.tgz
  49. cd $srcPath/amqp-1.10.2
  50. /www/server/php/$version/bin/phpize
  51. ./configure --with-php-config=/www/server/php/$version/bin/php-config
  52. make && make install
  53. if [ ! -d /www/server/php/$version ];then
  54. return;
  55. fi
  56. if [ ! -f "/www/server/php/$version/bin/php-config" ];then
  57. echo "php-$vphp 未安装,请选择其它版本!"
  58. echo "php-$vphp not install, Plese select other version!"
  59. return
  60. fi
  61. isInstall=`cat /www/server/php/$version/etc/php.ini|grep 'amqp.so'`
  62. if [ "${isInstall}" != "" ];then
  63. echo "php-$vphp 已安装过amqp,请选择其它版本!"
  64. echo "php-$vphp is already install amqp, Plese select other version!"
  65. return
  66. fi
  67. echo "extension=amqp.so" >> /www/server/php/$version/etc/php.ini
  68. /etc/init.d/php-fpm-$version reload
  69. echo '==============================================='
  70. echo 'successful!'
  71. /etc/init.d/php-fpm-$version reload
  72. rm -rf $srcPath/amqp*
  73. /www/server/php/${version}/bin/php -m|grep amqp
  74. }
  75. Uninstall_librabbitmq()
  76. {
  77. if [ ! -d /www/server/php/$version ];then
  78. rm -rf $srcPath/amqp*
  79. fi
  80. if [ ! -f "/www/server/php/$version/bin/php-config" ];then
  81. echo "php-$vphp 未安装,请选择其它版本!"
  82. echo "php-$vphp not install, Plese select other version!"
  83. return
  84. fi
  85. isInstall=`cat /www/server/php/$version/etc/php.ini|grep 'amqp.so'`
  86. if [ "${isInstall}" = "" ];then
  87. echo "php-$vphp 未安装amqp,请选择其它版本!"
  88. echo "php-$vphp not install amqp, Plese select other version!"
  89. return
  90. fi
  91. rm -f ${extFile}
  92. sed -i '/amqp.so/d' /www/server/php/$version/etc/php.ini
  93. /etc/init.d/php-fpm-$version reload
  94. echo '==============================================='
  95. echo 'successful!'
  96. }
  97. Bt_Check(){
  98. checkFile="/www/server/panel/install/check.sh"
  99. wget -O ${checkFile} ${download_Url}/tools/check.sh
  100. . ${checkFile}
  101. }
  102. actionType=$1
  103. version=$2
  104. vphp=${version:0:1}.${version:1:1}
  105. if [ "$actionType" == 'install' ];then
  106. Ext_Path
  107. Install_librabbitmq
  108. Bt_Check
  109. elif [ "$actionType" == 'uninstall' ];then
  110. Ext_Path
  111. Uninstall_librabbitmq
  112. fi

使用方法:

git  clone  https://github.com/breakmyself/shell.git

例如php7.4 

将此脚本保存服务器上,进入到shell目录执行

bash dapao_amqp.sh install 74

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/376083
推荐阅读
相关标签
  

闽ICP备14008679号