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

#!/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. PHP "松散比较"

    PHP 的整数和字符串比较是 "松散比较" var_dump('dev' == 0); bool(true) switch switch 在进行比较的时候,只是对值进行比较(&qu ...

  2. case when 遇到varchar转为int类型值失败的错误

    问题描述: 在Sql Server 2005下, 使用如下语句报错:在将 varchar 值 '大' 转换成数据类型 int 时失败. 注:status 是整型字段 select ff=  case ...

  3. 正则表达式中\b和\s有什么区别

    字符串:abcsdsadas abc asdsadasdabcasdsa使用\sabc\s和\babc\b都能匹配中间的abc,这种方法不是重复了么,/s是匹配空格回车等得,/b网上教程说得不清楚什么 ...

  4. ssh简单入门级案例教程

    准备工作:struts2.3.34+spring4.2.2+hibernate3.3.2 导入需要的开发包: struts开发包---注意:javassist-3.18.1-GA.jar包与hiber ...

  5. QT获取窗口句柄

    winId()函数 SendMessage((HWND)(this->dlg->winId()),WM_SEND_MY_MESSAGE,0,0);

  6. DataRow 点不出 Select

    DataRow 点不出 Select?why?using system.linq;

  7. Lua 可变参数之arg与select

    function TestFunc(...) local arg = { ... } --Lua .2以后不再支持默认arg参数,{}与...之间要有空格 print("输入的参数个数:&q ...

  8. linux命令-查找所有文件中包含某个字符串

    查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri "IBM" 查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 find .|xar ...

  9. ubuntu之redis集群配置

    redis3版本以上支持集群 需要ruby的支持 root@iZ2zejfbthvbzs5lxf37vjZ:/usr/local/src/redis-3.2.9/src# apt-get instal ...

  10. html5-css的使用强制优先级

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...