Tengine-2.2.3 安装与配置使用 二

本文详细介绍了如何在 CentOS Linux 7.6 的虚拟机环境中安装 Tengine 2.2.3 及其相关组件,包括 pcre、zlib、jemalloc 和 openssl 的解压与自动关联安装过程。通过 bash 脚本实现了自动化安装流程,最终成功部署了 Tengine,并验证了安装结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

测试环境: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)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值