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
    
    
    
  • 相关阅读:
    ios9 之后 配置百度地图出现的错误
    While reading XXX pngcrush caught libpng error: N
    主题:Java WebService 简单实例
    win7下如何建立ftp服务器
    64.Minimum Path Sum
    63.Unique Path II
    62.Unique Paths
    32.Longest Valid Parenttheses
    105.Construct Binary Tree from Preorder and Inorder Traversal
    83.Remove Duplicates from Sorted List
  • 原文地址:https://www.cnblogs.com/jpfss/p/9717303.html
Copyright © 2011-2022 走看看