• 【软件安装】CentOS7安装Tengine_2_3_2(Nginx 1_17_0)


    简单比较一下Tengine 和Nginx

    背景

    使用最新的软件,可以处理一些bug,文章对CentOS6不做介绍(不会用)

    推荐使用Tengine,理由是淘宝再用,兼容 Nginx 可以随时切换

    Tengine-2.3.0+介绍

    Github: Tengine: 【Star:9.2K】

    https://github.com/alibaba/tengine

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

    • nginx-1.17.3的所有特性都是继承的,即它与nginx 100%兼容。
    • 支持转发代理的连接http方法。
    • 支持异步openssl,使用qat等硬件实现https加速。
    • 增强的操作监控,如异步日志回滚、DNS缓存、内存使用等。
    • 流模块中支持服务器名。
    • 更多的负载平衡方法,例如一致的散列和会话持久性。
    • 输入体过滤器支持。使用这个机制编写Web应用防火墙非常方便。
    • 动态脚本语言(lua)支持,这是非常有效的,并使其易于扩展核心功能。
    • 限制上游服务器(proxy、memcached、fastcgi、scgi、uwsgi)的重试次数。
    • 包括支持独立进程的机制。
    • 在系统负载或内存使用过多的情况下保护服务器。
    • 可以将多个CSS或JavaScript请求组合成一个请求,以减少下载时间。
    • 删除不必要的空白和注释以减小页面大小。
    • 可以对上游服务器执行主动健康检查。
    • 可以自动设置工作进程和CPU关联的数量。
    • Limit_Req模块通过白名单支持得到增强,在单个位置允许更多条件。
    • 增强的诊断信息使故障排除变得更容易。
    • 更多用户友好的命令行,例如,显示所有编译的模块和支持的指令。
    • 可以为某些MIME类型指定到期时间。
    • 错误页可以重置为“默认”。

    Nginx-1.17.3+介绍

    Github: Nginx: 【Star:9.8K】

    https://github.com/nginx/nginx

    Nginx 是一个高性能的 Web 和反向代理服务器, 它具有有很多非常优越的特性:

    • 作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率,这点使 Nginx 尤其受到虚拟主机提供商的欢迎。能够支持高达 50,000 个并发连接数的响应,感谢 Nginx 为我们选择了 epoll and kqueue 作为开发模型.

    • 作为负载均衡服务器:Nginx 既可以在内部直接支持 Rails 和 PHP,也可以支持作为 HTTP代理服务器 对外进行服务。Nginx 用 C 编写, 不论是系统资源开销还是 CPU 使用效率都比 Perlbal 要好的多。

    • 作为邮件代理服务器: Nginx 同时也是一个非常优秀的邮件代理服务器(最早开发这个产品的目的之一也是作为邮件代理服务器),Last.fm 描述了成功并且美妙的使用经验。

    • Nginx 安装非常的简单,配置文件 非常简洁(还能够支持perl语法),Bugs非常少的服务器: Nginx 启动特别容易,并且几乎可以做到7*24不间断运行,即使运行数个月也不需要重新启动。你还能够在 不间断服务的情况下进行软件版本的升级。

    安装命令 ———#代表使用的root权限

    检查环境信息

    [root@ip104 ~]# cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core) 
    

    1、下载安装包(使用离线或者在线方式)

    1.1【离线方式自己下载】

    • 下载安装包安装Tengine-2.3.0
    • 下载pcre-8.39.tar.gz【依赖】
    • 下载zlib-1.2.11.tar.gz【依赖】
    • 下载openssl-1.0.1h.tar.gz【依赖】
    • 下载jemalloc-3.6.0.tar.bz2 【依赖】
    • 下载 tengine-2.3.0.tar.gz
    # wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz 
    # wget http://zlib.net/zlib-1.2.11.tar.gz 
    # wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
    # wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
    # wget http://tengine.taobao.org/download/tengine-2.3.0.tar.gz
    

    1.2【在线方式】(推荐方式,配置Centos 7网络自动下载)

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

    1.3【操作日志预览】

    1.3.1 【yum install gcc-c++】 需要输入一次y 继续下载安装

    [root@ip104 ~]#  yum install gcc-c++
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    ..............................等待,需要输入一次y 继续下载安装............................
    Total download size: 31 M
    Is this ok [y/d/N]: y
    Downloading packages:
    ..............................等待............................
    Complete!
    

    1.3.2 【yum -y install pcre pcre-devel 】

    [root@ip104 ~]# yum -y install pcre pcre-devel 
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    ..............................等待............................
    Complete!
    
    

    1.3.3【yum -y install zlib zlib-devel】

    [root@ip104 ~]#  yum -y install zlib zlib-devel
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Package zlib-1.2.7-18.el7.x86_64 already installed and latest version
    .............................等待............................
    Complete!
    
    

    1.3.4【yum -y install openssl openssl-devel】

    [root@ip104 ~]#  yum -y install openssl openssl-devel
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Resolving Dependencies
    ..............................等待............................
    Complete!
    

    2、解压安装包并安装软件(使用离线或者在线方式)

    2.1 下载Tengine

     cd /usr/local/src/
     
     wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
     
     ls
    

    2.2 解压压缩生成编译(一条一条来)

    tar -zxvf tengine-2.3.2.tar.gz
    
    cd /usr/local/src/tengine-2.3.2
    
    ./configure 
    
    make
    
    sudo make install
    
    

    2.3 解压安装包

    [root@ip104 ~]# cd /usr/local/src/
    [root@ip104 src]#  wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
    --2019-10-01 12:37:03--  http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
    Resolving tengine.taobao.org (tengine.taobao.org)... 140.205.172.18
    Connecting to tengine.taobao.org (tengine.taobao.org)|140.205.172.18|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2835884 (2.7M) [application/octet-stream]
    Saving to: ‘tengine-2.3.2.tar.gz’
    
    100%[==============================================>] 2,835,884    531KB/s   in 5.3s   
    
    2019-10-01 12:37:08 (521 KB/s) - ‘tengine-2.3.2.tar.gz’ saved [2835884/2835884]
    
    [root@ip104 src]# ls
    tengine-2.3.2.tar.gz 
    
    

    2.4 操作日志预览

    --------下载安装包--------
    [root@ip104 tengine-2.3.2]# cd /usr/local/src/
    [root@ip104 src]# ls
    rarlinux-x64-5.4.0.tar.gz  tengine-2.3.2  tengine-2.3.2.tar.gz
    [root@ip104 src]# 
    --------编译安装--------
    [root@ip104 tengine-2.3.2]# cd /usr/local/src/tengine-2.3.2
    [root@ip104 tengine-2.3.2]# ls
    AUTHORS.te  CHANGES.cn  configure  html      man      packages         tests
    auto        CHANGES.te  contrib    LICENSE   modules  README.markdown  THANKS.te
    CHANGES     conf        docs       Makefile  objs     src
    [root@ip104 tengine-2.3.2]# 
    

    3、配置Tengine并运行

    Tengine完全兼容Nginx,因此可以参照Nginx的方式来配置Tengine。我们在此只列出Tengine中值得注意的功能。关于详细的Tengine的相对于Nginx的差别,可以访问变更列表。

    3.1 配置后台服务

    • 输入以下命令
    vi /lib/systemd/system/nginx.service 
    
    
    • 输入以下编辑内容。按键:esc 输入 :wq 保存配置文件
    #配置 Tengine config
    [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/nginx/logs/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    
    ------启动nginx服务
    systemctl start nginx.service
    ------设置开机自启动
    systemctl enable nginx.service
    ------停止开机自启动
    # systemctl disable nginx.service
    ------查看服务当前状态
    systemctl status nginx.service
    ------重新启动服务
    systemctl restart nginx.service
    ------查看所有已启动的服务
    systemctl list-units --type=service
    

    3.2 操作日志

    [root@ip104 src]# vi /lib/systemd/system/nginx.service 
    [root@ip104 src]# systemctl start nginx.service
    [root@ip104 src]# systemctl status nginx.service
    ● nginx.service - The nginx HTTP and reverse proxy server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
       Active: active (running) since Tue 2019-10-01 13:09:43 CST; 7s ago
      Process: 8441 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
      Process: 8439 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
     Main PID: 8444 (nginx)
        Tasks: 2
       Memory: 1.5M
       CGroup: /system.slice/nginx.service
               ├─8444 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/ngi...
               └─8445 nginx: worker process
    
    Oct 01 13:09:43 ip104 systemd[1]: Starting The nginx HTTP and reverse proxy server...
    Oct 01 13:09:43 ip104 nginx[8439]: nginx: the configuration file /usr/local/nginx/... ok
    Oct 01 13:09:43 ip104 nginx[8439]: nginx: configuration file /usr/local/nginx/conf...ful
    Oct 01 13:09:43 ip104 systemd[1]: Started The nginx HTTP and reverse proxy server.
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@ip104 src]# 
    
    

    至此结束,看到以下命令表示成功配置

                                Welcome to tengine!
                  If you see this page, the tengine web server is successfully 
                  installed and working. Further configuration is required.
    
                  For online documentation and support please refer to tengine.taobao.org.
    
                  Thank you for using tengine.
    
    

    4、相关操作命令,扩展安装Nginx

    4.1 介绍 PCRE (http://www.pcre.org/)

    PCRE 下载地址:
    ftp://ftp.pcre.org/pub/pcre/

    https://ftp.pcre.org/pub/pcre/

    4.2 下载安装包、解压软件、编译安装

    [root@ip104 src]# cd /usr/local/src/
    [root@ip104 src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
    [root@ip104 src]# tar zxvf pcre-8.35.tar.gz
    [root@ip104 src]# cd pcre-8.35
    [root@ip104 pcre-8.35]# ./configure
    [root@ip104 pcre-8.35]# make && make install
    

    4.3 安装Nginx

    [root@ip104 src]# cd /usr/local/src/
    [root@ip104 src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
    [root@ip104 src]# tar zxvf nginx-1.6.2.tar.gz
    [root@ip104 src]# cd nginx-1.6.2
    [root@ip104 nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
    [root@ip104 nginx-1.6.2]# make
    [root@ip104 nginx-1.6.2]# make install
     
    

    4.3 Nginx 和 Tenginx 配置文件

    vi /usr/local/nginx/conf/nginx.conf
    
    server {
        listen        80;
        server_name   example.com *.example.com;
        location / {
            proxy_pass         http://localhost:5000;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection keep-alive;
            proxy_set_header   Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Proto $scheme;
        }
    }
    
    
    --重新启动
    systemctl restart nginx
    --查看状态
    systemctl status nginx
    

    4.4 Nginx 和 Tenginx 查询配置

    [root@ip104 ~]# cd /usr/local/nginx/sbin
    [root@ip104 sbin]# ./nginx -V
    Tengine version: Tengine/2.3.2
    nginx version: nginx/1.17.3
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments:
    [root@ip104 sbin]# 
    

    其他说明

    相关资源后续更新

    Linux常用命令

    touch .bash_profile。配置环境变量
    
    java -verbose-查看jdk安装路径
    
    java -version-查看jdk版本
    
    vim-编辑
    
    pwd-查看当前工作路径
    
    su root -切换到root下
    
    netstat -ntlp //查看当前所有tcp端口
    
    ps -ef | grep //查看进程号
    
    ps命令将某个进程显示出来
    
    
  • 相关阅读:
    爬虫案例-爬运维工单
    pandas数据库mysql交互
    pandas数据分析之三:数据重塑与轴向转化、数据分组与分组运算、离散化处理、多数据文件合并操作
    pandas数据分析之二:数据格式转换、排序、统计、函数
    pandas数据分析之一:数据类型及读写
    pandas的透视表pivot_table使用及筛选
    HTML5+CSS3学习笔记(一) 概述
    HTML5+CSS3学习笔记(二) 页面布局:HTML5新元素及其特性
    HTML基础笔记
    Linux札记1- centos7 桌面GNOME安装,语言设置,hostname设置
  • 原文地址:https://www.cnblogs.com/sopcce/p/11615294.html
Copyright © 2020-2023  润新知