centos配置tengine

作者: 778878net | 来源:发表于2018-02-10 11:21 被阅读5次

    yum update

    yum install gcc gcc-c++ autoconf automake

    ============安装pcre

    cd /usr/local/src

    wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

     tar zxvf pcre-8.38.tar.gz

     mkdir /usr/local/pcre  

     cd pcre-8.38

     ./configure    

     make

    make install

    ============安装openssl

    cd /usr/local/src

    wgethttp://www.openssl.org/source/openssl-1.0.1h.tar.gz

    tar zxvf openssl-1.0.1h.tar.gz

    cd openssl-1.0.1h

    ./config

    make && make install

    ==========

    cd /usr/local/src

    wget http://www.zlib.net/zlib-1.2.11.tar.gz

    tar zxvf zlib-1.2.11.tar.gz

    cd zlib-1.2.11

    ./configure 

    make && make install

    ======

    cd /usr/local/src

    wget https://github.com/jemalloc/jemalloc/releases/download/5.0.1/jemalloc-5.0.1.tar.bz2

    tar jxvf jemalloc-5.0.1.tar.bz2

    cd jemalloc-5.0.1

    ./configure

    make && make install

    ============== 

    groupadd www-data

    useradd -s /sbin/nologin -g www-data www-data

     ==============================================安装tenginx

    cd /usr/local/src

    wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz

    tar

     -zxvf tengine-2.2.0.tar.gz

    cd tengine-2.2.0

    ./configure --prefix=/opt/nginx --user=www-data --group=www-data --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.11 --with-pcre=/usr/local/src/pcre-8.38 --with-jemalloc=/usr/local/src/jemalloc-4.5.0 --with-http_concat_module=shared 

    make

    make install

    ========================配置

    vim /opt/nginx/conf/nginx.conf

    修改前面几行为:

    user www-data www-data;(内网应该可以直接root root)

    worker_processes 1;

    #error_log logs/error.log crit;

    pid logs/nginx.pid;

    events{

    use epoll;

    worker_connections 65535;

    }

    chmod 400 /root/.ssh/id*

    chown -R www-data:www-data /yigao

    4.7 测试和运行

    [root@centos ~]# cd /opt/nginx

    [root@centos ~]# ldconfig

    [root@centos ~]# ./sbin/nginx -t

    如果显示下面信息,即表示配置没问题

    nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok

    nginx: configuration file /opt/nginx/conf/nginx.conf test is successful

    输入代码运行nginx服务

    [root@centos ~]# ./sbin/nginx

    输入代码检测是否支持加速

    查看是否生效

    [root@centos ~]# lsof -n | grep jemalloc

    ginx 2346 root mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1

    nginx 2347 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1

    nginx 2348 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1

    nginx 2349 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1

    nginx 2350 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1 

    curlhttp://localhost

    ==================

    #停止firewall 

    [root@centos ~]# systemctl stop firewalld.service 

    #禁止firewall开机启动

    [root@centos ~]# systemctl disable firewalld.service

    安装 iptables

    [root@centos ~]# yum install iptables-services 

    设置防火墙规则 (增加80端口)

    [root@centos ~]# vim /etc/sysconfig/iptables

    打开文件,增加80端口那一行

    *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 -j REJECT --reject-with icmp-host-prohibited

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

    COMMIT

    :wq #保存退出

    #重启防火墙使配置生效

    [root@centos ~]# systemctl restart iptables.service

    #设置防火墙开机启动

    [root@centos ~]# systemctl enable iptables.service

     4.9 作为服务,开机后启动

    [root@centos ~]# vim /usr/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=/opt/nginx/logs/nginx.pid

    ExecStartPre=/opt/nginx/sbin/nginx -t

    ExecStart=/opt/nginx/sbin/nginx

    ExecReload=/bin/kill -s HUP $MAINPID

    ExecStop=/bin/kill -s QUIT $MAINPID

    PrivateTmp=true

    [Install]

    WantedBy=multi-user.target

    :wq 保存退出

     [root@centos ~]# systemctl stop tengine

     [root@centos ~]# systemctl start tengine

     [root@centos ~]# systemctl reload tengine

     [root@centos ~]# systemctl enable tengine

     [root@centos ~]# shutdown -r now 

    相关文章

      网友评论

        本文标题:centos配置tengine

        本文链接:https://www.haomeiwen.com/subject/pibuzxtx.html