LNMP平滑升级到淘宝的开源webserver Tengine

作者:老刘 发布时间:June 12, 2012 分类:学习笔记 阅读次数:3,846

将代码保存为upgrade_tengine.sh ,然后再root下运行

chmod +x ./upgrade_tengine.sh
./upgrade_tengine.sh


#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

# Check if user is root
if [ $(id -u) != "0" ]; then
    echo "Error: You must be root to run this script, please use root to install lnmp"
    exit 1
fi

nv=`/usr/local/nginx/sbin/nginx -v 2>&1`
old_nginx_version=`echo $nv | cut -c22-`
#echo $old_nginx_version

if [ "$1" != "--help" ]; then

#set nginx version

nginx_version=""
echo "Current Nginx Version:$old_nginx_version"
echo "Please input Tengine version you want:"
echo "You can get version number from http://tengine.taobao.org/download.html"
read -p "(example: 1.2.1 ):" nginx_version
if [ "$nginx_version" = "" ]; then
echo "Error: You must input Tengine version!!"
exit 1
fi
echo "==========================="

echo "You want to upgrade Tengine version to $nginx_version"

echo "==========================="

get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start...or Press Ctrl+c to cancel"
char=`get_char`

echo "============================check files=================================="
if [ -s nginx-$nginx_version.tar.gz ]; then
  echo "Tengine-$nginx_version.tar.gz [found]"
  else
  echo "Error: Tengine-$nginx_version.tar.gz not found!!!download now......"
  wget -c http://tengine.taobao.org/download/tengine-$nginx_version.tar.gz
  dl_status=`echo $?`
  if [ $dl_status = "0" ]; then
echo "Download Tengine-$nginx_version.tar.gz successfully!"
  else
echo "WARNING!May be the Tengine version you input was wrong,please check!"
echo "Nginx Version input was:"$nginx_version
sleep 5
exit 1
  fi
fi
echo "============================check files=================================="

rm -rf tengine-$nginx_version/

tar zxvf tengine-$nginx_version.tar.gz

echo "Press any key to start...or Press Ctrl+c to cancel"
char=`get_char`

cd tengine-$nginx_version/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
make

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
make upgrade
echo "Upgrade completed!"
echo "Program will display Nginx Version......"
/usr/local/nginx/sbin/nginx -v
cd ../

echo "========================================================================="
echo "You have successfully upgrade from $old_nginx_version to $nginx_version"
echo "========================================================================="
fi

标签: LNMP

前一篇:whmcs无法自动开通kloxo/lxadmin帐号

后一篇:SSH必备软件

仅有一条评论 »

  1. 自己测试

添加新评论 »