测试环境:CentOS Linux release 7.6.1810 (Core) 虚拟机一台
pcre、zlib、jemalloc、openssl 只解压,不手动安装,安装Tengine时,Tengine会自动关联安装,安装比较稳定报错少
#!/bin/bash
clear
function sttyPrintln(){
local message="$1"
shift 1
local program="$1"
shift
printf "%-50s%30s\n" "$message" "$program"
}
function unpackageTar(){
local programName="$1"
shift
if [[ -d "./${programName}" ]]; then
sttyPrintln '删除历史安装缓存...' $programName
rm -rf "./${programName}"
fi;
if [[ -r "./${programName}.tar.gz" ]]; then
sttyPrintln '组件解压文件路径...' $programName
tar -zxf "./${programName}.tar.gz"
elif [[ -r "./${programName}.tgz" ]]; then
sttyPrintln '组件解压文件路径...' $programName
tar -zxf "./${programName}.tgz"
elif [[ -r "./${programName}.tar.bz2" ]]; then
sttyPrintln '组件解压文件路径...' $programName
tar -jxf "./${programName}.tar.bz2"
else
sttyPrintln "组件$programName无法找到,即将退出安装..."
fi;
}
function configureInstall(){
local tmpPackage="$1"
shift 1
local installPath="$1"
shift
local programName=${tmpPackage//'.tar.gz'/''}
programName=${programName//'.tgz'/''}
if [[ -d "./${programName}" ]]; then
cd "./${programName}"
sttyPrintln '组件开始编译安装...' $programName
if [[ -r "./config" ]]; then
./config --prefix=$installPath"/"${programName}
elif [[ -r "./configure" ]]; then
./configure --prefix=$installPath"/"${programName}
else
sttyPrintln "Configure文件无法找到,即将退出安装..." ${programName}
fi
make
echo "$sudoPasswd" | sudo -S make install
if [[ -d $installPath"/"${programName} ]]; then
sttyPrintln '依赖组件安装完成...' $installPath"/"${programName}
fi;
cd ..
sleep 3
else
sttyPrintln "组件解压文件无法找到,即将退出安装..." "./${programName}"
exit 1
fi;
}
sttyPrintln '开始安装 Tengine 及其相关组件...'
bachPath=$(pwd)
sudoPasswd='wntime'
baseInstall='/usr/programs'
sttyPrintln '创建程序安装目录...' $baseInstall
echo $sudoPasswd | sudo -S mkdir -p $baseInstall
echo $sudoPasswd | sudo -S chown -R wntime:wntime $baseInstall
sttyPrintln '准备编译安装环境...'
echo $sudoPasswd | sudo -S yum install gcc gcc-c++ wget perl unzip autogen autoconf bzip2 lua-devel -y
program='pcre-8.43'
unpackageTar $program
# configureInstall $program $baseInstall
program='openssl-1.1.1c'
unpackageTar $program
# configureInstall $program $baseInstall
program='zlib-1.2.11'
unpackageTar $program
# configureInstall $program $baseInstall
program='jemalloc-5.2.1'
unpackageTar $program
# configureInstall $program $baseInstall
program='tengine-2.2.3'
unpackageTar $program
安装 Tengine 2.2.3
sttyPrintln '组件开始编译安装...' $program
cd "./$program"
./configure --prefix="$baseInstall/$program" \
--with-ld-opt=-Wl,-rpath, \
--user=wntime \
--group=wntime \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_v2_module \
--with-http_dav_module \
--with-http_mp4_module \
--with-http_secure_link_module \
--with-http_sysguard_module \
--with-http_concat_module \
--with-http_lua_module \
--with-http_upstream_check_module \
--with-pcre="../pcre-8.43" \
--with-zlib="../zlib-1.2.11" \
--with-jemalloc="../jemalloc-5.2.1" \
--with-openssl="../openssl-1.1.1c"
make
# echo "$sudoPasswd" | sudo -S make install
make install
sttyPrintln 'Tengine 及其相关组件安装完成...'
至此完成 Tengine的安装
tengine-2.2.3]$ ./sbin/nginx -m
Tengine version: Tengine/2.2.3 (nginx/1.8.1)
nginx: loaded modules:
nginx: ngx_core_module (static)
nginx: ngx_errlog_module (static)
nginx: ngx_conf_module (static)
nginx: ngx_dso_module (static)