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修改

  • 相关阅读:
    kibana.yml(中文配置详解)
    Elasticsearch之marvel(集群管理、监控)插件安装之后的浏览详解
    ElasticSearch vs Lucene多维度分析对比
    ElasticSearch 应用场景
    ElasticSearch 在Hadoop生态圈的位置
    ElasticSearch 工作原理
    ElasticSearch 架构图
    ElasticSearch vs 关系型数据库
    Codeforces Round #311 (Div. 2)
    uva 568(数学)
  • 原文地址:https://www.cnblogs.com/maohai-kdg/p/13452968.html
Copyright © 2011-2022 走看看