zoukankan      html  css  js  c++  java
  • Nginx 编译安装-1.61.1

    准备编译安装基础环境

    [root@node1 ~]# yum install -y vim lrzsz tree screen psmisc lsof tcpdump wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed

    解压缩 nginx 包

    [root@node1 ~]# tar xf nginx-1.16.1.tar.gz

    编译安装

    [root@node1 ~]# cd nginx-1.16.1/

    [root@node1 nginx-1.16.1]# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-debug

    [root@node1 nginx-1.16.1]# make && make install

    创建 nginx 系统账户

    [root@node1 ~]# useradd nginx -s /sbin/nologin

    更改 nginx 安装目录所属主和所属组为 nginx

    [root@node1 ~]# chown nginx.nginx -R /apps/nginx

    编写 nginx 自启动脚本

    [root@node1 ~]# vim /usr/lib/systemd/system/nginx.service

    [Unit]
    Description=The nginx HTTP and reverse proxy server
    After=network.target remote-fs.target nss-lookup.target

    [Service]
    Type=forking
    PIDFile=/apps/nginx/logs/nginx.pid
    # Nginx will fail to start if /run/nginx.pid already exists but has the wrong
    # SELinux context. This might happen when running `nginx -t` from the cmdline.
    # https://bugzilla.redhat.com/show_bug.cgi?id=1268621
    ExecStartPre=/usr/bin/rm -f /apps/nginx/logs/nginx.pid
    ExecStartPre=/apps/nginx/sbin/nginx -t
    ExecStart=/apps/nginx/sbin/nginx
    ExecReload=/bin/kill -s HUP $MAINPID
    KillSignal=SIGQUIT
    TimeoutStopSec=5
    KillMode=process
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target

    启动 nginx,并设为开机自启

    [root@node1 ~]# systemctl daemon-reload

    [root@node1 ~]# systemctl start nginx

    [root@node1 ~]# ss -ntl

    State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              

     LISTEN     0     100     127.0.0.1:25                          *:*               

     LISTEN     0     128             *:111                         *:*               

     LISTEN     0     128             *:80                          *:*               

     LISTEN     0     128             *:22                          *:*               

     LISTEN     0     100         [::1]:25                       [::]:*               

     LISTEN     0     128          [::]:111                      [::]:*               

     LISTEN     0     128          [::]:22                       [::]:*               

    [root@node1 ~]# systemctl enable nginx

    Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

     
  • 相关阅读:
    excel导入数据库表
    C# WinForm通过WebClient实现文件上传下载
    C#中的多线程——线程同步基础
    document.body.scrollTop为0的处理办法
    C#利用短信猫收发短信息的方法
    XML Serializable Generic Dictionary
    Making IE use PNG Alpha transparency
    String[3]: the Size property has an invalid size of 0.
    input style兼容IE6的方案
    安装window service 中出现Set Service Login对话框
  • 原文地址:https://www.cnblogs.com/d1anlong/p/11869663.html
Copyright © 2011-2022 走看看