Tengine安装使用及配置


        Tengine是由淘宝发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。

        官网地址:https://tengine.taobao.org/

1、下载tengine


        自行到官网下载 tengine,或者使用以下命令下载:   

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


        我下载的是tengine-3.0.0.tar.gz

2、安装tengine前安装好c语言编译工具

yum install gcc openssl-devel pcre-devel zlib-devel -y


3、解压tengine

tar -zxvf tengine-3.1.0.tar.gz


4、安装tengine


        进行tengine目录(cd tengine-3.1.0)

        (1)配置软件安装的路径:./configure --prefix=/安装路径 安装路径就是想将Tengine安装在的路径,例:./configure --prefix=/usr/local/tengine

./configure --prefix=/usr/local/tengine  --add-module=./modules/ngx_http_upstream_check_module

        如果出现错误,则缺少系统依赖组件:

        在线安装依赖命令:

yum install gcc openssl-devel pcre-devel zlib-devel

        离线安装依赖并安装

        下载pcre-8.42.tar.gz【依赖】
        下载zlib-1.2.11.tar.gz【依赖】
        下载openssl-1.0.1h.tar.gz【依赖】
        (2)编译和安装软件

make && make install


5、启动
        执行以下命令启动Nginx

/usr/local/tengine/sbin/nginx


        通过进程查看Nginx是否启动成功

ps -ef | grep nginx


6、停止
        执行以下命令停止Nginx

/usr/local/tengine/sbin/nginx -s stop


        或者使用有序停止

/usr/local/tengine/sbin/nginx -s quit


        通过进程查看Nginx是否停止成功

ps -ef | grep nginx


三、默认配置文件解析
        打开 /usr/local/tengine/conf/nginx.conf文件可以看到如下内容:

 vi /usr/local/tengine/conf/nginx.conf


 


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#error_log  "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;
    #access_log  "pipe:rollback logs/access_log interval=1d baknum=7 maxsize=2G"  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #access_log  "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G"  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # pass the Dubbo rpc to Dubbo provider server listening on 127.0.0.1:20880
        #
        #location /dubbo {
        #    dubbo_pass_all_headers on;
        #    dubbo_pass_set args $args;
        #    dubbo_pass_set uri $uri;
        #    dubbo_pass_set method $request_method;
        #
        #    dubbo_pass org.apache.dubbo.samples.tengine.DemoService 0.0.0 tengineDubbo dubbo_backend;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # upstream for Dubbo rpc to Dubbo provider server listening on 127.0.0.1:20880
    #
    #upstream dubbo_backend {
    #    multi 1;
    #    server 127.0.0.1:20880;
    #}

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

四、Nginx基本的访问状态监控

location /basic_status {
    stub_status on;
}


basic_status可自己定义。配置好在浏览器打开“http://nginx-ip:port/basic_status”就可以查看您Nginx的基本状态了。

注意:nginx-ip:port是您安装nginx服务的地址和nginx端口。

五、配置tengine.service使用systemctl启动、停止、开机启动


1、创建tengine.service文件

vi /usr/lib/systemd/system/tengine.service


 

[Unit]
Description=Tengine Nginx Web Server
After=network.target
 
 
[Service]
Type=forking
#PIDFile=/opt/nginx/tengine.pid
ExecStartPre=/usr/local/tengine/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/local/tengine/sbin/nginx
ExecReload=/usr/local/tengine/sbin/nginx -s reload
ExecStop=/usr/local/tengine/sbin/nginx -s quit
PrivateTmp=true
 
 
[Install]
WantedBy=multi-user.target

2、重新加载

systemctl daemon-reload


3、使用systemclt 启动停止等

systemctl start tengine
systemctl stop tengine
systemctl reload tengine
systemctl enable tengine

六、扩展-防火墙


如果您是为了测试,又不会配置防火墙,可以临时禁用防炎墙

systemctl stop firewalld
sudo firewall-cmd --state
也可通过下面方式来开放某一个特定端口,如配置防火墙开放http 8080

sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports
或者通过下面方式来开放某一特定服务,如配置防火墙开放http 80

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
sudo firewall-cmd --list-services

七、启动报错

报错
nginx: [emerg] invalid port in resolver "fe10::10c:21ff:fe17:d721%ens160" in /app/tengine/conf/nginx.conf:60 

vi /etc/resolv.conf

删除 /etc/resolv.conf 中的ipv6 记录

nameserver 192.168.3.122
#nameserver fe10::10c:21ff:fe17:d721%ens160

另外直接修改 /etc/resolv.conf 是临时的,重启网络后会被重置,如果服务器开启了ipv6功能,则一直会有这个问题,需要配置网卡关闭ipv6的功能,如果确实需要用到ipv6,那只能用方式1去解决了。

vim /etc/sysconfig/network-scripts/ifcfg-eno1


#设置如下,并将其他IPV6配置都删掉

IPV6INIT=no
IPV6_AUTOCONF=no 


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我在天堂抽烟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值