nginx安裝指令碼(後續最佳化)

來源:互聯網
上載者:User

標籤: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安裝指令碼(後續最佳化)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.