• nginx安装部署


    nginx的三种安装方式

    一 epol源安装 直接yum

    [root@web01 ~]# yum install -y nginx
    

    二 源码安装

    1下载依赖

    [root@web03 ~]# yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake wget httpd-tools vim tree
    

    2下载或者上传包

    [root@web03 ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
    #或者
    [root@web03 ~]# rz nginx-1.18.0.tar.gz
    

    3解压

    tar xf nginx-1.18.0.tar.gz  
    

    4生成

    [root@web03 ~]# cd nginx-1.18.0/
    [root@web03 ~/nginx-1.18.0]# ./configure --prefix=/usr/local/nginx-1.18.0 --user=www --group=www --with-http_addition_module --with-http_auth_request_module --without-http_gzip_module
    

    5#编译安装

    [root@web03 ~/nginx-1.18.0]# make && make install
    

    6配置system管理

    [root@web03 ~]# vim /etc/systemd/system/nginx.service 
    [Unit]
    Description=nginx - high performance web server
    After=network.target remote-fs.target nss-lookup.target
    [Service]
    Type=forking
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s stop
    [Install]
    WantedBy=multi-user.target
    

    7做软链接

    [root@web03 ~]# ln -s /usr/local/nginx-1.18.0 /usr/local/nginx
    
    #配置环境变量
    [root@web03 ~]# cat /etc/profile.d/nginx.sh 
    export PATH=/usr/local/nginx/sbin/:$PATH
    
    
    #1.配置环境变量可以不加版本号
    #2.配置system启动可以不加版本号
    #3.升级直接切换软连接的链接文件即可
    

    8启动

    [root@web03 ~]# systemctl daemon-reload
    [root@web03 ~]# systemctl start nginx
    #配置开机自启
    [root@web03 ~]# systemctl enable nginx
    

    三 官方源安装

    1 配置官方源

    [root@web02 ~]# vim /etc/yum.repos.d/nginx.repo 
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/7/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    module_hotfixes=true
    

    2安装依赖

    [root@web02 ~]# yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake wget httpd-tools vim tree
    

    3 安装nginx

    [root@web02 ~]# yum install -y nginx
    

    **4启动 **

    [root@web02 ~]# systemctl restart nginx
    

    5验证启动

    [root@web02 ~]# ps -ef | grep nginx
    
  • 相关阅读:
    头指针与头结点的异同
    C:Users用户名AppData里面的文件可以删除吗
    mac os x在PC上安装
    迷宫问题
    对称自反传递
    判断
    离散实验模板
    离散实验二
    tp.5.0.21抛出错误
    php复制整个文件夹,此方法可过滤掉.svn文件夹
  • 原文地址:https://www.cnblogs.com/GAO321/p/15238969.html
Copyright © 2020-2023  润新知