技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页Tengine>正文
Linux下编译安装部署Tengine
2025年04月24日 Tengine 暂无评论 ⁄ 被围观 33次+

官方网站:

https://tengine.taobao.org/

下载地址:

1、tengine

https://tengine.taobao.org/download_cn.html

https://tengine.taobao.org/download/tengine-3.1.0.tar.gz

2、pcre

https://ftp.pcre.org/pub/pcre/pcre-8.45.tar.gz

3、zlib

https://zlib.net/fossils/zlib-1.3.tar.gz

4、openssl

https://www.openssl.org/source/openssl-1.1.1k.tar.gz

创建相应目录:

mkdir -p /data/server/tengine/packages

mkdir -p /data/server/tengine/install

上传安装包到/data/server/tengine/packages目录下面

操作系统:openEuler、‌AnolisOS‌、AlmaLinux、Rocky Linux等

安装部署:

安装路径

tengine安装包存放目录:/data/server/tengine/packages

tengine安装目录:/data/server/tengine

tengine扩展安装目录:/data/server/tengine/install

1、关闭selinux

sestatus #查看状态,显示disabled表示已经禁用

sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config #禁用selinux

setenforce 0 #临时禁用

/usr/sbin/sestatus -v #查看selinux状态,disabled表示关闭

2、防火墙配置

2.1、关闭firewall

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

systemctl mask firewalld

systemctl stop firewalld

yum remove firewalld

2.2、安装iptables防火墙

yum install iptables-services #安装

vi /etc/sysconfig/iptables #编辑防火墙配置文件,开放TCP 80和443端口

# sample configuration for iptables service

# you can edit this manually or use system-config-firewall

# please do not ask us to add additional ports/services to this default configuration

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

:wq! #保存退出

systemctl restart iptables.service #最后重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

/usr/libexec/iptables/iptables.init restart #重启防火墙

3、安装编译工具包

yum install make gcc gcc-c++ perl zlib-devel glibc-devel glibc-static

4、安装tengine

4.1安装pcre

cd /data/server/tengine/packages

mkdir -p /data/server/tengine/install/pcre

tar zxvf pcre-8.45.tar.gz

cd pcre-8.45

./configure --prefix=/data/server/tengine/install/pcre

make

make install

4.2安装zlib

cd /data/server/tengine/packages

mkdir -p /data/server/tengine/install/zlib

tar zxvf zlib-1.3.tar.gz

cd zlib-1.3

./configure --prefix=/data/server/tengine/install/zlib

make

make install

4.3安装openssl

cd /data/server/tengine/packages

mkdir -p /data/server/tengine/install/openssl

tar zxvf openssl-1.1.1w.tar.gz

cd openssl-1.1.1w

./config -fPIC shared zlib --prefix=/data/server/tengine/install/openssl

make

make install

4.4安装tengine

tengine默认运行账号和组是Linux系统的内置账号和组nobody

groupadd www

useradd -g www www -s /bin/false

cd /data/server/tengine/packages

tar zxvf ngx_cache_purge-2.3.tar.gz

tar zxvf tengine-3.1.0.tar.gz

cd tengine-3.1.0

./configure --prefix=/data/server/tengine --user=www --group=www --without-http_memcached_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module --with-stream --with-http_flv_module --with-http_mp4_module --with-http_sub_module --http-client-body-temp-path=/data/server/tengine/client --http-proxy-temp-path=/data/server/tengine/proxy --http-fastcgi-temp-path=/data/server/tengine/fcgi --http-uwsgi-temp-path=/data/server/tengine/uwsgi --with-openssl=/data/server/tengine/packages/openssl-1.1.1w --with-zlib=/data/server/tengine/packages/zlib-1.3 --with-pcre=/data/server/tengine/packages/pcre-8.45 --add-module=../ngx_cache_purge-2.3

注意:--with-openssl=/data/server/tengine/packages/openssl-1.1.1w --with-zlib=/data/server/tengine/packages/zlib-1.3 --with-pcre=/data/server/tengine/packages/pcre-8.45指向的是源码包解压的路径,而不是安装的路径,否则会报错。

make

make install

/data/server/tengine/sbin/nginx #启动tengine

打开浏览器可以看到如下信息,说明安装启动成功。

#查看tengine版本和安装模块信息

/data/server/tengine/sbin/nginx -V

4.5配置tengine启动脚本

vi /data/server/tengine/tengine.sh

#!/bin/bash

tengine_PATH="/data/server/tengine/sbin/nginx"

PID_FILE="/data/server/tengine/logs/nginx.pid"

function start_tengine() {

if [ -f $PID_FILE ]; then

echo "tengine is already running."

else

echo "Starting tengine..."

$tengine_PATH

echo "tengine started."

fi

}

function stop_tengine() {

if [ -f $PID_FILE ]; then

echo "Stopping tengine..."

$tengine_PATH -s stop

echo "tengine stopped."

else

echo "tengine is not running."

fi

}

function restart_tengine() {

if [ -f $PID_FILE ]; then

echo "Restarting tengine..."

$tengine_PATH -s stop

sleep 1

$tengine_PATH

echo "tengine restarted."

else

echo "tengine is not running. Starting it now..."

$tengine_PATH

echo "tengine started."

fi

}

function reload_tengine() {

if [ -f $PID_FILE ]; then

echo "Reloading tengine configuration..."

$tengine_PATH -s reload

echo "tengine configuration reloaded."

else

echo "tengine is not running. Cannot reload the configuration."

fi

}

function status_tengine() {

if [ -f $PID_FILE ]; then

echo "tengine is running with PID $(cat $PID_FILE)."

else

echo "tengine is stopped."

fi

}

case "$1" in

start)

start_tengine

;;

stop)

stop_tengine

;;

restart)

restart_tengine

;;

reload)

reload_tengine

;;

status)

status_tengine

;;

*)

echo "Usage: $0 {start|stop|restart|reload|status}"

exit 1

;;

esac

:wq! #保存退出

#添加执行权限

chmod +x /data/server/tengine/tengine.sh

4.6添加开机启动

vi /etc/rc.d/rc.local

/bin/sh /data/server/tengine/tengine.sh start

sudo -u root /data/server/tengine/sbin/nginx

sudo -u root "/bin/sh /data/server/tengine/tengine.sh start"

:wq! #保存退出

#默认/etc/rc.local没有执行权限,需要手动添加执行权限

chmod +x /etc/rc.d/rc.local

至此,Linux下编译安装部署Tengine完成。

     
» 转载请注明来源:系统运维 » Linux下编译安装部署Tengine

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2025 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3