Tengine

DevOps Tengine评论2,081字数 5210阅读17分22秒阅读模式

Tengine简介

Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网天猫商城等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。

从2011年12月开始,Tengine成为一个开源项目,Tengine团队在积极地开发和维护着它。Tengine团队的核心成员来自于淘宝搜狗等互联网企业。Tengine是社区合作的成果,我们欢迎大家参与其中,贡献自己的力量。

 

Tengine官网 https://tengine.taobao.org/

安装Tengine

依赖包

[root@us-pre-ebu-english-1 ~]# yum -y install lrzsz gcc-c++  pcre pcre-devel lvm2  vim zlib zlib-devel ruby openssl openssl-devel patch wget bash-completion lsof  unzip zip bash-completion tree telnet lsof iotop autoconf libmcrypt libmcrypt-devel mcrypt mhas libxml2 libxml2-dev libxslt-devel gd gd-devel  geoip-devel

创建nginx用户

[root@us-pre-ebu-english-1 ~]# useradd -r tengine

下载tengine包,解压

[root@us-pre-ebu-english-1 ]# wget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz
[root@us-pre-ebu-english-1 ~]# tar xvf tengine-2.3.3.tar.gz -C /usr/local/
[root@us-pre-ebu-english-1 ~]# cd /usr/local/tengine-2.3.3/
[root@us-pre-ebu-english-1 ~]# ./configure --prefix=/usr/local/tengine --user=tengine --group=tengine --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_addition_module --with-http_xslt_module --with-http_xslt_module=dynamic --with-http_image_filter_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module --with-stream_ssl_preread_module --with-compat --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream --add-module=./modules/ngx_http_upstream_check_module/
[root@us-pre-ebu-english-1 tengine-2.3.3]# make
[root@us-pre-ebu-english-1 tengine-2.3.3]# make install

查看安装结果

[root@us-pre-ebu-english-1 ~]# whereis tengine
tengine: /usr/local/tengine

启动脚本

把tengine的sbin 软连接到/usr/sbin/ 下

[root@us-pre-ebu-english-1 ~]# ln -s /usr/local/tengine/sbin/* /usr/sbin/

查看版本

[root@us-pre-ebu-english-1 ~]# nginx -v
Tengine version: Tengine/2.3.3
nginx version: nginx/1.18.0

配置启动脚本

[root@us-pre-ebu-english-1 ~]# vim /lib/systemd/system/tengine.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/tengine/logs/nginx.pid
ExecStartPre=/usr/local/tengine/sbin/nginx -t
ExecStart=/usr/local/tengine/sbin/nginx -c /usr/local/tengine/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

开机自启动

[root@us-pre-ebu-english-1 ~]# chmod 755 /lib/systemd/system/tengine.service
[root@us-pre-ebu-english-1 ~]# systemctl enable tengine.service
Created symlink from /etc/systemd/system/multi-user.target.wants/tengine.service to /usr/lib/systemd/system/tengine.service.
[root@us-pre-ebu-english-1 ~]# systemctl start tengine.service

主配置文件

[root@us-pre-ebu-english-1 conf]# cp /usr/local/tengine/conf/nginx.conf /usr/local/tengine/conf/nginx.confback
[root@us-pre-ebu-english-1 conf]# > /usr/local/tengine/conf/nginx.conf
[root@us-pre-ebu-english-1 conf]# vim /usr/local/tengine/conf/nginx.conf
user  tengine;
worker_processes  auto;

pid        logs/nginx.pid;
events {
  use epoll;
  worker_connections 10240;
  multi_accept on;

}


http {
                       log_format main '{"time":"[$time_local]",'
                      '"client_ip":"$remote_addr",'
                      '"real_ip":"$http_x_forwarded_for",'
                      '"request_method":"$request_method",'
                      '"query_string":"$query_string",'
                      '"url":"$request_uri",'
                      '"uri":"$uri",'
                      '"server_name":"$server_name",'
                      '"hostname":"$hostname",'
                      '"http_host":"$http_host",'
                      '"code":"$status",'
                      '"body_size":"$body_bytes_sent",'
                      '"http_referer":"$http_referer",'
                      '"client_agent":"$http_user_agent",'
                      '"upstream_addr":"$upstream_addr",'
                      '"rt":"$request_time",'
                      '"uct":"$upstream_connect_time",'
                      '"uht":"$upstream_header_time",'
                      '"urt":"$upstream_response_time",'
                      '"myrequest_body":"$request_body",'
                      '"upstram_code":"$upstream_status"}';


access_log  /usr/local/tengine/logs/tengine-access.log  main;
error_log /usr/local/tengine/logs/tengine-error.log ;



  include mime.types;
  proxy_headers_hash_max_size 51200;
  proxy_headers_hash_bucket_size 6400;
  default_type application/octet-stream;
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 1024m;
  client_body_buffer_size 10m;
  sendfile on;
  tcp_nopush on;
  keepalive_timeout 120;
  server_tokens off;
  tcp_nodelay on;

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 8 128k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
  fastcgi_intercept_errors on;
  gzip on;
  gzip_buffers 16 8k;
  gzip_comp_level 3;
  gzip_http_version 1.1;
  gzip_min_length 256;
  gzip_proxied any;
  gzip_vary on;
  gzip_types *;
  gzip_disable "MSIE [1-6]\.(?!.*SV1)";


    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }
        location /nginx_status {
        stub_status on;
        access_log off;
        } 
           location /status {
            check_status;

            access_log   off;
            }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
include /usr/local/tengine/conf/conf.d/*.conf;
include /usr/local/tengine/conf/conf.d/*/*.conf;
}
[root@us-pre-ebu-english-1 conf]# mkdir conf.d
[root@us-pre-ebu-english-1 conf]# nginx -t

 

继续阅读
DevOps
  • 本文由 发表于 2022年5月5日 11:02:27
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
  • Tengine
评论  0  访客  0

发表评论