nginx自动化部署脚本
使用方法:
将nginx的源码包解压到本地目录,然后将这个脚本拷贝到解压出来的nginx目录中执行
执行方式:
sh nginx_install.sh $1 $2 $1为安装目录,$2为nginx端口
注意:目录路径后不能有斜杠
安装脚本:
#!/bin/bashDIR=$1
Port=$2
jp=`netstat -antp | awk '{print $4}' | grep -w "$Port" | wc -l`if [ "$1" = "" ];thenecho 'please print install directory:$1'exit 99
elif [ "$2" = "" ];thenecho 'please print nginx port:$2'exit 99
fipot(){
if [ $jp != 0 ];thenecho "!!The port is exist,please replace!!"exit 99
elseecho "The port is no problem"
fi
}Dire(){
if [ ! -d $DIR ];thenecho "Set directory now"mkdir -p $DIR
elseecho "The directory is exist"
fi
}user(){
id nginx &>/dev/null
if [ $? != 0 ];thenecho "Set nginx user now"useradd nginx
elseecho "Nginx user is exist"
fi
}Appli(){
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
}confi(){
make clean
./configure \
--prefix=$DIR \
--sbin-path=$DIR/sbin/nginx \
--modules-path=$DIR/modules \
--conf-path=$DIR/conf/nginx.conf \
--error-log-path=$DIR/log/error.log \
--http-log-path=$DIR/log/access.log \
--pid-path=$DIR/nginx.pid \
--lock-path=$DIR/nginx.lock \
--http-client-body-temp-path=$DIR/client_temp \
--http-proxy-temp-path=$DIR/proxy_temp \
--http-fastcgi-temp-path=$DIR/fastcgi_temp \
--http-uwsgi-temp-path=$DIR/uwsgi_temp \
--http-scgi-temp-path=$DIR/scgi_temp \
--with-compat \
--user=nginx \
--group=nginx \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \make && make install
if [ $? != 0 ];thenecho "!!Make fail,please check!!"exit 99
elseecho "make successful,please next step"
fi
}File(){
mv $DIR/nginx/conf/nginx.conf $DIR/nginx/conf/nginx_defaults.conf
cat >$DIR/nginx/conf/nginx.conf <<EOF
user nginx;
worker_processes auto;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;server_tokens off;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;access_log $DIR/nginx/log/access.log;error_log $DIR/nginx/log/error.log;server {listen $Port;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}}
EOF
}fir(){
$DIR/nginx/sbin/nginx
if [ $? = 0 ];thenecho "The nginx firing successful"
elseecho "!!The nginx firing failed,please check!!"exit 99
fi
}PRO(){
proce=`ps -ef | grep "nginx" | grep -v "color" | wc -l`
if [ "$proce" = 0 ];thenecho "!!Not to find nginx process.please check!!"
elseecho "The nginx process exist,finish to install nginx"
fi
}Tot(){
pot
Dire
user
Appli
confi
File
fir
PRO
}Tot
个人技术文档分享网站,有关于linux运维相关的学习资料:
https://opszzfwordpress.club/
nginx自动化部署脚本相关推荐
- linux如何自动化部署脚本实现免密登录并访问资源
任务把weijie主机jdk文件安装到weijie1中. 首先再各台主机中安装必要的命令: expect.wget.httpd.ssh 执行命令 如:expect提示命令不存在,则分别安装命令 yum ...
- 第一章【Oracle自动化部署脚本】诞生
作者简介 作者:LuciferLiu,中国DBA联盟(ACDU)成员. 目前从事Oracle DBA工作,曾从事 Oracle 数据库开发工作,主要服务于生产制造,汽车金融等行业. 现拥有Oracle ...
- Mysql安装及自动化部署脚本方案
一.简介 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库, 每个数据库都有一个或多个不同的API用于创建,访问,管理,搜索和复制所保存的数据. 我们也可以将数据存储在文件中,但是 ...
- linux创建脚本文件auto,linux 自动化部署脚本
1 概述 在工作中,需要对环境中的机器打补丁或者安装软件.如果机器太多,有可能会漏掉机器,或者有些机器上版本不一致.如果能实现同一的部署,不仅能降低人为导致的错误,而且能大大提高工作效率 本文,我将介 ...
- linux nexus启动_Linux一键部署Nexus 3私服仓库自动化部署脚本
此脚本是Linux一键部署Nexus 3私服仓库自动化脚本,有需要朋友可以参考,脚本内容如下: 环境准备: 操作系统:CentOS Linux release 7.8.2003 软件版本: Docke ...
- 服务器部署项目脚本,写一个自动化部署脚本
.sh脚本一键部署 打游戏用过一键无敌 正好这几天熟悉新项目 我就把之前的./push.sh迁移了过来 顺便 写了个自动化构建并提交到服务器的.sh脚本 一.背景 先是一个git的提交脚本 因为每次提 ...
- Nginx自动化部署Let‘s Encrypt证书并续期
HTTP和HTTPS分别是什么 HTTP协议是超文本传输协议的缩写,英文是Hyper Text Transfer Protocol.它是从WEB服务器传输超文本标记语言(HTML)到本地浏览器的传送协 ...
- 自动化部署脚本,给每一台主机装上JDK,且配好环境变量
centos6.7 当我们有很多台主机,想在每台机器上都安装一样的某些软件,当然,一台机器一台机器安装也是可以的,但是如果有一键安装所有机器上的软件那是不是很激动人心呢! 首先我们需要制作一台服务器, ...
- 自动化部署脚本开启所有zookpeer等服务
1.为了方便ssh连接,最好把所有的主机之间实现免密登录 ssh-keygen sh-copy-id 主机名 2.在根目录下新建bin文件夹,并创建部署的脚本start.sh #!/bin/bash ...
最新文章
- 用OpenCV玩《铁拳》!!!
- Gartner:为什么每一位首席执行官都应重视物联网并为其投资?
- 16 BasicHashTable基本哈希表类(三)——Live555源码阅读(一)基本组件类
- 安装python后如何打开-Python的安装与使用
- 【OPENGL】第三篇 着色器基础(一)
- 程序员职场第二次课笔记 9.9号
- SPIFFS文件系统移植–基于STM32F407
- Read a large file with python
- Java客户端操作elasticsearch--查询索引库(高亮显示)
- VTK:几何对象之OpenVROrientedCylinder
- WIN2003下×××服务器架设攻略
- python-study-12
- 雪儿--北京欢迎你!!!
- Maven - 构建与命令
- python猴子偷桃递归_C++猴子偷桃问题
- java data文件夹_java-如何在不指定父文件夹/ ref的情况下遍历Datasnapshot
- ATL之深入浅出书评(转)
- 大数据人才成了“香饽饽”
- 经典C语言编程100例——题目+答案代码(完结)
- Python之仓库管理系统
热门文章
- ## STM32F103的光照、烟雾MQ2、有毒气体MQ135的ADC配置(寄存器版与库函数版
- Nat. Methods | 基于机器学习和生物物理的蛋白质-肽相互作用预测
- oracle如何查询临时表空间,Oracle查询临时表空间的占用
- gte、lte、gt、lt 缩写的含义
- php header 302 move,302 Moved Temporarily和302 Found有什么区别?
- TextView使用textApperance属性设置字体颜色失效
- MTK 电池曲线配置【转】
- 《工程电磁场》学习笔记5-准静态电磁场
- 一个人的成功不是没有理由的!(人物之楼天城)
- 微型计算机的主要技术性能指标,微型计算机的主要性能指标