• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

nginx安装脚本(后续优化)

Nginx相关 zbjtwyyue 147次浏览 已收录 0个评论
#!/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
  action "yum change success !" /bin/true
else
  action "yum change failure" /bin/false
  exit 1
fi

yum -y install pcre pcre-devel openssl-devel  openssl gcc-c++
if [ $? -eq 0 ];then
  action "yum success !" /bin/true
else
  action "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
  action "download  success !" /bin/true
else
  action "download  failure" /bin/false
  exit 1
fi
tar xf nginx-1.6.3.tar.gz
if [ $? -eq 0 ];then
  action "tar  success !" /bin/true
else
  action "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
  action "configure success !" /bin/true
else
  action "configure  failure" /bin/false
  exit 1
fi
make
if [ $? -eq 0 ];then
  action "make success !" /bin/true
else
  action "make  failure" /bin/false
  exit 1
fi
make install
if [ $? -eq 0 ];then
  action "install success !" /bin/true
else
  action "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键上面那个符号;

VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明nginx安装脚本(后续优化)
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址