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.

     
  • 相关阅读:
    kafka-eagle监控kafka
    ZABBIX自动发现Redis端口并监控
    用Redislive监控redis
    zabbix监控hbase
    zabbix监控zookeeper
    zabbix监控nginx日志状态码
    深入理解JVM-内存溢出案例演示与分析
    深入理解JVM-hotspot虚拟机对象探秘
    java开发手册-总结与补充
    IntelliJ IDEA快速自动生成Junit测试类
  • 原文地址:https://www.cnblogs.com/d1anlong/p/11869663.html
Copyright © 2011-2022 走看看