diff --git a/plugins/php-apt/versions/all_test.sh b/plugins/php-apt/versions/all_test.sh new file mode 100644 index 000000000..ba4ad348d --- /dev/null +++ b/plugins/php-apt/versions/all_test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + + +## + +cd /www/server/mdserver-web + +cd /www/server/mdserver-web/plugins/php-apt/versions && /bin/bash common.sh 5.6 install yaf \ No newline at end of file diff --git a/plugins/php-apt/versions/common.sh b/plugins/php-apt/versions/common.sh index b77ccaf2a..eed0b1106 100644 --- a/plugins/php-apt/versions/common.sh +++ b/plugins/php-apt/versions/common.sh @@ -12,6 +12,12 @@ version=$1 action=$2 extName=$3 +which bc +if [ "$?" != "0" ];then + apt install -y bc +fi + + # echo $1,$2,$3 # echo $curPath @@ -24,6 +30,7 @@ FILE_COMMON=${curPath}/common/${extName}.sh # apt install -y php81-php-yar + if [ "$action" == 'install' ];then if [ -f $FILE ];then diff --git a/plugins/php-apt/versions/common/yaf.sh b/plugins/php-apt/versions/common/yaf.sh index c13c6d520..916731c87 100755 --- a/plugins/php-apt/versions/common/yaf.sh +++ b/plugins/php-apt/versions/common/yaf.sh @@ -3,14 +3,7 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH curPath=`pwd` - rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - actionType=$1 version=$2 @@ -20,9 +13,13 @@ LIBNAME=yaf LIBV=3.3.5 +if [ `echo "$version < 7.0"|bc` -eq 1 ];then + LIBV=2.3.5 +fi -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +extVer=`bash $rootPath/lib.sh $version` +extFile=/usr/lib/php/${extVer}/${LIBNAME}.so if [ "$sysName" == "Darwin" ];then BAK='_bak' @@ -32,8 +29,9 @@ fi Install_lib() { - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + + #cat /etc/php/${version}/fpm/conf.d/* | grep -v '^;' |tr -s '\n' + isInstall=`cat /etc/php/${version}/fpm/conf.d/* | grep -v '^;' |tr -s '\n' |grep "${LIBNAME}.so"` if [ "${isInstall}" != "" ];then echo "php-$version 已安装${LIBNAME},请选择其它版本!" return @@ -59,13 +57,14 @@ Install_lib() echo "ERROR!" return; fi + - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - echo "${LIBNAME}.use_namespace=1" >> $serverPath/php/$version/etc/php.ini + echo "" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini + echo "[${LIBNAME}]" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini + echo "extension=${LIBNAME}.so" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini + echo "${LIBNAME}.use_namespace=1" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini - bash ${rootPath}/plugins/php/versions/lib.sh $version restart + systemctl restart php${version}-fpm echo '===========================================================' echo 'successful!' } @@ -73,7 +72,7 @@ Install_lib() Uninstall_lib() { - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + if [ ! -f "/usr/bin/php-config${version}" ];then echo "php-$version 未安装,请选择其它版本!" return fi @@ -83,13 +82,10 @@ Uninstall_lib() return fi - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.use_namespace/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/\[${LIBNAME}\]/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart + rm -rf /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini + rm -rf $extFile + + systemctl restart php${version}-fpm echo '===============================================' echo 'successful!' } diff --git a/plugins/php-apt/versions/lib.sh b/plugins/php-apt/versions/lib.sh index 5702d47ed..4a2b1b91d 100644 --- a/plugins/php-apt/versions/lib.sh +++ b/plugins/php-apt/versions/lib.sh @@ -9,12 +9,21 @@ rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") version=$1 -action=$2 -if [ -f /lib/systemd/system/php${version}.service ];then - systemctl ${action} php${version} -elif [[ -f /usr/lib/systemd/system/php${version}.service ]]; then - systemctl ${action} php${version} -else - $serverPath/php/init.d/php${version} ${action} +if [ "$version" == '5.6' ];then + echo '20131226' +elif [[ "$version" == '7.0' ]]; then + echo '20151012' +elif [[ "$version" == '7.1' ]]; then + echo '20160303' +elif [[ "$version" == '7.2' ]]; then + echo '20170718' +elif [[ "$version" == '7.3' ]]; then + echo '20180731' +elif [[ "$version" == '7.4' ]]; then + echo '20190902' +elif [[ "$version" == '8.0' ]]; then + echo '20200930' +elif [[ "$version" == '8.1' ]]; then + echo '20210902' fi \ No newline at end of file