tenginx安装

简介

Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。
从2011年12月开始,Tengine成为一个开源项目,Tengine团队在积极地开发和维护着它。Tengine团队的核心成员来自于淘宝、搜狗等互联网企业。Tengine是社区合作的成果,我们欢迎大家参与其中,贡献自己的力量。

特性

  • 继承Nginx-1.15.9的所有特性,兼容Nginx的配置;
  • 支持HTTP的CONNECT方法,可用于正向代理场景;
  • 支持异步OpenSSL,可使用硬件如:QAT进行HTTPS的加速与卸载;
  • 增强相关运维、监控能力,比如异步打印日志及回滚,本地DNS缓存,内存监控等;
  • Stream模块支持server_name指令;
  • 更加强大的负载均衡能力,包括一致性hash模块、会话保持模块,还可以对后端的服务器进行主动健康检查,根据服务器状态自动上线下线,以及动态解析upstream中出现的域名;
  • 输入过滤器机制支持。通过使用这种机制Web应用防火墙的编写更为方便;
  • 支持设置proxy、memcached、fastcgi、scgi、uwsgi在后端失败时的重试次数
  • 动态脚本语言Lua支持。扩展功能非常高效简单;
  • 支持按指定关键字(域名,url等)收集Tengine运行状态;
  • 组合多个CSS、JavaScript文件的访问请求变成一个请求;
  • 自动去除空白字符和注释从而减小页面的体积
  • 自动根据CPU数目设置进程个数和绑定CPU亲缘性;
  • 监控系统的负载和资源占用从而对系统进行保护;
  • 显示对运维人员更友好的出错信息,便于定位出错机器;
  • 更强大的防攻击(访问速度限制)模块;
  • 更方便的命令行参数,如列出编译的模块列表、支持的指令等;
  • 可以根据访问文件类型设置过期时间;

tnginx下载地址

查看系统版本
[root@centos-4 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
安装tenginx依赖包
[root@centos-4 ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pcre-devel
卸载系统自带的http服务
[root@centos-4 ~]# rpm -e httpd --nodeps
解压,编译安装,配置环境变量
[root@centos-4 ~]# tar zxf tengine-2.3.0.tar.gz -c /usr/src/
[root@centos-4 ~]# cd /usr/src/tengine-2.3.0
[root@centos-4 tengine-2.3.0]# ./configure --prefix=/usr/local/nginx && make && make isntall
[root@centos-4 tengine-2.3.0]# cd /etc/
[root@centos-4 etc]# vim profile
export PATH=$PATH:/usr/local/nginx/sbin
[root@centos-4 etc]# source /etc/profile
显示版本并配置选项
[root@centos-4 ~]# nginx -V
Tengine version: Tengine/2.3.0 (nginx/1.15.9)
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/tnginx
[root@centos-4 ~]# nginx -h
@ root@centos-4 ~]# nginx -h
Tengine version: Tengine/2.3.0 (nginx/1.15.9)
Usage: nginx [-?
hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?
,-h : this help
#显示版本并退出
-v : show version and exit
#显示版本和配置选项,然后退出
-V : show version and configure options then exit
t : 测试配置和退出
-T :test configuration:测试配置dump:转储exit:退出
-q : 在配置测试期间抑制非错误消息
#停止,退出,重新打开,重新加载
-s signal : send signal to a master process: stop, quit, reopen, reload
nginx -s 启动nginx
nginx -s reload 重启nginx
nginx -s stop 停止nginx
-p prefix : 设置前缀路径(默认:/usr/local/tnginx/)
-c filename : 设置配置文件(默认:conf/nginx.conf)
-g directives : 从配置文件中设置全局指令
-m : 显示所有模块并退出
-l : show:显示exit:退出

编写启动脚本
[root@centos-4 ~]# cat /etc/init.d/nginx 
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/tnginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   if [ -n "$user" ]; then
      if [ -z "`grep $user /etc/passwd`" ]; then
         useradd -M -s /bin/nologin $user
      fi
      options=`$nginx -V 2>&1 | grep 'configure arguments:'`
      for opt in $options; do
          if [ `echo $opt | grep '.*-temp-path'` ]; then
              value=`echo $opt | cut -d "=" -f 2`
              if [ ! -d "$value" ]; then
                  # echo "creating" $value
                  mkdir -p $value && chown -R $user $value
              fi
          fi
       done
    fi
}

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    sleep 1
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

force_reload() {
    restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

[root@centos-4 ~]# systemctl daemon-reload
[root@centos-4 ~]# systemctl start nginx
[root@centos-4 ~]# systemctl status nginx
● nginx.service - SYSV: NGINX is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled)
Active: active (running) since 日 2019-05-05 21:49:51 CST; 10s ago
Docs: man:systemd-sysv-generator(8)
Process: 1684 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=0/SUCCESS)
Main PID: 1701 (nginx)
CGroup: /system.slice/nginx.service
├─1701 nginx: master process /usr/sbin/nginx -c /usr/local/tnginx/conf/nginx.conf
└─1702 nginx: worker process

5月 05 21:49:51 centos-4 systemd[1]: Starting SYSV: NGINX is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server…
5月 05 21:49:51 centos-4 nginx[1684]: Starting nginx: [ 确定 ]
5月 05 21:49:51 centos-4 systemd[1]: Started SYSV: NGINX is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
[root@centos-4 ~]# netstat -anplt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1701/nginx: master
给防火墙开例外
[root@centos-4 ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@centos-4 ~]# firewall-cmd --reload
success
更多详细信息请查看官网tenginx: http://tengine.taobao.org/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值