浏览代码

Merge pull request #1 from lj2007331/master

up
Logig 7 年之前
父节点
当前提交
8f11f23aa9

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+install.log

+ 2 - 2
README.md

@@ -1,13 +1,13 @@
 [![PayPal donate button](https://img.shields.io/badge/paypal-donate-green.svg)](https://paypal.me/yeho) [![支付宝捐助按钮](https://img.shields.io/badge/%E6%94%AF%E4%BB%98%E5%AE%9D-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/alipay.png) [![微信捐助按钮](https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/weixin.png)
 
-This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 5~7(including redhat), Debian 6~8, Ubuntu 12~16 of 32 and 64.
+This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 6~7(including redhat), Debian 6~9, Ubuntu 12~16 of 32 and 64.
 
 Script properties:
 - Continually updated
 - Source compiler installation, most stable source is the latest version, and download from the official site
 - Some security optimization
 - Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5, Percona-5.7, Percona-5.6, Percona-5.5, AliSQL-5.6)
-- Providing multiple PHP versions (PHP-7.1, PHP-7.0, PHP-5.6, PHP-5.5, PHP-5.4, PHP-5.3)
+- Providing multiple PHP versions (PHP-7.2, PHP-7.1, PHP-7.0, PHP-5.6, PHP-5.5, PHP-5.4, PHP-5.3)
 - Provide Nginx, Tengine, OpenResty
 - Providing a plurality of Tomcat version (Tomcat-8, Tomcat-7, Tomcat-6)
 - Providing a plurality of JDK version (JDK-1.8, JDK-1.7, JDK-1.6)

+ 7 - 7
addons.sh

@@ -69,7 +69,7 @@ if [ -e "${php_install_dir}/bin/phpize" ]; then
     "5.6")
       PHP_version=4
       ;;
-    "7.0" | "7.1")
+    "7.0" | "7.1" | "7.2" )
       PHP_version=5
       ;;
     *)
