shell脚本一键安装nginx
依赖包安装包放在一起, 直接执行这个脚本就行。
#!/bin/bash
#------------------------------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------------------------------#
#| chenglee public nginx |#
#| version: nginx-1.9.10 |#
#| version: openssl-1.1.0f |#
#| version: pcre-8.40 |#
#| version: zlib-1.2.11 |#
#| 2018.12.04 |#
#------------------------------------------------------------------------------------------------------------------#
#| Some people die at the age of 25 and don't bury themselves in the earth until they are 75 |#
#------------------------------------------------------------------------------------------------------------------#
#| $$$$ $$ $$ $$$$$$ $$ $$ $$$$$$ $$ $$$$$$ $$$$$$ |#
#| $$ $$ $$ $$ $$ $$ $$ $$ $$ $$ $$ |#
#| $$ $$$$$$$ $$$$$ $$ $$ $ $$ $$$$$$ $$ $$$$$ $$$$$ |#
#| $$ $$ $$ $$ $$ $ $ $$ $$ $$ $$ $$ |#
#| $$$$ $$ $$ $$$$$$ $$ $$ $$$$$ $$ $$$$$$ $$$$$$ $$$$$$ |#
#------------------------------------------------------------------------------------------------------------------#
K_NGINX="nginx-1.9.10.tar.gz"
K_PCRE="pcre-8.40.tar.gz"
K_OPENSSL="openssl-1.1.0f.tar.gz"
K_ZLIB="zlib-1.2.11.tar.gz"
PRENAME="nginx"
installpath=$(cd `dirname $0`; pwd) function environment(){
echo "-----------------------------------------------------------------------"
echo "------------------------ check gcc ----------------------------------"
echo "-----------------------------------------------------------------------"
GCCBIN=`which gcc`
GCCV=$(echo $GCCBIN | grep "gcc")
if [[ "$GCCV" != "" ]]
then
echo "gcc was installed "
else
echo "install gcc"
yum install gcc gcc-c++ -y >/dev/null 2>&1
fi
} function initialize(){
installpath=$(cd `dirname $0`; pwd)
cd ${installpath}
cd ${PRENAME}/lib/openssl* && OPENSSLPATH=`pwd`
cd ${installpath}
cd ${PRENAME}/lib/pcre* && PCREPATH=`pwd`
cd ${installpath}
cd ${PRENAME}/lib/zlib* && ZLIBPATH=`pwd`
cd ${installpath}
} function installssl(){
echo "-----------------------------------------------------------------------"
echo "---------------------- install openssl ------------------------------"
echo "-----------------------------------------------------------------------"
mkdir -p logs ${PRENAME}/lib && touch logs/{openssl.log,pcre.log,zlib.log,nginx.log}
#openss
tar -zxvf ${K_OPENSSL} -C ${PRENAME}/lib >/dev/null 2>&1
cd ${PRENAME}/lib/openssl* && OPENSSLPATH=`pwd`
./config --prefix=${OPENSSLPATH} >${installpath}/logs/openssl.log >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
return 1
else
make && make install >${installpath}/logs/openssl.log
if [[ $? -ne 0 ]]; then
return 1
fi
return 0
fi
}
function installpcre(){
echo "-----------------------------------------------------------------------"
echo "---------------------- install pcre ---------------------------------"
echo "-----------------------------------------------------------------------"
#pcre
cd ${installpath}
tar -zxvf ${K_PCRE} -C ${PRENAME}/lib >/dev/null 2>&1
cd ${PRENAME}/lib/pcre* && PCREPATH=`pwd`
./configure --prefix=${PCREPATH} >${installpath}/logs/pcre.log >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
return 1
else
make && make install >${installpath}/logs/pcre.log
if [[ $? -ne 0 ]]; then
return 1
fi
return 0
fi
}
function installzlib(){
echo "-----------------------------------------------------------------------"
echo "---------------------- install zlib ---------------------------------"
echo "-----------------------------------------------------------------------"
#zlib
cd ${installpath}
tar -zxvf ${K_ZLIB} -C ${PRENAME}/lib >/dev/null 2>&1
cd ${PRENAME}/lib/zlib* && ZLIBPATH=`pwd`
./configure --prefix=${ZLIBPATH} >${installpath}/logs/zlib.log >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
return 1
else
make && make install >${installpath}/logs/zlib.log
if [[ $? -ne 0 ]]; then
return 1
fi
return 0
fi
}
function installnginx(){
echo "-----------------------------------------------------------------------"
echo "---------------------- install nginx --------------------------------"
echo "-----------------------------------------------------------------------"
#nginx
cd ${installpath}
initialize
tar -zxvf ${K_NGINX} >/dev/null 2>&1
cd nginx-* && NGINXPATH=`pwd`
./configure --prefix=${installpath}/${PRENAME} --with-pcre=${PCREPATH} --with-openssl=${OPENSSLPATH} --with-zlib=${ZLIBPATH}
if [[ $? -ne 0 ]]; then
return 1
else
make && make install >${installpath}/logs/nginx.log
if [[ $? -ne 0 ]]; then
return 1
fi
return 0
fi
} environment
installssl
installpcre
installzlib
installnginx
shell脚本一键安装nginx的更多相关文章
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15 #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...
- 安装完Ubuntu后通过shell脚本一键安装软件
安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...
- shell脚本一键安装mysql5.7.x
使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...
- shell脚本一键安装mysql5.7.x(免安装版)
使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- shell脚本一键部署nginx
一键部署nginx 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...
- shell脚本一键安装redis集群[最终版]
直接上shell了. #!/bin/bash #---------------------------------------------------------------------------- ...
- shell脚本一键安装jdk
直接上shell #!/bin/bash #offline jdk install ipath="/usr/local" installpath=$(cd `dirname $0` ...
随机推荐
- iOS 开发常用链接总结
知识归纳 1.招聘一个靠谱的程序员 面试题答案 https://github.com/ChenYilong/iOSInterviewQuestions 2.中文 iOS/Mac 开发博客列表 http ...
- React对比Vue(03 事件的对比,传递参数对比,事件对象,ref获取DOM节点,表单事件,键盘事件,约束非约束组件等)
import React from 'react'; class Baby extends React.Component { constructor (props) { super(props) t ...
- setUp和tearDown及setUpClass和tearDownClass的用法及区别
① setup():每个测试函数运行前运行 ② teardown():每个测试函数运行完后执行 ③ setUpClass():必须使用@classmethod 装饰器,所有test运行前运行一次 ④ ...
- Tomcat任意文件上传漏洞CVE-2017-12615
文章来源:https://blog.csdn.net/qq1124794084/article/details/78044756 漏洞影响的tomcat版本为tomcat7.0.0-7.0.81版本 ...
- python入门第一篇
python里面 单行注释用:#被注释内容 多行注释用:"""被注释内容""" 要想py2.7和py3.5都能运行,必须在文件头部加: #/ ...
- UVa-12563 劲歌金曲
题目 https://vjudge.net/problem/Uva-12563 给出n首歌和KTV的剩余时间T,因为KTV不会在时间到的时候立刻把歌切掉,而是会等它放完.而<劲歌金曲>长达 ...
- strlen实现
1.strlen函数. 普通版实现方法, int strlen( char *s) { int length = 0; while(*s++) length++; return length; } 优 ...
- HTTP GET的VC三种方式
一.第一种方式(包装类的方式) a.在VC++添加类,选择typelib b.选择文件:C:\Windows\System32\winhttp.dll 选择到右边生成的类,最后点完成,即产生了一个CW ...
- HighCharts学习笔记(一)
HighChars基本概述 Highcharts是一个纯js写成的插件库,很好的外观表现可以满足任何图标需求. 开始使用chart之前进行配置 全局配置: Highcharts.setOptions( ...
- html5 随机数函数
function selec(low,high){var ch=high-low+1;return Math.floor(Math.random()*ch+low);}for (var i = 0; ...