码迷,mamicode.com
首页 > 其他好文 > 详细

nginx安装脚本(后续优化)

时间:2018-10-13 22:41:59      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:c++   function   ESS   安装   init.d   yun   null   mirror   ali   

#!/bin/bash
. /etc/init.d/functions
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sleep 2
yum makecache
if [ $? -eq 0 ];then
echo "yum change success !" /bin/true
else
echo "yum change failure" /bin/false
exit 1
fi

yum -y install pcre pcre-devel openssl-devel openssl gcc-c++
if [ $? -eq 0 ];then
echo "yum success !" /bin/true
else
echo "yum failure" /bin/false
exit 1
fi
useradd www -s /sbin/nologin -M
[ ! -d /home/tools ] && mkdir /home/tools -p
[ ! -d /application ] && mkdir /application

cd /home/tools
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
if [ $? -eq 0 ];then
echo "download success !" /bin/true
else
echo "download failure" /bin/false
exit 1
fi
tar xf nginx-1.6.3.tar.gz
if [ $? -eq 0 ];then
echo "tar success !" /bin/true
else
echo "tar failure" /bin/false
exit 1
fi

cd nginx-1.6.3
./configure --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --prefix=/application/nginx-1.6.3
if [ $? -eq 0 ];then
echo "configure success !" /bin/true
else
echo "configure failure" /bin/false
exit 1
fi
make
if [ $? -eq 0 ];then
echo "make success !" /bin/true
else
echo "make failure" /bin/false
exit 1
fi
make install
if [ $? -eq 0 ];then
echo "install success !" /bin/true
else
echo "install failure" /bin/false
exit 1
fi
ln -s /application/nginx-1.6.3/ /application/nginx
/application/nginx/sbin/nginx
ps -ef |grep nginx
#HTTP_CODE=curl -I -s -w "%{http_code}\n" -o /dev/null www.baidu.com
#if [ $HTTP_CODE -eq 200 -o $HTTP_CODE -eq 301 ]
#then
#action "Nginx is running" /bin/true
#else
#action "Nginx already been down" /bin/false
#fi
注意:curl处 有反引号 tab键上面那个符号;

nginx安装脚本(后续优化)

标签:c++   function   ESS   安装   init.d   yun   null   mirror   ali   

原文地址:http://blog.51cto.com/13754781/2299553

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!