@@ -192,7 +192,7 @@ ACTION_FUN() {
     read -p "Please input a number:(Default 1 press Enter) " ACTION
     [ -z "${ACTION}" ] && ACTION=1
     if [[ ! "${ACTION}" =~ ^[1,2]$ ]]; then
-      echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+      echo "${CWARNING}input error! Please only input number 1~2${CEND}"
     else
       break
     fi
@@ -229,7 +229,7 @@ What Are You Doing?
           read -p "Please input a number:(Default 1 press Enter) " PHP_cache
           [ -z "${PHP_cache}" ] && PHP_cache=1
           if [[ ! "${PHP_cache}" =~ ^[1-4]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
+            echo "${CWARNING}input error! Please only input number 1~4${CEND}"
           else
             case "${PHP_cache}" in
               1)
@@ -312,7 +312,7 @@ What Are You Doing?
           read -p "Please input a number:(Default 1 press Enter) " Loader
           [ -z "${Loader}" ] && Loader=1
           if [[ ! "${Loader}" =~ ^[1,2]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+            echo "${CWARNING}input error! Please only input number 1~2${CEND}"
           else
             [ "${Loader}" = '1' ] && PHP_extension=ZendGuardLoader
             [ "${Loader}" = '2' ] && PHP_extension=0ioncube
@@ -334,7 +334,7 @@ What Are You Doing?
               echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
             fi
           elif [ "${Loader}" = '2' ]; then
-            if [[ "${PHP_main_version}" =~ ^5.[3-6]$|^7.0$ ]] || [ "${TARGET_ARCH}" != "arm64" ]; then
+            if [[ "${PHP_main_version}" =~ ^5.[3-6]$|^7.[0-1]$ ]] || [ "${TARGET_ARCH}" != "arm64" ]; then
               ionCube_yn='y' && checkDownload
               Install_ionCube
               Restart_PHP; echo "${CSUCCESS}PHP ioncube module installed successfully! ${CEND}";
@@ -355,7 +355,7 @@ What Are You Doing?
           read -p "Please input a number:(Default 1 press Enter) " Magick
           [ -z "${Magick}" ] && Magick=1
           if [[ ! "${Magick}" =~ ^[1,2]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+            echo "${CWARNING}input error! Please only input number 1~2${CEND}"
           else
             [ "${Magick}" = '1' ] && PHP_extension=imagick
             [ "${Magick}" = '2' ] && PHP_extension=gmagick
@@ -410,7 +410,7 @@ What Are You Doing?
           read -p "Please input a number:(Default 1 press Enter) " Memcache
           [ -z "${Memcache}" ] && Memcache=1
           if [[ ! "${Memcache}" =~ ^[1-3]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+            echo "${CWARNING}input error! Please only input number 1~3${CEND}"
           else
             [ "${Memcache}" = '1' ] && PHP_extension=memcache
             [ "${Memcache}" = '2' ] && PHP_extension=memcached

+ 2 - 2
backup.sh

@@ -39,7 +39,7 @@ DB_COS_BK() {
     DB_GREP="DB_${D}_`date +%Y`"
     DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
     ${python_install_dir}/bin/coscmd upload $backup_dir/$DB_FILE /`date +%F`/$DB_FILE
-    [ $? -eq 0 ] && ${python_install_dir}/bin/coscmd delete -r `date +%F --date="$expired_days days ago"` > /dev/null 2>&1
+    [ $? -eq 0 ] && ${python_install_dir}/bin/coscmd delete -r -f `date +%F --date="$expired_days days ago"` > /dev/null 2>&1
   done
 }
 
@@ -76,7 +76,7 @@ WEB_COS_BK() {
       popd
     fi
     ${python_install_dir}/bin/coscmd upload $PUSH_FILE /`date +%F`/Web_${W}_$(date +%Y%m%d_%H).tgz
-    [ $? -eq 0 ] && { [ -e "$PUSH_FILE" ] && rm -rf $PUSH_FILE; ${python_install_dir}/bin/coscmd delete -r `date +%F --date="$expired_days days ago"` > /dev/null 2>&1; }
+    [ $? -eq 0 ] && { [ -e "$PUSH_FILE" ] && rm -rf $PUSH_FILE; ${python_install_dir}/bin/coscmd delete -r -f `date +%F --date="$expired_days days ago"` > /dev/null 2>&1; }
   done
 }
 

+ 11 - 13
backup_setup.sh

@@ -41,7 +41,7 @@ while :; do echo
   read -p "Please input a number:(Default 1 press Enter) " DESC_BK
   [ -z "$DESC_BK" ] && DESC_BK=1
   if [[ ! $DESC_BK =~ ^[1-6]$ ]]; then
-    echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}"
+    echo "${CWARNING}input error! Please only input number 1~6${CEND}"
   else
     break
   fi
@@ -62,7 +62,7 @@ while :; do echo
   read -p "Please input a number:(Default 1 press Enter) " CONTENT_BK
   [ -z "$CONTENT_BK" ] && CONTENT_BK=1
   if [[ ! $CONTENT_BK =~ ^[1-3]$ ]]; then
-    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+    echo "${CWARNING}input error! Please only input number 1~3${CEND}"
   else
     break
   fi
@@ -169,8 +169,6 @@ fi
 if [[ "$DESC_BK" =~ ^[3,5,6]$ ]]; then
   [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
   [ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1 
-  sed -i "/if query_yes_no/{ n; s/^.*/#&/; }" ${python_install_dir}/lib/python2.7/site-packages/coscmd/cos_client.py
-  sed -i "s/if query_yes_no/#if query_yes_no/" ${python_install_dir}/lib/python2.7/site-packages/coscmd/cos_client.py
   while :; do echo
     echo 'Please select your backup datacenter:'
     echo -e "\t ${CMSG}1${CEND}. 北京一区(华北)  ${CMSG}2${CEND}. 北京"
@@ -196,26 +194,26 @@ if [[ "$DESC_BK" =~ ^[3,5,6]$ ]]; then
   [ "$Location" == '8' ] && region='na-toronto'
   [ "$Location" == '9' ] && region='eu-frankfurt'
   while :; do echo
-    read -p "Please enter the Qcloud COS appid: " appid 
+    read -p "Please enter the Qcloud COS APPID: " appid 
     [ -z "$appid" ] && continue
     echo
-    read -p "Please enter the Qcloud COS secret id: " secret_id
-    [ -z "$secret_id" ] && continue
+    read -p "Please enter the Qcloud COS SecretId: " SecretId
+    [ -z "$SecretId" ] && continue
     echo
-    read -p "Please enter the Qcloud COS secret key: " secret_key
-    [ -z "$secret_key" ] && continue
+    read -p "Please enter the Qcloud COS SecretKey: " SecretKey
+    [ -z "$SecretKey" ] && continue
     echo
     read -p "Please enter the Qcloud COS bucket: " bucket 
     [ -z "$bucket" ] && continue
     echo
-    $python_install_dir/bin/coscmd config -u $appid -a $secret_id -s $secret_key -r $region -b $bucket >/dev/null 2>&1
-    $python_install_dir/bin/coscmd delete oneinstack.test >/dev/null 2>&1
+    $python_install_dir/bin/coscmd config -u $appid -a $SecretId -s $SecretKey -r $region -b $bucket >/dev/null 2>&1
+    $python_install_dir/bin/coscmd list >/dev/null 2>&1
     if [ $? = 0 ];then
-      echo "${CMSG}appid/secret_id/secret_key/region/bucket OK${CEND}"
+      echo "${CMSG}appid/SecretId/SecretKey/region/bucket OK${CEND}"
       echo
       break
     else
-      echo "${CWARNING}input error! appid/secret_id/secret_key/region/bucket invalid${CEND}"
+      echo "${CWARNING}input error! appid/SecretId/SecretKey/region/bucket invalid${CEND}"
     fi
   done
 fi

+ 1 - 0
include/alisql-5.6.sh

@@ -187,6 +187,7 @@ EOF
 
   ${alisql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${alisql_install_dir} --datadir=${alisql_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${alisql_data_dir}
   [ -d "/etc/mysql" ] && mv /etc/mysql{,_bk}
   service mysqld start

+ 7 - 4
include/check_download.sh

@@ -94,7 +94,7 @@ checkDownload() {
   fi
 
   if [ "${DB_yn}" == 'y' ]; then
-    if [[ "${DB_version}" =~ ^[1,4,7]$ ]] && [ "${dbInstallMethods}" == "2" ]; then
+    if [[ "${DB_version}" =~ ^[1,4,8]$ ]] && [ "${dbInstallMethods}" == "2" ]; then
       echo "Download boost..."
       [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/${boost_version}
       boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}')
@@ -559,6 +559,9 @@ checkDownload() {
       6)
         src_url=http://www.php.net/distributions/php-${php71_version}.tar.gz && Download_src
         ;;
+      7)
+        src_url=http://www.php.net/distributions/php-${php72_version}.tar.gz && Download_src
+        ;;
     esac
   fi
 
@@ -579,7 +582,7 @@ checkDownload() {
       fi
       ;;
     3)
-      # php 5.3 5.4 5.5 5.6 7.0 7.1
+      # php 5.3 5.4 5.5 5.6 7.0 7.1 7.2
       echo "Download apcu..."
       if [[ "$PHP_version" =~ ^[1-4]$ ]]; then
         src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src
@@ -671,7 +674,7 @@ checkDownload() {
     else
       echo "Download graphicsmagick..."
       src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${GraphicsMagick_version}/GraphicsMagick-${GraphicsMagick_version}.tar.gz && Download_src
-      if [[ "$PHP_version" =~ ^[5-6]$ ]]; then
+      if [[ "$PHP_version" =~ ^[5-7]$ ]]; then
         echo "Download gmagick for php 7.x..."
         src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_version}.tgz && Download_src
       else
@@ -705,7 +708,7 @@ checkDownload() {
   if [ "${memcached_yn}" == 'y' ]; then
     echo "Download memcached..."
     src_url=http://www.memcached.org/files/memcached-${memcached_version}.tar.gz && Download_src
-    if [[ "$PHP_version" =~ ^[5-6]$ ]]; then
+    if [[ "$PHP_version" =~ ^[5-7]$ ]]; then
       echo "Download pecl memcache for php 7.x..."
       # src_url=https://codeload.github.com/websupport-sk/pecl-memcache/zip/php7 && Download_src
       src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src

+ 4 - 0
include/check_os.sh

@@ -48,6 +48,10 @@ else
   kill -9 $$
 fi
 
+if [ "$(uname -r | awk -F- '{print $3}' 2>/dev/null)" == "Microsoft" ]; then
+  Wsl=true
+fi
+
 if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then
   OS_BIT=64
   SYS_BIG_FLAG=x64 #jdk

+ 2 - 2
include/init_Ubuntu.sh

@@ -87,8 +87,8 @@ sed -i 's@^@#@g' /etc/init/tty[3-6].conf
 locale-gen en_US.UTF-8
 echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local
 cat > /etc/default/locale << EOF
-LANG="en_US.UTF-8"
-LANGUAGE="en_US:en"
+LANG=en_US.UTF-8
+LANGUAGE=en_US:en
 EOF
 sed -i 's@^@#@g' /etc/init/control-alt-delete.conf
 

+ 1 - 0
include/mariadb-10.0.sh

@@ -193,6 +193,7 @@ EOF
 
   ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mariadb_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/mariadb-10.1.sh

@@ -193,6 +193,7 @@ EOF
 
   ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mariadb_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/mariadb-10.2.sh

@@ -193,6 +193,7 @@ EOF
 
   ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mariadb_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/mariadb-5.5.sh

@@ -196,6 +196,7 @@ EOF
 
   ${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mariadb_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/mysql-5.5.sh

@@ -199,6 +199,7 @@ EOF
 
   ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mysql_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/mysql-5.6.sh

@@ -198,6 +198,7 @@ EOF
 
   ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mysql_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/mysql-5.7.sh

@@ -199,6 +199,7 @@ EOF
 
   ${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${mysql_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/nginx.sh

@@ -72,6 +72,7 @@ proxy_set_header Cookie \$http_cookie;
 proxy_set_header Host \$host;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
+proxy_set_header X-Forwarded-Proto \$scheme;
 EOF
   sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $nginx_install_dir/conf/nginx.conf
   sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf

+ 1 - 0
include/openresty.sh

@@ -69,6 +69,7 @@ proxy_set_header Cookie \$http_cookie;
 proxy_set_header Host \$host;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
+proxy_set_header X-Forwarded-Proto \$scheme;
 EOF
   sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $openresty_install_dir/nginx/conf/nginx.conf
   sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $openresty_install_dir/nginx/conf/nginx.conf

+ 1 - 1
include/openssl.sh

@@ -24,7 +24,7 @@ Install_openSSL102() {
     if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
       echo "${CSUCCESS}openssl-1.0.2 module installed successfully! ${CEND}"
       /bin/cp cacert.pem ${openssl_install_dir}/ssl/cert.pem
-      echo "${openssl_install_dir}/lib" > /etc/ld.so.conf.d/openssl.conf
+      echo "${openssl_install_dir}/lib" > /etc/ld.so.conf.d/z.openssl.conf
       ldconfig
       rm -rf openssl-${openssl_version}
     else

+ 1 - 0
include/percona-5.5.sh

@@ -200,6 +200,7 @@ EOF
 
   ${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${percona_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/percona-5.6.sh

@@ -200,6 +200,7 @@ EOF
 
   ${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${percona_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 1 - 0
include/percona-5.7.sh

@@ -200,6 +200,7 @@ EOF
 
   ${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
 
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
   chown mysql.mysql -R ${percona_data_dir}
   [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
   service mysqld start

+ 245 - 0
include/php-7.2.sh

@@ -0,0 +1,245 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_PHP72() {
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  ./configure --prefix=/usr/local --with-ssl=${openssl_install_dir}
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf php-$php72_version.tar.gz
+  pushd php-$php72_version
+  make clean
+  ./buildconf
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
+    ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+    --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl=${openssl_install_dir} \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options
+  else
+    ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+    --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl=${openssl_install_dir} \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-debug $php_modules_options
+  fi
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
+    echo "${CSUCCESS}PHP installed successfully! ${CEND}"
+  else
+    rm -rf $php_install_dir
+    echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
+    kill -9 $$
+  fi
+  
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini
+  sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+[opcache]
+zend_extension=opcache.so
+opcache.enable=1
+opcache.enable_cli=1
+opcache.memory_consumption=$Memory_limit
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=100000
+opcache.max_wasted_percentage=5
+opcache.use_cwd=1
+opcache.validate_timestamps=1
+opcache.revalidate_freq=60
+opcache.save_comments=0
+opcache.fast_shutdown=1
+opcache.consistency_checks=0
+;opcache.optimization_level=0
+EOF
+
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
+    # php-fpm Init Script
+    /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
+    chmod +x /etc/init.d/php-fpm
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
+
+    cat > $php_install_dir/etc/php-fpm.conf <<EOF
+;;;;;;;;;;;;;;;;;;;;;
+; FPM Configuration ;
+;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;
+; Global Options ;
+;;;;;;;;;;;;;;;;;;
+
+[global]
+pid = run/php-fpm.pid
+error_log = log/php-fpm.log
+log_level = warning
+
+emergency_restart_threshold = 30
+emergency_restart_interval = 60s
+process_control_timeout = 5s
+daemonize = yes
+
+;;;;;;;;;;;;;;;;;;;;
+; Pool Definitions ;
+;;;;;;;;;;;;;;;;;;;;
+
+[$run_user]
+listen = /dev/shm/php-cgi.sock
+listen.backlog = -1
+listen.allowed_clients = 127.0.0.1
+listen.owner = $run_user
+listen.group = $run_user
+listen.mode = 0666
+user = $run_user
+group = $run_user
+
+pm = dynamic
+pm.max_children = 12
+pm.start_servers = 8
+pm.min_spare_servers = 6
+pm.max_spare_servers = 12
+pm.max_requests = 2048
+pm.process_idle_timeout = 10s
+request_terminate_timeout = 120
+request_slowlog_timeout = 0
+
+pm.status_path = /php-fpm_status
+slowlog = log/slow.log
+rlimit_files = 51200
+rlimit_core = 0
+
+catch_workers_output = yes
+;env[HOSTNAME] = $HOSTNAME
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /tmp
+env[TMPDIR] = /tmp
+env[TEMP] = /tmp
+EOF
+
+    [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
+
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    fi
+
+    #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
+    service php-fpm start
+
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
+    service httpd restart
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php72_version
+  popd
+}

+ 1 - 1
include/python.sh

@@ -78,7 +78,7 @@ EOF
     # get the IP information
     PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
     IPADDR_COUNTRY=$(../include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}')
-    if [ "$IPADDR_COUNTRY"x != "CN"x ]; then
+    if [ "$IPADDR_COUNTRY"x == "CN"x ]; then
       [ ! -d "/root/.pip" ] && mkdir /root/.pip
       echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf
     fi

+ 1 - 0
include/tengine.sh

@@ -70,6 +70,7 @@ proxy_set_header Cookie \$http_cookie;
 proxy_set_header Host \$host;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
+proxy_set_header X-Forwarded-Proto \$scheme;
 EOF
   sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $tengine_install_dir/conf/nginx.conf
   sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf

+ 2 - 0
include/tomcat-6.sh

@@ -94,6 +94,8 @@ EOF
   <Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
     prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+  <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
+    protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
 </Host>
 EOF
     # logrotate tomcat catalina.out

+ 2 - 0
include/tomcat-7.sh

@@ -94,6 +94,8 @@ EOF
   <Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
     prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+  <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
+    protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
 </Host>
 EOF
     # logrotate tomcat catalina.out

+ 2 - 0
include/tomcat-8.sh

@@ -94,6 +94,8 @@ EOF
   <Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
     prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+  <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
+    protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
 </Host>
 EOF
     # logrotate tomcat catalina.out

+ 4 - 1
include/upgrade_memcached.sh

@@ -12,9 +12,12 @@ Upgrade_Memcached() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "${memcached_install_dir}/bin/memcached" ] && echo "${CWARNING}Memcached is not installed on your system! ${CEND}" && exit 1
   OLD_Memcached_version=`$memcached_install_dir/bin/memcached -V | awk '{print $2}'`
+  Latest_Memcached_version=`curl -s http://memcached.org/downloads | awk -F'>|<' '/\/files\/memcached/{print $3}' | grep -oE "[0-9]\.[0-9]\.[0-9]+"`
+  [ -z "$Latest_Memcached_version" ] && Latest_Memcached_version=1.6.8
   echo "Current Memcached Version: ${CMSG}$OLD_Memcached_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Memcached Version(example: 1.4.39): " NEW_Memcached_version
+    read -p "Please input upgrade Memcached Version(default: $Latest_Memcached_version): " NEW_Memcached_version
+    [ -z "$NEW_Memcached_version" ] && NEW_Memcached_version=$Latest_Memcached_version
     if [ "${NEW_Memcached_version}" != "$OLD_Memcached_version" ]; then
       [ ! -e "memcached-${NEW_Memcached_version}.tar.gz" ] && wget --no-check-certificate -c http://www.memcached.org/files/memcached-${NEW_Memcached_version}.tar.gz > /dev/null 2>&1
       if [ -e "memcached-${NEW_Memcached_version}.tar.gz" ]; then

+ 5 - 2
include/upgrade_php.sh

@@ -11,11 +11,14 @@
 Upgrade_PHP() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "${php_install_dir}" ] && echo "${CWARNING}PHP is not installed on your system! ${CEND}" && exit 1
-  echo
   OLD_PHP_version=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
+  Latest_PHP_version=`curl -s http://php.net/downloads.php | awk '/Changelog/{print $2}' | grep "${OLD_PHP_version%.*}"`
+  echo
+  [ -z "$Latest_PHP_version" ] && Latest_PHP_version=5.5.38
   echo "Current PHP Version: ${CMSG}$OLD_PHP_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade PHP Version: " NEW_PHP_version
+    read -p "Please input upgrade PHP Version(Default: $Latest_PHP_version): " NEW_PHP_version
+    [ -z "$NEW_PHP_version" ] && NEW_PHP_version=$Latest_PHP_version
     if [ "${NEW_PHP_version%.*}" == "${OLD_PHP_version%.*}" ]; then
       [ ! -e "php-${NEW_PHP_version}.tar.gz" ] && wget --no-check-certificate -c http://www.php.net/distributions/php-${NEW_PHP_version}.tar.gz > /dev/null 2>&1
       if [ -e "php-${NEW_PHP_version}.tar.gz" ]; then

+ 4 - 2
include/upgrade_phpmyadmin.sh

@@ -12,10 +12,12 @@ Upgrade_phpMyAdmin() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "${wwwroot_dir}/default/phpMyAdmin" ] && echo "${CWARNING}phpMyAdmin is not installed on your system! ${CEND}" && exit 1
   OLD_phpMyAdmin_version=`grep Version ${wwwroot_dir}/default/phpMyAdmin/README | awk '{print $2}'`
+  Latest_phpMyAdmin_version=`curl -s https://www.phpmyadmin.net/files/ | awk -F'>|<' '/\/files\/[0-9]/{print $5}' | head -1`
+  [ -z "$Latest_phpMyAdmin_version" ] && Latest_phpMyAdmin_version=4.8.6
   echo "Current phpMyAdmin Version: ${CMSG}${OLD_phpMyAdmin_version}${CEND}"
-
   while :; do echo
-    read -p "Please input upgrade phpMyAdmin Version(example: 4.4.15): " NEW_phpMyAdmin_version
+    read -p "Please input upgrade phpMyAdmin Version(default: $Latest_phpMyAdmin_version): " NEW_phpMyAdmin_version
+    [ -z "$NEW_phpMyAdmin_version" ] && NEW_phpMyAdmin_version=$Latest_phpMyAdmin_version
     if [ "${NEW_phpMyAdmin_version}" != "${OLD_phpMyAdmin_version}" ]; then
       [ ! -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/${NEW_phpMyAdmin_version}/phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1
       if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ]; then

+ 4 - 1
include/upgrade_redis.sh

@@ -12,9 +12,12 @@ Upgrade_Redis() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -d "$redis_install_dir" ] && echo "${CWARNING}Redis is not installed on your system! ${CEND}" && exit 1
   OLD_Redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
+  Latest_Redis_version=`curl -s http://download.redis.io/redis-stable/00-RELEASENOTES | awk '/Released/{print $2}' | head -1`
+  [ -z "$Latest_Redis_version" ] && Latest_Redis_version=4.2.8
   echo "Current Redis Version: ${CMSG}$OLD_Redis_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Redis Version(example: 3.0.5): " NEW_Redis_version
+    read -p "Please input upgrade Redis Version(default: $Latest_Redis_version): " NEW_Redis_version
+    [ -z "$NEW_Redis_version" ] && NEW_Redis_version=$Latest_Redis_version
     if [ "$NEW_Redis_version" != "$OLD_Redis_version" ]; then
       [ ! -e "redis-$NEW_Redis_version.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_Redis_version.tar.gz > /dev/null 2>&1
       if [ -e "redis-$NEW_Redis_version.tar.gz" ]; then

+ 74 - 5
include/upgrade_web.sh

@@ -13,10 +13,13 @@ Upgrade_Nginx() {
   [ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
   OLD_Nginx_version_tmp=`$nginx_install_dir/sbin/nginx -v 2>&1`
   OLD_Nginx_version=${OLD_Nginx_version_tmp##*/}
+  Latest_Nginx_version=`curl -s http://nginx.org/en/CHANGES-1.12 | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
+  [ -z "$Latest_Nginx_version" ] && Latest_Nginx_version=`curl -s http://nginx.org/en/CHANGES | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
   echo
   echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Nginx Version(example: 1.9.15): " NEW_Nginx_version
+    read -p "Please input upgrade Nginx Version(default: $Latest_Nginx_version): " NEW_Nginx_version
+    [ -z "$NEW_Nginx_version" ] && NEW_Nginx_version=$Latest_Nginx_version
     if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ]; then
       [ ! -e "nginx-$NEW_Nginx_version.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-$NEW_Nginx_version.tar.gz > /dev/null 2>&1
       if [ -e "nginx-$NEW_Nginx_version.tar.gz" ]; then
@@ -64,14 +67,16 @@ Upgrade_Nginx() {
 }
 
 Upgrade_Tengine() {
-  pushd ${oneinstack_dir}/src
+  pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1
   OLD_Tengine_version_tmp=`$tengine_install_dir/sbin/nginx -v 2>&1`
   OLD_Tengine_version="`echo ${OLD_Tengine_version_tmp#*/} | awk '{print $1}'`"
+  Latest_Tengine_version=`curl -s http://tengine.taobao.org/changelog.html | grep -oE "[0-9]\.[0-9]\.[0-9]+" | head -1`
   echo
   echo "Current Tengine Version: ${CMSG}$OLD_Tengine_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Tengine Version(example: 2.1.15): " NEW_Tengine_version
+    read -p "Please input upgrade Tengine Version(default: $Latest_Tengine_version): " NEW_Tengine_version
+    [ -z "$NEW_Tengine_version" ] && NEW_Tengine_version=$Latest_Tengine_version
     if [ "$NEW_Tengine_version" != "$OLD_Tengine_version" ]; then
       [ ! -e "tengine-$NEW_Tengine_version.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-$NEW_Tengine_version.tar.gz > /dev/null 2>&1
       if [ -e "tengine-$NEW_Tengine_version.tar.gz" ]; then
@@ -124,14 +129,16 @@ Upgrade_Tengine() {
 }
 
 Upgrade_OpenResty() {
-  pushd ${oneinstack_dir}/src
+  pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "$openresty_install_dir/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1
   OLD_OpenResty_version_tmp=`$openresty_install_dir/nginx/sbin/nginx -v 2>&1`
   OLD_OpenResty_version="`echo ${OLD_OpenResty_version_tmp#*/} | awk '{print $1}'`"
+  Latest_OpenResty_version=`curl -s https://openresty.org/en/download.html | awk '/download\/openresty-/{print $0}' |  grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -1`
   echo
   echo "Current OpenResty Version: ${CMSG}$OLD_OpenResty_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade OpenResty Version(example: 1.9.7.19): " NEW_OpenResty_version
+    read -p "Please input upgrade OpenResty Version(default: $Latest_OpenResty_version): " NEW_OpenResty_version
+    [ -z "$NEW_OpenResty_version" ] && NEW_OpenResty_version=$Latest_OpenResty_version
     if [ "$NEW_OpenResty_version" != "$OLD_OpenResty_version" ]; then
       [ ! -e "openresty-$NEW_OpenResty_version.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-$NEW_OpenResty_version.tar.gz > /dev/null 2>&1
       if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ]; then
@@ -176,3 +183,65 @@ Upgrade_OpenResty() {
   fi
   popd > /dev/null 
 }
+
+Upgrade_Apache() {
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -e "$apache_install_dir/bin/httpd" ] && echo "${CWARNING}Apache is not installed on your system! ${CEND}" && exit 1
+  OLD_Apache_version="`/usr/local/apache/bin/httpd -v | grep version | awk -F'/| ' '{print $4}'`"
+  Apache_flag="`echo $OLD_Apache_version | awk -F. '{print $1 $2}'`"
+  Latest_Apache_version=`curl -s http://httpd.apache.org/download.cgi | awk "/#apache$Apache_flag/{print $2}" | head -1 | grep -oE "2\.[24]\.[0-9]+"`
+  echo
+  echo "Current Apache Version: ${CMSG}$OLD_Apache_version${CEND}"
+  while :; do echo
+    read -p "Please input upgrade Apache Version(Default: $Latest_Apache_version): " NEW_Apache_version
+    [ -z "$NEW_Apache_version" ] && NEW_Apache_version=$Latest_Apache_version
+    if [ "$NEW_Apache_version" != "$OLD_Apache_version" ]; then
+      if [ "$Apache_flag" == '24' ]; then
+        src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src
+        src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_version}.tar.gz && Download_src
+        tar xzf apr-${apr_version}.tar.gz
+        tar xzf apr-util-${apr_util_version}.tar.gz
+      fi
+      [ ! -e "httpd-$NEW_Apache_version.tar.gz" ] && wget --no-check-certificate -c http://mirrors.linuxeye.com/apache/httpd/httpd-$NEW_Apache_version.tar.gz > /dev/null 2>&1
+      if [ -e "httpd-$NEW_Apache_version.tar.gz" ]; then
+        echo "Download [${CMSG}apache-$NEW_Apache_version.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}Apache version does not exist! ${CEND}"
+      fi
+    else
+      echo "${CWARNING}input error! Upgrade Apache version is the same as the old version${CEND}"
+    fi
+  done
+
+  if [ -e "httpd-$NEW_Apache_version.tar.gz" ]; then
+    echo "[${CMSG}httpd-$NEW_Apache_version.tar.gz${CEND}] found"
+    echo "Press Ctrl+c to cancel or Press any key to continue..."
+    char=`get_char`
+    tar xzf httpd-$NEW_Apache_version.tar.gz
+    pushd httpd-$NEW_Apache_version
+    make clean
+    if [ "$Apache_flag" == '24' ]; then
+      /bin/cp -R ../apr-${apr_version} ./srclib/apr
+      /bin/cp -R ../apr-util-${apr_util_version} ./srclib/apr-util
+      LDFLAGS=-ldl LD_LIBRARY_PATH=${openssl_install_dir}/lib ./configure --prefix=${apache_install_dir} --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-dav --enable-rewrite --enable-ssl --with-ssl=${openssl_install_dir} --enable-http2 --with-nghttp2=/usr/local --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all
+    elif [ "$Apache_flag" == '22' ]; then
+      [ "${Ubuntu_version}" == "12" ] && sed -i '@SSL_PROTOCOL_SSLV2@d' modules/ssl/ssl_engine_io.c
+      LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-rewrite --enable-ssl--with-ssl=${openssl_install_dir} --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all
+    fi
+    make -j ${THREAD}
+    if [ -e 'httpd' ]; then
+      [[ -d ${apache_install_dir}.bak && -d ${apache_install_dir} ]] && rm -rf ${apache_install_dir}.bak
+      /etc/init.d/httpd stop
+      /bin/cp -R ${apache_install_dir}{,bak}
+      make install && unset LDFLAGS
+      /etc/init.d/httpd start
+      popd > /dev/null
+      echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Apache_version${CEND} to ${CWARNING}$NEW_Apache_version${CEND}"
+      rm -rf httpd-$NEW_Apache_version apr-${apr_version} apr-util-${apr_util_version}
+    else
+      echo "${CFAILURE}Upgrade Apache failed! ${CEND}"
+    fi
+  fi
+  popd > /dev/null
+}

+ 25 - 19
install.sh

@@ -81,7 +81,7 @@ while :; do echo
         read -p "Please input a number:(Default 1 press Enter) " Nginx_version
         [ -z "$Nginx_version" ] && Nginx_version=1
         if [[ ! $Nginx_version =~ ^[1-4]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
+          echo "${CWARNING}input error! Please only input number 1~4${CEND}"
         else
           [ "$Nginx_version" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
           [ "$Nginx_version" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
@@ -98,7 +98,7 @@ while :; do echo
         read -p "Please input a number:(Default 3 press Enter) " Apache_version
         [ -z "$Apache_version" ] && Apache_version=3
         if [[ ! $Apache_version =~ ^[1-3]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+          echo "${CWARNING}input error! Please only input number 1~3${CEND}"
         else
           [ "$Apache_version" != '3' -a -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; Apache_version=Other; }
           break
@@ -114,7 +114,7 @@ while :; do echo
         read -p "Please input a number:(Default 4 press Enter) " Tomcat_version
         [ -z "$Tomcat_version" ] && Tomcat_version=4
         if [[ ! $Tomcat_version =~ ^[1-4]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
+          echo "${CWARNING}input error! Please only input number 1~4${CEND}"
         else
           [ "$Tomcat_version" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; }
           if [ "$Tomcat_version" == '1' ]; then
@@ -125,7 +125,7 @@ while :; do echo
               read -p "Please input a number:(Default 2 press Enter) " JDK_version
               [ -z "$JDK_version" ] && JDK_version=2
               if [[ ! $JDK_version =~ ^[1-2]$ ]]; then
-                echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+                echo "${CWARNING}input error! Please only input number 1~2${CEND}"
               else
                 break
               fi
@@ -139,7 +139,7 @@ while :; do echo
               read -p "Please input a number:(Default 2 press Enter) " JDK_version
               [ -z "$JDK_version" ] && JDK_version=2
               if [[ ! $JDK_version =~ ^[1-3]$ ]]; then
-                echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                echo "${CWARNING}input error! Please only input number 1~3${CEND}"
               else
                 break
               fi
@@ -152,7 +152,7 @@ while :; do echo
               read -p "Please input a number:(Default 2 press Enter) " JDK_version
               [ -z "$JDK_version" ] && JDK_version=2
               if [[ ! $JDK_version =~ ^[2-3]$ ]]; then
-                echo "${CWARNING}input error! Please only input number 2,3${CEND}"
+                echo "${CWARNING}input error! Please only input number 2~3${CEND}"
               else
                 break
               fi
@@ -204,7 +204,7 @@ while :; do echo
               read -p "Please input a number:(Default 1 press Enter) " dbInstallMethods
               [ -z "$dbInstallMethods" ] && dbInstallMethods=1
               if [[ ! $dbInstallMethods =~ ^[1-2]$ ]]; then
-                echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+                echo "${CWARNING}input error! Please only input number 1~2${CEND}"
               else
                 break
               fi
@@ -236,10 +236,11 @@ while :; do echo
         echo -e "\t${CMSG}4${CEND}. Install php-5.6"
         echo -e "\t${CMSG}5${CEND}. Install php-7.0"
         echo -e "\t${CMSG}6${CEND}. Install php-7.1"
-        read -p "Please input a number:(Default 4 press Enter) " PHP_version
-        [ -z "$PHP_version" ] && PHP_version=4
-        if [[ ! $PHP_version =~ ^[1-6]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}"
+        echo -e "\t${CMSG}7${CEND}. Install php-7.2"
+        read -p "Please input a number:(Default 5 press Enter) " PHP_version
+        [ -z "$PHP_version" ] && PHP_version=5
+        if [[ ! $PHP_version =~ ^[1-7]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 1~7${CEND}"
         else
           while :; do echo
             read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
@@ -257,7 +258,7 @@ while :; do echo
                     read -p "Please input a number:(Default 1 press Enter) " PHP_cache
                     [ -z "$PHP_cache" ] && PHP_cache=1
                     if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
-                      echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
+                      echo "${CWARNING}input error! Please only input number 1~4${CEND}"
                     else
                       break
                     fi
@@ -273,7 +274,7 @@ while :; do echo
                     read -p "Please input a number:(Default 1 press Enter) " PHP_cache
                     [ -z "$PHP_cache" ] && PHP_cache=1
                     if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
-                      echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
+                      echo "${CWARNING}input error! Please only input number 1~4${CEND}"
                     else
                       break
                     fi
@@ -288,7 +289,7 @@ while :; do echo
                     read -p "Please input a number:(Default 1 press Enter) " PHP_cache
                     [ -z "$PHP_cache" ] && PHP_cache=1
                     if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
-                      echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                      echo "${CWARNING}input error! Please only input number 1~3${CEND}"
                     else
                       break
                     fi
@@ -303,7 +304,7 @@ while :; do echo
                     read -p "Please input a number:(Default 1 press Enter) " PHP_cache
                     [ -z "$PHP_cache" ] && PHP_cache=1
                     if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
-                      echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                      echo "${CWARNING}input error! Please only input number 1~3${CEND}"
                     else
                       break
                     fi
@@ -323,6 +324,7 @@ while :; do echo
                     fi
                   done
                 fi
+                [ $PHP_version == 7 ] && PHP_cache=1
               fi
               break
             fi
@@ -345,7 +347,7 @@ while :; do echo
           fi
 
           # ionCube
-          if [ "${TARGET_ARCH}" != "arm64" ]; then
+          if [ "${TARGET_ARCH}" != "arm64" ] && [[ $PHP_version =~ ^[1-6]$ ]]; then
             while :; do echo
               read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
               if [[ ! $ionCube_yn =~ ^[y,n]$ ]]; then
@@ -374,7 +376,7 @@ while :; do echo
               read -p "Please input a number:(Default 1 press Enter) " Magick
               [ -z "$Magick" ] && Magick=1
               if [[ ! $Magick =~ ^[1-2]$ ]]; then
-                echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+                echo "${CWARNING}input error! Please only input number 1~2${CEND}"
               else
                 break
               fi
@@ -400,7 +402,7 @@ while :; do echo
 done
 
 # check phpMyAdmin
-if [[ $PHP_version =~ ^[1-6]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then
+if [[ $PHP_version =~ ^[1-7]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then
   while :; do echo
     read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
     if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]]; then
@@ -510,7 +512,7 @@ fi
 
 # openSSL 
 . ./include/openssl.sh
-if [[ $Tomcat_version =~ ^[1-3]$ ]] || [[ $Apache_version =~ ^[1-2]$ ]] || [[ $PHP_version =~ ^[1-6]$ ]]; then
+if [[ $Tomcat_version =~ ^[1-3]$ ]] || [[ $Apache_version =~ ^[1-2]$ ]] || [[ $PHP_version =~ ^[1-7]$ ]]; then
   Install_openSSL102 | tee -a $oneinstack_dir/install.log
 fi
 
@@ -613,6 +615,10 @@ case "${PHP_version}" in
     . include/php-7.1.sh
     Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
+  7)
+    . include/php-7.2.sh
+    Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
 esac
 
 # ImageMagick or GraphicsMagick

+ 1 - 1
ss.sh

@@ -98,7 +98,7 @@ Def_parameter() {
       read -p "Please input a number:(Default 1 press Enter) " SS_version
       [ -z "${SS_version}" ] && SS_version=1
       if [[ ! "${SS_version}" =~ ^[1-2]$ ]]; then
-        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+        echo "${CWARNING}input error! Please only input number 1~2${CEND}"
       else
         break
       fi

+ 7 - 3
upgrade.sh

@@ -44,7 +44,7 @@ IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
 Usage(){
   printf "
 Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} | ${CMSG}phpmyadmin${CEND} ]
-${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty
+${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty/Apache
 ${CMSG}db${CEND}             --->Upgrade MySQL/MariaDB/Percona
 ${CMSG}php${CEND}            --->Upgrade PHP
 ${CMSG}redis${CEND}          --->Upgrade Redis
@@ -58,7 +58,7 @@ Menu(){
   while :; do
     printf "
 What Are You Doing?
-\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
+\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty/Apache
 \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
 \t${CMSG}3${CEND}. Upgrade PHP
 \t${CMSG}4${CEND}. Upgrade Redis
@@ -69,7 +69,7 @@ What Are You Doing?
     echo
     read -p "Please input the correct option: " Number
     if [[ ! $Number =~ ^[1-6,q]$ ]]; then
-      echo "${CWARNING}input error! Please only input 1,2,3,4,5,6 and q${CEND}"
+      echo "${CWARNING}input error! Please only input 1~6 and q${CEND}"
     else
       case "$Number" in
       1)
@@ -79,6 +79,8 @@ What Are You Doing?
           Upgrade_Tengine
         elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
           Upgrade_OpenResty
+        elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+          Upgrade_Apache 
         fi
         ;;
       2)
@@ -115,6 +117,8 @@ elif [ $# == 1 ]; then
       Upgrade_Tengine
     elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
       Upgrade_OpenResty
+    elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+      Upgrade_Apache 
     fi
     ;;
   db)

+ 32 - 31
versions.txt

@@ -1,56 +1,57 @@
 # newest software version
 # Web
-nginx_version=1.12.1
-tengine_version=2.1.1
-openresty_version=1.11.2.5
-openssl_version=1.0.2l
+nginx_version=1.12.2
+tengine_version=2.2.1
+openresty_version=1.13.6.1
+openssl_version=1.0.2m
 
-tomcat8_version=8.5.23
+tomcat8_version=8.5.24
 tomcat7_version=7.0.82
 tomcat6_version=6.0.53
 
-apache24_version=2.4.28
+apache24_version=2.4.29
 apache22_version=2.2.34
 pcre_version=8.41
-apr_version=1.6.2
-apr_util_version=1.6.0
-nghttp2_version=1.24.0
+apr_version=1.6.3
+apr_util_version=1.6.1
+nghttp2_version=1.28.0
 
 # DB
-mysql57_version=5.7.19
-mysql56_version=5.6.37
-mysql55_version=5.5.57
+mysql57_version=5.7.20
+mysql56_version=5.6.38
+mysql55_version=5.5.58
 
-mariadb102_version=10.2.9
-mariadb101_version=10.1.28
-mariadb100_version=10.0.32
-mariadb55_version=5.5.57
+mariadb102_version=10.2.11
+mariadb101_version=10.1.29
+mariadb100_version=10.0.33
+mariadb55_version=5.5.58
 
 percona57_version=5.7.19-17
 percona56_version=5.6.37-82.2
-percona55_version=5.5.57-38.9
+percona55_version=5.5.58-38.10
 
-alisql56_version=5.6.32-6
+alisql56_version=5.6.32-7
 
 # JDK
-jdk18_version=1.8.0_144
+jdk18_version=1.8.0_152
 jdk17_version=1.7.0_80
 jdk16_version=1.6.0_45
 
 # PHP
-php71_version=7.1.10
-php70_version=7.0.24
-php56_version=5.6.31
+php72_version=7.2.0
+php71_version=7.1.12
+php70_version=7.0.26
+php56_version=5.6.32
 php55_version=5.5.38
 php54_version=5.4.45
 php53_version=5.3.29
 
 libiconv_version=1.15
-curl_version=7.56.0
+curl_version=7.57.0
 libmcrypt_version=2.5.8
 mcrypt_version=2.6.8
 mhash_version=0.9.9.9
-ImageMagick_version=6.9.9-19
+ImageMagick_version=6.9.9-25
 imagick_version=3.4.3
 GraphicsMagick_version=1.3.26
 gmagick_for_php7_version=2.0.4RC1
@@ -60,20 +61,20 @@ xcache_version=3.2.0
 apcu_version=4.0.11
 apcu_for_php7_version=5.1.8
 eaccelerator_version=0.9.6.1
-swoole_version=1.9.20
+swoole_version=1.9.23
 
 # Ftp
-pureftpd_version=1.0.46
+pureftpd_version=1.0.47
 
 # Redis
-redis_version=4.0.2
+redis_version=4.0.6
 redis_pecl_version=3.1.4
 
 # Memcached
-memcached_version=1.5.1
+memcached_version=1.5.3
 libmemcached_version=1.0.18
 memcached_pecl_version=2.2.0
-memcached_pecl_php7_version=3.0.3
+memcached_pecl_php7_version=3.0.4
 memcache_pecl_version=3.0.8
 
 # phpMyadmin
@@ -87,10 +88,10 @@ boost_version=1.59.0
 
 # Others
 libevent_version=2.0.22-stable
-tmux_version=2.5
+tmux_version=2.6
 htop_version=2.0.2
 bison_version=2.7.1
 python_version=2.7.14
 setuptools_version=32.0.0
 pip_version=9.0.1
-fail2ban_version=0.10
+fail2ban_version=0.10.1

+ 6 - 4
vhost.sh

@@ -46,7 +46,7 @@ Choose_env() {
       read -p "Please input a number:(Default 1 press Enter) " Choose_number
       [ -z "${Choose_number}" ] && Choose_number=1
       if [[ ! ${Choose_number} =~ ^[1-3]$ ]]; then
-        echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+        echo "${CWARNING}input error! Please only input number 1~3${CEND}"
       else
         break
       fi
@@ -71,7 +71,7 @@ Choose_env() {
       read -p "Please input a number:(Default 1 press Enter) " Choose_number
       [ -z "${Choose_number}" ] && Choose_number=1
       if [[ ! ${Choose_number} =~ ^[1-2]$ ]]; then
-        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+        echo "${CWARNING}input error! Please only input number 1~2${CEND}"
       else
         break
       fi
@@ -90,7 +90,7 @@ Choose_env() {
       read -p "Please input a number:(Default 1 press Enter) " Choose_number
       [ -z "${Choose_number}" ] && Choose_number=1
       if [[ ! ${Choose_number} =~ ^[1-2]$ ]]; then
-        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+        echo "${CWARNING}input error! Please only input number 1~2${CEND}"
       else
         break
       fi
@@ -106,7 +106,7 @@ Choose_env() {
       read -p "Please input a number:(Default 1 press Enter) " Choose_number
       [ -z "${Choose_number}" ] && Choose_number=1
       if [[ ! ${Choose_number} =~ ^[1-2]$ ]]; then
-        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+        echo "${CWARNING}input error! Please only input number 1~2${CEND}"
       else
         break
       fi
@@ -508,6 +508,8 @@ EOF
   <Context path="" docBase="${vhostdir}" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
     prefix="${domain}_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+  <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
+    protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
 </Host>
 EOF
   [ -z "$(grep -o "vhost-${domain} SYSTEM" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://${tomcat_install_dir}/conf/vhost/${domain}.xml\">" ${tomcat_install_dir}/conf/server.xml