zoukankan      html  css  js  c++  java
  • shell自动化下载、安装、配置nginx

    #!/bin/bash
    auto config nginx server 
    #by author www.jfedu.net
    #2018年5月14日17:25:52
    
    N_PAR="vim lrzsz perl perl-devel libxml2 libxml2-devel ncurses ncurses-devel gd gd-deve
    l wget gcc gcc-c++ pcre pcre-devel ntp ntpdate openssl openssl-devel"
    N_URL="http://nginx.org/download/nginx-1.14.0.tar.gz"
    N_DIR="nginx-1.14.0.tar.gz"
    N_PATH="nginx-1.14.0"
    N_PREFIX="/usr/local/nginx"
    N_VHOST=$1
    
    if [ -d $N_PREFIX ];then
        echo -e "33[32mThe nginx server already installd ,please exit.33[0m"
        read -p "Enter the number of installd users:" lists
        service iptables stop
        setenforce 0
        systemctl stop firewalld
        ps -ef |grep nginx
        mkdir -p $N_PREFIX/conf/domains
        mkdir -p $N_PREFIX/html/$lists
    cat >$N_PREFIX/html/$lists/index.html<<EOF
        <html>
         <h1> The first test nginx page.<h1>
         <h1> The www.$lists.com test page.<h1>
        <hr color="red">
        </html>
    EOF
    cat >$N_PREFIX/conf/nginx.conf<<EOF
        worker_processes  1;
        events {
            worker_connections  1024;
        }
        http {
            include       mime.types;
            default_type  application/octet-stream;
            sendfile        on;
            keepalive_timeout  65;
            include   domains/*;
        }
    EOF
    cat >$N_PREFIX/conf/domains/www.$lists.com<<EOF
         server {
                listen       80;
                server_name  www.$lists.com;
                location / {
                    root   html/$lists;
                    index  index.html index.htm;
                }
            }
    EOF
    $N_PREFIX/sbin/nginx -t
    if [ $? -eq 0 ];then
            pkill nginx
            $N_PREFIX/sbin/nginx
    else
            echo -e "33[32m Please check nginx config file33[0m"
            exit
    fi
    else
        echo -e "33[32m Please install nginx server 33[0m"
        yum install -y $N_PAR
        ntpdate 1.cn.pool.ntp.org
        cd /usr/src
        wget -c $N_URL
        tar xzf $N_DIR
        cd $N_PATH
        ./configure --prefix=$N_PREFIX --with-http_ssl_module --with-pcre 
    if [ $? -eq 0 ];then
        make && make install
        echo -e "33[32m The nginx server install successfully.33[0m"
    else
        echo -e "33[32m The nginx server install failed,please check33[0m"
        exit
    fi
        ln -s $N_PREFIX/sbin/nginx /usr/local/sbin
        $N_PREFIX/sbin/nginx -t
    if [ $? -eq 0 ];then
        $N_PREFIX/sbin/nginx -s reload
    else
        echo -e "33[32m Please check nginx config file33[0m"
        exit
    fi
    
    read -p "Enter the number of installd users:" lists
        service iptables stop 
        setenforce 0
        systemctl stop firewalld
        ps -ef |grep nginx
        mkdir -p $N_PREFIX/conf/domains
        mkdir -p $N_PREFIX/html/$lists
    cat >$N_PREFIX/html/$lists/index.html<<EOF
        <html>
         <h1> The first test nginx page.<h1>
         <h1> The www.$lists.com test page.<h1>
        <hr color="red">
        </html>
    EOF
    cat >$N_PREFIX/conf/nginx.conf<<EOF
        worker_processes  1;
        events {
            worker_connections  1024;
        }
        http {
            include       mime.types;
            default_type  application/octet-stream;
            sendfile        on;
            keepalive_timeout  65;
            include   domains/*;
    }
    EOF
    cat >$N_PREFIX/conf/domains/www.$lists.com<<EOF
         server {
                listen       80;
                server_name  www.$lists.com;
                location / {
                    root   html/$lists;
                    index  index.html index.htm;
                }
            }
    EOF
        $N_PREFIX/sbin/nginx -t
    if [ $? -eq 0 ];then
        pkill nginx
            $N_PREFIX/sbin/nginx 
    else
            echo -e "33[32m Please check nginx config file33[0m"
            exit
    fi
    fi
    
    
    
  • 相关阅读:
    XAML语言
    Sqlite 数据库插入标示字段 获取新Id 及利用索引优化查询
    提高C#编程水平的50个要点 ——学生的迷茫
    734条高频词组笔记
    C#读取ini配置文件
    MD5加密
    SQL Server 2000 及 2005 端口修改
    Java控制台程序20例
    Tomcat 6.0+ SQL Server 2005连接池的配
    阿里巴巴离职DBA 35岁总结的职业生涯
  • 原文地址:https://www.cnblogs.com/jpfss/p/9717303.html
Copyright © 2011-2022 走看看