FreeABC
记忆重叠

军哥 LNMP 一键平滑升级 Tengine 2.2.1完美版

lnmp 自动切换为tengine 工具

1、首先进入:Tengine 官网下载页 查看版本,例如要安装:2.2.1

 

2、执行如下命令,然后输入你刚刚看到并且想安装的版本号并回车(Enter)安装:

wget http://server.file.cdn.12cf.com/upgrade_tengine/upgrade_tengine.sh;
sh upgrade_tengine.sh

 

3、等待安装完成即可通过 nginx -V 查看版本了。

 

不方便下载的,可以参考下面脚本源码

#!/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

clear
echo "========================================================================="
echo "Upgrade Tengine for LNMP,  Modify by abcZn  https://b.abczn.com"
echo "========================================================================="
echo "LNMP is tool to auto-compile & install Tengine+MySQL+PHP on Linux "
echo "========================================================================="

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 tengine Version:$old_nginx_version"
  echo "Please input tengine version you want:"
  echo "You can get version number from http://tengine.taobao.org/download_cn.html"
  read -p "(example: 2.2.2 ):" nginx_version
  if [ "$nginx_version" = "" ]; then
    nginx_version="2.2.1"
    #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 tengine-$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
  if [ $? -eq 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 "tengine Version input was:"$nginx_version
  sleep 5
  exit 1
  fi
fi
echo "============================check files=================================="
echo "Stoping MySQL..."
/etc/init.d/mysql stop
echo "Stoping PHP-FPM..."
/etc/init.d/php-fpm stop
if [ -s /etc/init.d/memceached ]; then
  echo "Stoping Memcached..."
  /etc/init.d/memcacehd stop
fi

rm -rf tengine-$nginx_version/

tar zxvf tengine-$nginx_version.tar.gz
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 "Restarting Nginx..."
/etc/init.d/nginx restart

echo "Starting MySQL..."
/etc/init.d/mysql start
echo "Starting PHP-FPM..."
/etc/init.d/php-fpm start
if [ -s /etc/init.d/memceached ]; then
  echo "Starting Memcached..."
  /etc/init.d/memcacehd start
fi

echo "========================================================================="
echo "You have successfully upgrade from $old_nginx_version to $nginx_version"
echo "========================================================================="
echo "LNMP is tool to auto-compile & install Tengine+MySQL+PHP on Linux "
echo "========================================================================="
fi

 

未经允许不得转载:Free-Abc智能 » 军哥 LNMP 一键平滑升级 Tengine 2.2.1完美版
分享到: 更多 (0)