#!/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 "\033[32mThe nginx server already installd ,please exit.\033[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 "\033[32m Please check nginx config file\033[0m"
exit
fi
else
echo -e "\033[32m Please install nginx server \033[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 "\033[32m The nginx server install successfully.\033[0m"
else
echo -e "\033[32m The nginx server install failed,please check\033[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 "\033[32m Please check nginx config file\033[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 "\033[32m Please check nginx config file\033[0m"
exit
fi
fi

shell自动化下载、安装、配置nginx的更多相关文章

  1. ELK 6安装配置 nginx日志收集 kabana汉化

    #ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...

  2. (转)windows 下安装配置 Nginx 详解

    windows 下安装配置 Nginx 详解 本文转自https://blog.csdn.net/kingscoming/article/details/79042874 nginx功能之一可以启动一 ...

  3. nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站

    一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...

  4. AntSword 中国蚁剑的下载安装配置(附下载文件)

    文章更新于:2020-04-11 按照惯例,需要的文件附上链接放在文首. 文件一: antSword-2.1.8.1.zip.7z 文件大小: 14.3 MB 下载链接: 中国蚁剑 v2.1.8.1 ...

  5. win10 DVWA下载安装配置(新手学渗透)

    电脑重装系统了,需要重新装一下渗透测试的学习环境DVWA,借此机会就跟大家讲一下DVWA的安装过程,因为不同的电脑配置.环境不同,在我的电脑上按照我这个安装教程是一次性就安装好了的.如果安装的时候遇到 ...

  6. Jmeter下载安装配置及使用(windows)

    1 前言 仅作为记录使用. 2 步骤 2.1 下载地址:http://jmeter.apache.org/download_jmeter.cgi 2.2 选择binary版本即可:apache-jme ...

  7. 01_2Java开发环境的下载 安装 配置

    01_2Java开发环境的下载 安装 配置 l 配置Java开发环境步骤(WindowsXP) l 下载并按照最新版本的J2SDK l 设置Windows环境变量 l 选择合适的文本编辑器或使用集成开 ...

  8. 2019-03-18 OpenCV Tesseract-OCR 下载 安装 配置(cv2 报错)

    OpenCV 下载 安装 配置 1.下载和Python版本对应的版本,此为下载地址 2.安装(在powershell管理员模式下安装) pip3 install .\opencv_python-3.4 ...

  9. 从零开始使用git第一篇:下载安装配置

    从零开始使用git 第一篇:下载安装配置 第一篇:从零开始使用git第一篇:下载安装配置 第二篇:从零开始使用git第二篇:git实践操作 第三篇:从零开始使用git第三篇:git撤销操作.分支操作和 ...

  10. JDK下载安装配置教程(详细)

    JDK下载安装配置教程(详细) 版权声明:本文为原创文章,转载请附上原文出处链接和本声明.https://www.cnblogs.com/mxxbc/p/11844885.html 因为最近需要在Wi ...

随机推荐

  1. 基于ContentObserver来动态取消或加入屏幕超时任务

    前面也说了.ContentObserver能够来监控数据库里某一项数据的变化,当然也能够同一时候监控多个数据项的变化. 笔者在项目中须要改动到屏幕超时的需求,比方在车载业务中,倒车事件发生的时候,是不 ...

  2. jmeter--使用badboy录制脚本

    JMeter录制脚本有多种方法,其中最常见的方法是用第三方工具badboy录制,另外还有JMeter自身设置(Http代理服务器+IE浏览器设置)来录制脚本,但这种方法录制出来的脚本比较多且比较乱,个 ...

  3. BAT面试常的问题和最佳答案

    原标题:BAT面试常的问题和最佳答案 技术面试 1.servlet执行流程 客户端发出http请求,web服务器将请求转发到servlet容器,servlet容器解析url并根据web.xml找到相对 ...

  4. 使用ClassyShark压缩你的项目

    原文链接 : Shrinking Your Build With No Rules and do it with Class(yShark) 原文作者 : Roberto Orgiu 译文出自 : 开 ...

  5. [CSS3] Create a fixed-fluid-fixed layout using CSS calc()

    CSS calc() allows you to mix and match units to get real-time calculations. It's useful when you nee ...

  6. POJ 3090 Visible Lattice Points (ZOJ 2777)

    http://poj.org/problem?id=3090 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1777 题目大意: ...

  7. 【record】11.14..11.20

    balabala

  8. excel转换成oracle建表脚本

    package excel2sql; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundE ...

  9. php array数组的相关处理函数and str字符串处理与正则表达式

    下面给各位同学整理了一些关于php array数组的相关处理函数and str字符串处理与正则表达式,希望文章对你会有所帮助.   数组的相关处理函数: 1)数组的键值操作函数 array_value ...

  10. 在SSMS查询分析器中显示行号

    有网友问及,看到Insus.NET帮他解决问题分享的截屏时,发现代码中有显示行号.而他的没有. Step1: Go to Tools > Options Step2: In the Option ...