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

  • 相关阅读:
    JAVA的泛型与反射的联合应用
    jsp文件过大,is exceeding 65535 bytes limit
    Eclipse闪退解决方案
    EL中定义函数
    JAVA开发工作流程
    理解HTTP协议
    umask函数
    utime修改文件的存取,修改时间
    Linux C ftruncate 函数清空文件注意事项(要使用 lseek 重置偏移量)
    如何实现多进程写一个文件
  • 原文地址:https://www.cnblogs.com/maohai-kdg/p/13452968.html
Copyright © 2011-2022 走看看