#! /bin/bash
# Swoole-compiler loader install wizard
# Color
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Output Logo
echo ""
echo "+-------------------------------------------------------------------+"
echo -e "| ${RED}Swoole Compiler Loader Installer${NC} |"
echo "+-------------------------------------------------------------------+"
echo "| version 1.0.3 (2018-03-15) |"
echo "+-------------------------------------------------------------------+"
echo ""
# The function which outputs help information
help(){
echo " "
echo -e " ${YELLOW}Usage :${NC} bash $0 [options] [arguments]"
echo " "
echo -e " ${YELLOW}Options :${NC} "
echo " -h --help Show the help of swoole compiler loader"
echo " -s --libsodium Install libsodium library"
echo " "
echo -e " ${YELLOW}Optional Arguments :${NC} "
echo " php_path : the absolute path of php-cli or php-fpm executable path"
echo " "
echo -e " ${YELLOW}Examples : ${NC}"
echo " bash $0"
echo " bash $0 /usr/local/sbin/php-fpm"
echo " base $0 -s"
echo " "
}
# The function which outputs choice
yes_or_no(){
if [ $# -eq 0 ]; then
echo -e " ${RED}Error:${NC}"
echo " Wrong function parameter"
echo ""
exit 1;
fi
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
* ) echo "Please answer yes or no." ;;
esac
done
}
# The function which judges the execute ability of the php_path
check_php(){
if [ $# -eq 0 ]; then
echo -e " ${RED}Error:${NC}"
echo " Wrong function parameter"
echo ""
exit 1;
fi
check_php_path="$1";
which "$check_php_path" &> /dev/null;
check_php_path_exist=$?;
if [ "$check_php_path_exist" == "0" ]; then
check_php_path=$(which "$check_php_path")
if [ -x "$check_php_path" ]; then
return 0;
else
return 1;
fi
else
return 1;
fi
}
# The function which installs the libsodium libray
install_libsodium(){
back_libsodium_path="./libsodium.so"
if [ ! -e "$back_libsodium_path" ]; then
echo ""
echo -e " ${RED}Error:${NC}"
echo " Not found backed libsodium.so, please check the loader folder"
echo ""
exit 1;
fi
ldconfig
libsodium_exists=$(ldconfig -p | awk '/libsodium/')
if [ -n "$libsodium_exists" ]; then
echo " libsodium.so : found"
else
echo " libsodium.so : not found"
echo -e " ${YELLOW}install libsodium.so...${NC}"
fi
enabled_so_path="/usr/lib"
cp "$back_libsodium_path" "$enabled_so_path"
ldconfig
libSodiumPath="$enabled_so_path/libsodium.so"
if [ ! -e $libSodiumPath ]; then
echo ""
echo -e " ${RED}Error:${NC}"
echo " No found shared library libsodium.so"
echo ""
exit 1;
fi
libsodium_exists=$(ldconfig -p | awk '/libsodium/')
if [ ! -n "$libsodium_exists" ]; then
echo ""
echo -e " ${RED}Error:${NC}"
echo " Fail to install libsodium.so"
echo ""
exit 1;
fi
}
# The function which checks the root
check_root(){
if [[ $EUID -ne 0 ]]; then
echo ""
echo -e " ${RED}This program needs root privilege${NC}"
exit 1
fi
}
# Check the parameter of shell sctipt
if [ "$#" == "1" ] ; then
if [[ ( "$1" == "-h" ) || ( "$1" == "--help" ) ]] ; then
help
exit 1
fi
if [[ ( "$1" == "-s" ) || ( "$1" == "--libsodium" ) ]]; then
# Output checking environment information
echo " "
echo -e " ${YELLOW}Install Libsodium...${NC}"
echo " "
check_root
install_libsodium
echo " "
exit
fi
fi
# Output checking environment information
echo " "
echo -e " ${YELLOW}Checking Environment...${NC}"
echo " "
# Check the bin path of php
php_path=""
if [ $# -eq 0 ]; then
# Check the bin path of php-cli or php-fpm
default_optional_php_paths="php php-fpm php5-fpm php-fpm7.0"
enabled_php_paths=""
for optional_php_path in $default_optional_php_paths
do
check_php "$optional_php_path"
php_exists=$?
if [ "$php_exists" == "0" ]; then
optional_php_path=$(which "$optional_php_path")
enabled_php_paths=$enabled_php_paths" $optional_php_path"
fi
done
if [ "$enabled_php_paths" == "" ]; then
echo ""
echo -e " ${RED}Error:${NC}"
echo " No found php or php-fpm command, please run this script with the path of php"
echo ""
exit 1;
else
pathCount=$(echo "$enabled_php_paths" | awk '{print NF}')
echo " Please select the php path to install loader extension:"
echo ""
indexCount=1
for enabled_php_path in $enabled_php_paths
do
echo " $indexCount : $enabled_php_path"
indexCount=$(($indexCount + 1))
done
echo ""
echo " 0 : Quit this script"
# Choose the bin path to install loader extension
while true; do
preg_str="^[0-$pathCount]$"
echo ""
read -p " Enter a number > ";
if [[ $REPLY =~ $preg_str ]]; then
if [[ $REPLY == 0 ]]; then
echo ""
echo " Exit";
exit 1;
fi
indexCount=1
for enabled_php_path in $enabled_php_paths
do
if [[ $indexCount == $REPLY ]]; then
php_path=$enabled_php_path
fi
indexCount=$(($indexCount + 1))
done
break
else
echo ""
echo " Invalid input";
fi
done
fi
elif [ $# -eq 1 ]; then
php_path="$1"
check_php "$1"
php_exists=$?
if [ "$php_exists" == "0" ]; then
php_path=$(which "$php_path")
else
echo -e " ${RED}Error:${NC}"
echo " Please check if $php_path is existing and executable"
echo ""
exit 1;
fi
else
echo -e " ${RED}Error:${NC}"
echo " Please check your parameters, this shell script supports only one optional parameter."
echo ""
exit 1;
fi
# Check if installed swoole loader
loader_installed=$($php_path -m 2> /dev/null | awk '/swoole_loader/')
if [ -n "$loader_installed" ]; then
# check the version of installed swoole loader
loader_version_installed=$($php_path -i 2> /dev/null | awk '/^swoole_loader version =>/ {print $4}')
echo -e " ${YELLOW}Swoole Compiler Loader $loader_version_installed is installed now${NC}"
echo ""
yes_or_no " Reinstall swoole compiler loader?"
yes_or_no_res=$?
if [ "$yes_or_no_res" == "1" ]; then
echo "";
echo " Exit script";
echo "";
exit 1;
else
echo "";
fi
fi
# Output php path information
echo " php_path : $php_path"
# Check php version
raw_php_version=$($php_path -i 2> /dev/null | awk 'NR != 2 && /^PHP Version =>/ {print $4}')
php_one_version=$(echo "$raw_php_version" | cut -d . -f 1)
php_two_version=$(echo "$raw_php_version" | cut -d . -f 2)
php_version=$php_one_version.$php_two_version
echo " php_version : $php_version"
# Check php sapi
php_sapi=$($php_path -i 2> /dev/null | awk '/^Server API =>/ {print $4,$5,$6}')
echo " php_sapi : $php_sapi"
# Check php thread saftey
php_thread_safety=$($php_path -i 2> /dev/null | awk '/^Thread Safety =>/ {print $4}')
echo " php_thread_safety : $php_thread_safety"
# Check php extension dir
php_extension_dir=$($php_path -i 2> /dev/null | awk '/^extension_dir =>/ {print $3}')
if [ -d "$php_extension_dir" ]; then
echo " php_extension_dir : $php_extension_dir"
else
echo ""
echo -e " ${RED}Error:${NC}"
echo " No found php extension directory : $php_extension_dir"
echo ""
exit 1;
fi
# Check php extension dir
php_ini_path=$($php_path -i 2> /dev/null | awk '/^Loaded Configuration File =>/ {print $5}')
if [ -f "$php_ini_path" ]; then
echo " php_ini_path : $php_ini_path"
else
echo ""
echo -e " ${RED}Error:${NC}"
echo " No found php.ini file: $php_ini_path"
echo ""
exit 1;
fi
# Check xdebug, ioncube loader and zend loader extensions
forbidden_extensions_exists=$($php_path -m 2> /dev/null | awk '/xdebug|ionCube|zend_loader/')
if [ -n "$forbidden_extensions_exists" ]; then
echo ""
echo -e " ${RED}Error:${NC}"
echo " It exists xdebug or ionCuber loader or zend_loader extension, please remove these extensions"
echo ""
exit 1;
fi
# Ensure root privileges.
check_root
# Check libsodium.so which is required for swoole-compiler load
没有合适的资源?快使用搜索试试~ 我知道了~
Swoole Loader 扩展,各个版本的都有,下载直接配置使用
共63个文件
so:40个
dll:20个
sh:2个
需积分: 5 1 下载量 58 浏览量
2024-03-14
22:12:12
上传
评论
收藏 3.73MB 7Z 举报
温馨提示
安装 Swoole-Loader 扩展 1、确定 PHP 版本,线程安全和非线程安全,可在终端(需要登录到服务器,宝塔面板可直接在菜单——终端)中输入 php -v 2、查找扩展路径:php -i | grep extension_dir 3、配置 php.ini,在 php.ini 的最后一行添加:extension=swoole_loader74.so 4、重启php
资源推荐
资源详情
资源评论
收起资源包目录
swoole-loader.7z (63个子文件)
swoole-loader
__MACOSX
._swoole-loader 312B
swoole-loader
._swoole_loader70.so 212B
._swoole_loader55.so 212B
._swoole_loader81_zts_x64.dll 212B
._swoole_loader80_zts.so 212B
._swoole_loader55_zts.so 212B
._swoole_loader71_zts.so 212B
._swoole_loader81.so 212B
._swoole_loader71.so 212B
._swoole_loader74.so 212B
._swoole_loader73_nzts_x64.dll 212B
._swoole-compiler-loader.sh 212B
._swoole_loader74_zts.so 212B
._swoole_loader73.so 212B
._swoole_loader56_zts.so 212B
._swoole_loader73_zts.so 212B
._swoole_loader74_nzts_x64.dll 212B
._swoole_loader54_zts.so 212B
._swoole_loader54.so 212B
._swoole_loader81_nzts_x64.dll 212B
._swoole_loader74_zts_x64.dll 212B
._swoole_loader73_zts_x64.dll 212B
._swoole_loader80_zts_x64.dll 212B
._swoole_loader80.so 212B
._swoole_loader72_nzts_x64.dll 212B
._swoole_loader72_zts_x64.dll 212B
._swoole_loader72.so 212B
._swoole_loader70_zts.so 212B
._swoole_loader72_zts.so 212B
._swoole_loader56.so 212B
._swoole_loader81_zts.so 212B
._swoole_loader80_nzts_x64.dll 212B
swoole-loader
swoole_loader70.so 363KB
swoole_loader55_zts.so 418KB
swoole_loader71_zts.so 230KB
swoole_loader72_zts_x64.dll 203KB
swoole_loader54.so 394KB
swoole_loader72_zts.so 119KB
swoole_loader73_zts.so 177KB
swoole-compiler-loader.sh 10KB
swoole_loader80.so 141KB
swoole_loader81_nzts_x64.dll 514KB
swoole_loader72.so 115KB
swoole_loader70_zts.so 367KB
swoole_loader55.so 406KB
swoole_loader80_nzts_x64.dll 212KB
swoole_loader81.so 189KB
swoole_loader72_nzts_x64.dll 197KB
swoole_loader74.so 161KB
swoole_loader56_zts.so 402KB
swoole_loader56.so 390KB
swoole_loader80_zts.so 145KB
swoole_loader73_nzts_x64.dll 512KB
swoole_loader81_zts.so 202KB
swoole_loader81_zts_x64.dll 526KB
swoole_loader80_zts_x64.dll 220KB
swoole_loader71.so 230KB
swoole_loader74_zts_x64.dll 506KB
swoole_loader54_zts.so 414KB
swoole_loader74_nzts_x64.dll 482KB
swoole_loader73_zts_x64.dll 534KB
swoole_loader73.so 165KB
swoole_loader74_zts.so 169KB
共 63 条
- 1
资源评论
lnlingyuan
- 粉丝: 10
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 筷手引流工具.apk
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功