zoukankan      html  css  js  c++  java
  • 1.18.0 nignx 编译安装

    安装依赖

     yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
    

    解压

     tar xf nginx-1.18.0.tar.gz -C /data/
    

    创建虚拟用户

    useradd www -s /sbin/nologin/ -M
    

    编译

    ./configure --prefix=/data/nginx-1.18.0 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
    

    安装

    make && make install
    

    软链接

    ln  -s /data/nginx-1.18.0 /data/nginx
    

    精简nginx 配置

    grep -Ev "#|^$" nginx.conf.default >nginx.conf
    

    添加环境变量

    cat /etc/profile.d/nginx.sh

    PATH=$PATH:/data/nginx/bin/:/data/nginx/sbin
    

    加载环境变量

    source /etc/profile
    

    添加system 启动方式

    cat <<EOF> /usr/lib/systemd/system/nginx.service 
    [Unit]
    Description=nginx
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/data/nginx/sbin/nginx
    ExecReload=/data/nginx/sbin/nginx -s reload
    ExecStop=/data/nginx/sbin/nginx -s quit
    PrivateTmp=true
    #EnvironmentFile=/etc/sysconfig/rdisc
    #ExecStart=/sbin/rdisc $RDISCOPTS
    
    [Install]
    WantedBy=multi-user.target
    EOF
    

    加载 启动方式

    systemctl daemon-reload

    配置虚拟主机

    vim /data/nginx/conf/nginx.conf

    
    worker_processes  1;
    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  data/octet-stream;
        sendfile           on;
        server_tokens      off;
        keepalive_timeout  65;
        server {
                listen       80;
                server_name  ;
                location / {
                    root   html;
                    index  index.html index.htm;
                }
                error_page   500 502 503 504  /50x.html;
                location = /50x.html {
                root   html;
                }
            }
    }
    

    启动命令

    systemctl restart nginx
    

    停止命令

    systemctl stop nginx
    

    重启命令

    systemctl restart nginx
    
  • 相关阅读:
    (29)zabbix执行远程命令
    (28)zabbix用户宏变量详解macro
    CentOS7安装Nginx及配置
    Open-Falcon 监控系统监控 MySQL/Redis/MongoDB 状态监控
    Centos7安装ansible
    Centos7部署open-falcon 0.2
    Centos7安装redis
    vim常用命令
    CentOS7安装配置Bacula yum方法
    CentOS7时间同步
  • 原文地址:https://www.cnblogs.com/zongliang-ya/p/14519120.html
Copyright © 2011-2022 走看看