依赖包安装包放在一起, 直接执行这个脚本就行。

#!/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的更多相关文章

  1. Centos 6.4上面用Shell脚本一键安装vsftpd

    Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...

  2. 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 ...

  3. 安装完Ubuntu后通过shell脚本一键安装软件

    安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...

  4. shell脚本一键安装mysql5.7.x

    使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...

  5. shell脚本一键安装mysql5.7.x(免安装版)

    使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...

  6. Shell脚本一键安装LNMP环境

    https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...

  7. 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 ...

  8. shell脚本一键安装redis集群[最终版]

    直接上shell了. #!/bin/bash #---------------------------------------------------------------------------- ...

  9. shell脚本一键安装jdk

    直接上shell #!/bin/bash #offline jdk install ipath="/usr/local" installpath=$(cd `dirname $0` ...

随机推荐

  1. CentOS6.5 安装Kafka集群

    1.安装zookeeper 参考文档:http://www.cnblogs.com/hunttown/p/5452138.html 2.下载:https://www.apache.org/dyn/cl ...

  2. composer 用法

    构建工程 composer create-project test/name project_name help composer help create-project 参数 --prefer-di ...

  3. Kotlin 范型约束

    官方的示意及其简约,该说的一概没说 我在这里给大家一个完整的例子 //test.kt fun <T> cloneWhenGreater(list: List<T>, thres ...

  4. Golang package

    今天,灵感一现:不能一个文件干到底吧,那要是工程大了怎么办? 答案很简单,“包”啊 GO里的包,看起来很简单,但又不简单 一开始,我想当然的以为就是include 路径一样的问题 事实是,GO以GOP ...

  5. 单点登录开源架构之CAS

    服务端 开源地址:https://github.com/apereo/cas Release版:https://github.com/apereo/cas/releases Windows下使用下载c ...

  6. 安装程序无法打开注册表项 UNKNOWN\Components\…的简单解决办法(转)

    安装程序无法打开注册表项 UNKNOWN\Components\…的简单解决办法 2018年04月16日 16:41:32 super_star_贤 阅读数:7193   在安装软件时(比如安装SQL ...

  7. 49.CSS--- 特殊css3效果展示

    1.设置多行文本超出显示省略号<div class="caption"> <p>显示超过两行就显示省略号,其余隐藏,隐藏不了的情况下给这个模块添加一个高度和 ...

  8. POJ 2155 Matrix(二维BIT)

    Matrix [题目链接]Matrix [题目类型]二维BIT &题解: bit只能单点更新,恰好,这题可以想一下就可以用单点更新解决了. 只不过最后我交上去居然T了,想了10多分钟,试了一下 ...

  9. python 文件写入错误

    在保存网页文字到txt文件下时,出现如下错误 UnicodeEncodeError: 'gbk' codec can't encode character u'\xa9' in position 24 ...

  10. IIS7配置rewriter

    遇到的问题就是rewriter不起效果冲IIS6迁移过来的.最后发现是Framework 4.0的原因!记录处理方式为: 一. <configSections> <section n ...