zoukankan      html  css  js  c++  java
  • nginx自动安装脚本

    本次环境为centos7,本人小菜鸟一只,希望各位大佬提出宝贵的意见,小弟谢谢了!!!

    #!/bin/bash
    echo "安装必要的依赖环境"
    yum install -y gcc gcc-c++ make
    echo "下载相关库文件和nginx安装包"
    wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
    wget http://www.zlib.net/zlib-1.2.11.tar.gz
    wget https://ftp.pcre.org/pub/pcre/pcre-8.33.tar.gz
    wget http://nginx.org/download/nginx-1.14.0.tar.gz
    echo "解压并安装库文件"
    #安装pcre库
    temp_path=/root/nginx
    install_path=/usr/local/nginx
    rm -rf $temp_path
    rm -rf $install_path
    mkdir $temp_path
    mkdir $install_path
    tar -xvf pcre-8.33.tar.gz -C $temp_path
    cd /root/nginx/pcre-8.33
    ./configure --prefix=/usr/local/nginx/pcre
    make && make install
    cd -
    #安装openssl库
    tar -xvf openssl-1.1.1.tar.gz -C $temp_path
    cd /root/nginx/openssl-1.1.1
    ./config --prefix=/usr/local/nginx/openssl
    make && make install
    cd -
    #安装zlib库
    tar -xvf zlib-1.2.11.tar.gz -C $temp_path
    cd /root/nginx/zlib-1.2.11
    ./configure --prefix=/usr/local/nginx/zlib
    make && make install
    cd -
    #安装nginx
    tar -xvf nginx-1.14.0.tar.gz -C $temp_path
    cd /root/nginx/nginx-1.14.0
    ./configure --prefix=/usr/local/nginx/nginx
    make && make install
    cd /usr/local/nginx/nginx/sbin
    ./nginx
    netstat -ntlp
    echo "complete!"
    echo "#######################"
    echo "将nginx加入环境变量"
    
    
    cat >> /etc/profile << EOF
    
    NGINX_HOME=/usr/local/nginx/nginx
    PATH=$NGINX_HOME/sbin:$PATH
    export PATH
    
    EOF
    source /etc/profile
    #这里是为了验证配置的环境是否生效
    
    /usr/local/nginx/nginx/sbin/nginx
    /usr/local/nginx/nginx/sbin/nginx -V
    #配置开机启动命令
    qidong_path=/lib/systemd/system/nginx.service
    touch $qidong_path
    cat > $qidong_path << EOF
    [Unit]
    Description=nginx
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/usr/local/nginx/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/nginx/sbin/nginx reload
    ExecStop=/usr/local/nginx/nginx/sbin/nginx quit
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl start nginx
    systemctl status nignx

     版本信息:2020/09/08修改

  • 相关阅读:
    PE格式详细讲解10 系统篇10|解密系列
    复杂的数据类型1 C++快速入门07
    复杂的数据类型2 C++快速入门08
    复杂的数据类型2 C++快速入门08
    复杂的数据类型1 C++快速入门07
    PE格式详细讲解10 系统篇10|解密系列
    Win32基础知识1 Win32汇编语言002
    开题篇 Win32汇编语言001
    开题篇 Win32汇编语言001
    Win32基础知识1 Win32汇编语言002
  • 原文地址:https://www.cnblogs.com/maohai-kdg/p/13452968.html
Copyright © 2011-2022 走看看