Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiTelteu/c92ef2414cc97e2c76f539cc988652d0 to your computer and use it in GitHub Desktop.
Save AndreiTelteu/c92ef2414cc97e2c76f539cc988652d0 to your computer and use it in GitHub Desktop.
How to install swoole v4.8.2 on aapanel with php 8.0

As a root user, download this script and put it in /www/server/panel/install/modified-swoole-install.sh

cd /www/server/panel/install/
wget https://gist.githubusercontent.com/AndreiTelteu/c92ef2414cc97e2c76f539cc988652d0/raw/abf316cd872ad75be34ce5572bb7ff3dac6819ce/modified-swoole-install.sh
chmod +x modified-swoole-install.sh
bash modified-swoole-install.sh install 80

Done ! installed and activated

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
Swoole_Version='4.5.11'
runPath=/root
extPath()
{
case "${version}" in
'70')
extFile='/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/swoole.so'
;;
'71')
extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/swoole.so'
;;
'72')
extFile='/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/swoole.so'
;;
'73')
extFile='/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/swoole.so'
;;
'74')
extFile='/www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902/swoole.so'
;;
'80')
extFile='/www/server/php/80/lib/php/extensions/no-debug-non-zts-20200930/swoole.so'
;;
esac
}
Install_Swoole()
{
if [ ! -f "/www/server/php/$version/bin/php-config" ];then
echo "php-$vphp 未安装,请选择其它版本!"
echo "php-$vphp not install, Plese select other version!"
return
fi
isInstall=`cat /www/server/php/$version/etc/php.ini|grep 'swoole.so'`
if [ "${isInstall}" != "" ];then
echo "php-$vphp 已安装过swoole,请选择其它版本!"
echo "php-$vphp not install, Plese select other version!"
return
fi
public_file=/www/server/panel/install/public.sh
if [ ! -f $public_file ];then
wget -O $public_file http://download.bt.cn/install/public.sh -T 5;
fi
. $public_file
download_Url=$NODE_URL
extPath
if [ ! -f "${extFile}" ];then
if [ "$version" -ge "72" ];then
Swoole_Version="4.8.2"
fi
# wget $download_Url/src/swoole-$Swoole_Version.tgz
# tar -zxvf swoole-$Swoole_Version.tgz
# cd swoole-$Swoole_Version
wget https://github.com/swoole/swoole-src/archive/refs/tags/v4.8.2.zip
unzip v4.8.2.zip
cd swoole-src-4.8.2
/www/server/php/$version/bin/phpize
chmod +x /www/server/panel/install/swoole-src-4.8.2/build/shtool
./configure --with-php-config=/www/server/php/$version/bin/php-config --enable-openssl --with-openssl-dir=/usr/local/openssl --enable-mysqlnd --enable-sockets --enable-http2 --enable-swoole-curl --enable-swoole-json --enable-cares
chmod +x /www/server/panel/install/swoole-src-4.8.2/build/shtool
make
chmod +x /www/server/panel/install/swoole-src-4.8.2/build/shtool
make install
cd ../
# rm -rf swoole*
fi
if [ ! -f "${extFile}" ];then
echo 'error';
exit 0;
fi
echo -e "\n[swoole]\nextension = swoole.so\n" >> /www/server/php/$version/etc/php.ini
service php-fpm-$version reload
}
Uninstall_Swoole()
{
extPath
sed -i '/swoole/d' /www/server/php/$version/etc/php.ini
rm -f ${extFile}
service php-fpm-$version reload
echo '==============================================='
echo 'successful!'
}
actionType=$1
version=$2
vphp=${version:0:1}.${version:1:1}
if [ "$actionType" == 'install' ];then
Install_Swoole
elif [ "$actionType" == 'uninstall' ];then
Uninstall_Swoole
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment