Browse Source

first commit

lj2007331 9 years ago
parent
commit
395e77de39
87 changed files with 9868 additions and 1 deletions
  1. 110 1
      README.md
  2. 65 0
      apps.conf
  3. 63 0
      backup.sh
  4. 129 0
      backup_setup.sh
  5. 12 0
      conf/discuz.conf
  6. 3 0
      conf/drupal.conf
  7. 32 0
      conf/ecshop.conf
  8. 40 0
      conf/index.html
  9. 41 0
      conf/index_cn.html
  10. 3 0
      conf/joomla.conf
  11. 86 0
      conf/nginx.conf
  12. 107 0
      conf/nginx_apache.conf
  13. 2 0
      conf/phpwind.conf
  14. 446 0
      conf/pure-ftpd.conf
  15. 45 0
      conf/server.xml
  16. 9 0
      conf/typecho.conf
  17. 4 0
      conf/wordpress.conf
  18. 41 0
      functions/GraphicsMagick.sh
  19. 41 0
      functions/ImageMagick.sh
  20. 86 0
      functions/ZendGuardLoader.sh
  21. 124 0
      functions/apache-2.2.sh
  22. 134 0
      functions/apache-2.4.sh
  23. 32 0
      functions/apcu.sh
  24. 26 0
      functions/check_os.sh
  25. 12 0
      functions/download.sh
  26. 50 0
      functions/eaccelerator-0.9.sh
  27. 50 0
      functions/eaccelerator-1.0-dev.sh
  28. 14 0
      functions/get_ip_area.py
  29. 22 0
      functions/get_local_ip.py
  30. 21 0
      functions/get_public_ip.py
  31. 218 0
      functions/hhvm_CentOS.sh
  32. 50 0
      functions/ioncube.sh
  33. 46 0
      functions/jdk-1.6.sh
  34. 44 0
      functions/jdk-1.7.sh
  35. 44 0
      functions/jdk-1.8.sh
  36. 26 0
      functions/jemalloc.sh
  37. 195 0
      functions/mariadb-10.0.sh
  38. 195 0
      functions/mariadb-5.5.sh
  39. 89 0
      functions/memcached.sh
  40. 201 0
      functions/mysql-5.5.sh
  41. 200 0
      functions/mysql-5.6.sh
  42. 112 0
      functions/nginx.sh
  43. 204 0
      functions/percona-5.5.sh
  44. 204 0
      functions/percona-5.6.sh
  45. 244 0
      functions/php-5.3.sh
  46. 242 0
      functions/php-5.4.sh
  47. 257 0
      functions/php-5.5.sh
  48. 256 0
      functions/php-5.6.sh
  49. 261 0
      functions/php-7.sh
  50. 21 0
      functions/phpmyadmin.sh
  51. 65 0
      functions/pureftpd.sh
  52. 85 0
      functions/redis.sh
  53. 27 0
      functions/tcmalloc.sh
  54. 101 0
      functions/tengine.sh
  55. 38 0
      functions/test.sh
  56. 99 0
      functions/tomcat-7.sh
  57. 99 0
      functions/tomcat-8.sh
  58. 82 0
      functions/xcache.sh
  59. 50 0
      functions/zendopcache.sh
  60. 81 0
      init/Memcached-init-CentOS
  61. 85 0
      init/Memcached-init-Ubuntu
  62. 128 0
      init/Nginx-init-CentOS
  63. 336 0
      init/Nginx-init-Ubuntu
  64. 102 0
      init/Redis-server-init-CentOS
  65. 60 0
      init/Redis-server-init-Ubuntu
  66. 109 0
      init/Tomcat-init
  67. 96 0
      init/hhvm-init-CentOS6
  68. 250 0
      init/init_CentOS.sh
  69. 145 0
      init/init_Debian.sh
  70. 164 0
      init/init_Ubuntu.sh
  71. 733 0
      install.sh
  72. 60 0
      options.conf
  73. 169 0
      pureftpd_vhost.sh
  74. 13 0
      tools/ckssh.py
  75. 33 0
      tools/db_bk.sh
  76. 172 0
      tools/mabs.sh
  77. 158 0
      tools/mscp.exp
  78. 129 0
      tools/mssh.exp
  79. 46 0
      tools/thread.sh
  80. 13 0
      tools/website_bk.sh
  81. 106 0
      uninstall.sh
  82. 79 0
      upgrade_php.sh
  83. 78 0
      upgrade_phpmyadmin.sh
  84. 89 0
      upgrade_redis.sh
  85. 152 0
      upgrade_web.sh
  86. 565 0
      vhost.sh
  87. 112 0
      vpn_centos.sh

+ 110 - 1
README.md

@@ -1 +1,110 @@
-# oneinstack
+   OneinStack is free collection of shell scripts for rapid deployment of `LEMP`/`LAMP`/`LNMP` stacks (`Linux`, `Nginx`/`Tengine`, `MySQL`/`MariaDB`/`Percona` and `PHP`) for CentOS/Redhat Debian and Ubuntu.
+
+   Script features: 
+- Constant updates 
+- Source compiler installation, most source code is the latest stable version, and downloaded from the official website
+- Fixes some security issues 
+- You can freely choose to install database version (MySQL-5.6, MySQL-5.5, MariaDB-10.0, MariaDB-5.5, Percona-5.6, Percona-5.5)
+- You can freely choose to install PHP version (php-5.3, php-5.4, php-5.5, php-5.6, php-7/phpng(alpha))
+- You can freely choose to install HHVM version (CentOS6.5 64bit, CentOS7 64bit)
+- You can freely choose to install Nginx or Tengine
+- You can freely choose to install Apache version (Apache-2.4, Apache-2.2)
+- You can freely choose to install Tomcat version (Tomcat-8, Tomcat-7)
+- You can freely choose to install JDK version (JDK-1.6, JDK-1.7, JDK-1.8)
+- According to their needs can to install ZendOPcache, xcache, APCU, eAccelerator, ionCube and ZendGuardLoader (php-5.4, php-5.3)
+- According to their needs can to install Pureftpd, phpMyAdmin
+- According to their needs can to install memcached, redis
+- According to their needs can to optimize MySQL and Nginx with jemalloc or tcmalloc
+- Add a virtual host script provided
+- Nginx/Tengine, PHP, Redis, phpMyAdmin upgrade script provided
+- Add backup script provided
+
+## How to use 
+
+```bash
+   yum -y install wget screen # for CentOS/Redhat
+   #apt-get -y install wget screen # for Debian/Ubuntu 
+   wget http://mirrors.linuxeye.com/oneinstack.tar.gz
+   # or download include source packages
+   wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
+   tar xzf oneinstack.tar.gz
+   # or tar xzf oneinstack-full.tar.gz
+   cd oneinstack 
+   # Prevent interrupt the installation process. If the network is down, 
+   # you can execute commands `screen -r oneinstack` network reconnect the installation window.
+   screen -S oneinstack 
+   ./install.sh
+```
+
+## How to add a virtual host
+
+```bash
+   ./vhost.sh
+```
+
+## How to add FTP virtual user 
+
+```bash
+   ./pureftpd_vhost.sh
+```
+
+## How to backup
+
+```bash
+   ./backup_setup.sh # Set backup options 
+   ./backup.sh # Start backup, You can add cron jobs
+   # crontab -l # Examples 
+     0 1 * * * cd ~/lnmp;./backup.sh  > /dev/null 2>&1 &
+```
+
+## How to manage service
+Nginx/Tengine:
+```bash
+   service nginx {start|stop|status|restart|reload|configtest}
+```
+MySQL/MariaDB/Percona:
+```bash
+   service mysqld {start|stop|restart|reload|status}
+```
+PHP:
+```bash
+   service php-fpm {start|stop|restart|reload|status}
+```
+Apache:
+```bash
+   service httpd {start|restart|stop}
+```
+Tomcat:
+```bash
+   service tomcat {start|stop|status|restart} 
+```
+Pure-Ftpd:
+```bash
+   service pureftpd {start|stop|restart|status}
+```
+Redis:
+```bash
+   service redis-server {start|stop|status|restart|reload}
+```
+Memcached:
+```bash
+   service memcached {start|stop|status|restart|reload}
+```
+
+## How to upgrade 
+```bash
+   ./upgrade_php.sh # upgrade PHP
+   ./upgrade_web.sh # upgrade Nginx/Tengine
+   ./upgrade_redis.sh # upgrade Redis 
+   ./upgrade_phpmyadmin.sh # upgrade phpMyAdmin 
+```
+
+## How to uninstall 
+
+```bash
+   ./uninstall.sh
+```
+
+## Installation
+   For feedback, questions, and to follow the progress of the project (Chinese): <br />
+   [OneinStack](http://oneinstack.com)<br />

+ 65 - 0
apps.conf

@@ -0,0 +1,65 @@
+# newest software version
+# Web
+nginx_version=1.8.0
+tengine_version=2.1.0
+apache_2_version=2.2.29
+apache_4_version=2.4.12
+pcre_version=8.37
+apr_version=1.5.1
+apr_util_version=1.5.4
+
+# DB
+mysql_6_version=5.6.25
+mysql_5_version=5.5.44
+mariadb_10_version=10.0.19
+mariadb_5_version=5.5.44
+percona_6_version=5.6.24-72.2
+percona_5_version=5.5.43-37.2
+
+# PHP
+php_3_version=5.3.29
+php_4_version=5.4.42
+php_5_version=5.5.26
+php_6_version=5.6.10
+php_7_version=7.0.0alpha1
+
+zendopcache_version=7.0.5
+xcache_version=3.2.0
+apcu_version=4.0.7
+ImageMagick_version=6.8.8-10
+imagick_version=3.1.2
+GraphicsMagick_version=1.3.20
+gmagick_version=1.1.7RC2
+libiconv_version=1.14
+libmcrypt_version=2.5.8
+mcrypt_version=2.6.8
+mhash_version=0.9.9.9
+
+# JDK
+jdk_6_version=1.6.45
+jdk_7_version=1.7.80
+jdk_8_version=1.8.45
+
+# tomcat
+tomcat_7_version=7.0.62
+tomcat_8_version=8.0.23
+
+# Ftp
+pureftpd_version=1.0.39
+
+# Redis
+redis_version=2.8.21
+redis_pecl_version=2.2.7
+
+# Memcached
+memcached_version=1.4.24
+libmemcached_version=1.0.18
+memcached_pecl_version=2.2.0
+memcache_pecl_version=2.2.7
+
+# phpMyadmin
+phpMyAdmin_version=4.4.9
+
+# malloc
+tcmalloc_version=2.4
+jemalloc_version=3.6.0

+ 63 - 0
backup.sh

@@ -0,0 +1,63 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+. ./options.conf
+DB_Local_BK() {
+	for D in `echo $db_name | tr ',' ' '`
+	do
+		cd $oneinstack_dir/tools
+		./db_bk.sh $D
+	done
+}
+
+DB_Remote_BK() {
+        for D in `echo $db_name | tr ',' ' '`
+        do
+                cd $oneinstack_dir/tools
+                ./db_bk.sh $D
+		DB_GREP="DB_${D}_`date +%Y`"
+                DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
+                echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> $oneinstack_dir/tools/config.txt
+                echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> $oneinstack_dir/tools/config.txt
+        done
+}
+
+WEB_Local_BK() {
+	for W in `echo $website_name | tr ',' ' '`
+        do
+                cd $oneinstack_dir/tools
+                ./website_bk.sh $W
+        done
+}
+
+WEB_Remote_BK() {
+        for W in `echo $website_name | tr ',' ' '`
+        do
+		cd $oneinstack_dir/tools
+                echo "file:::$home_dir/$W $backup_dir push" >> $oneinstack_dir/tools/config.txt
+        done
+}
+
+if [ "$local_bankup_yn" == 'y' -a "$remote_bankup_yn" == 'n' ];then
+	WEB_Local_BK
+	DB_Local_BK
+elif [ "$local_bankup_yn" == 'n' -a "$remote_bankup_yn" == 'y' ];then
+	echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > $oneinstack_dir/tools/config.txt
+	DB_Remote_BK
+	WEB_Remote_BK
+	./mabs.sh -T -1 | tee mabs.log	
+elif [ "$local_bankup_yn" == 'y' -a "$remote_bankup_yn" == 'y' ];then
+	echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > $oneinstack_dir/tools/config.txt
+	WEB_Local_BK
+	WEB_Remote_BK
+	DB_Local_BK
+	DB_Remote_BK
+	./mabs.sh -T -1 | tee mabs.log	
+fi

+ 129 - 0
backup_setup.sh

@@ -0,0 +1,129 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+while : 
+do
+	echo
+	echo 'Please select your backup destination:'
+	echo -e "\t\033[32m1\033[0m. Only Localhost"
+	echo -e "\t\033[32m2\033[0m. Only Remote host"
+	echo -e "\t\033[32m3\033[0m. Localhost and remote host"
+	read -p "Please input a number:(Default 1 press Enter) " DESC_BK 
+	[ -z "$DESC_BK" ] && DESC_BK=1
+	if [ $DESC_BK != 1 -a $DESC_BK != 2 -a $DESC_BK != 3 ];then
+	        echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+	else
+	        break
+	fi
+done
+
+[ "$DESC_BK" == '1' ] && { sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf; sed -i 's@remote_bankup_yn=.*@remote_bankup_yn=n@' ./options.conf; }
+[ "$DESC_BK" == '2' ] && { sed -i 's@^local_bankup_yn=.*@local_bankup_yn=n@' ./options.conf; sed -i 's@remote_bankup_yn=.*@remote_bankup_yn=y@' ./options.conf; }
+[ "$DESC_BK" == '3' ] && { sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf; sed -i 's@remote_bankup_yn=.*@remote_bankup_yn=y@' ./options.conf; }
+
+. ./options.conf
+
+while :
+do
+	echo
+	echo "Please enter the directory for save the backup file: "
+	read -p "(Default directory: /home/backup): " backup_dir 
+	[ -z "$backup_dir" ] && backup_dir="/home/backup"
+        if [ -z "`echo $backup_dir | grep '^/'`" ]; then
+                echo -e "\033[31minput error! \033[0m"
+        else
+                break
+        fi
+done
+sed -i "s@^backup_dir=.*@backup_dir=$backup_dir@" ./options.conf
+
+while :
+do
+	echo
+	echo "Pleas enter a valid backup number of days: "
+	read -p "(Default days: 5): " expired_days 
+	[ -z "$expired_days" ] && expired_days=5
+	[ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo -e "\033[31minput error! Please only enter numbers! \033[0m"
+done
+sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf
+
+databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|ftpusers)"`
+while :
+do
+	echo
+	echo "Please enter one or more name for database, separate multiple database names with commas: "
+	read -p "(Default database: `echo $databases | tr ' ' ','`) " db_name
+	db_name=`echo $db_name | tr -d ' '`
+	[ -z "$db_name" ] && db_name="`echo $databases | tr ' ' ','`"
+	D_tmp=0
+	echo $db_name
+	for D in `echo $db_name | tr ',' ' '`
+	do
+		[ -z "`echo $databases | grep -w $D`" ] && { echo -e "\033[31m$D not exist! \033[0m" ; D_tmp=1; }
+	done
+	[ "$D_tmp" != '1' ] && break
+done
+sed -i "s@^db_name=.*@db_name=$db_name@" ./options.conf
+
+websites=`ls $home_dir | grep -vw default`
+while :
+do
+        echo
+        echo "Please enter one or more name for website, separate multiple website names with commas: "
+        read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name 
+        website_name=`echo $website_name | tr -d ' '`
+        [ -z "$website_name" ] && website_name="`echo $websites | tr ' ' ','`"
+        W_tmp=0
+        echo $db_name
+        for W in `echo $website_name | tr ',' ' '`
+        do
+                [ ! -e "$home_dir/$W" ] && { echo -e "\033[31m$home_dir/$W not exist! \033[0m" ; W_tmp=1; }
+        done
+        [ "$W_tmp" != '1' ] && break
+done
+echo $website_name
+sed -i "s@^website_name=.*@website_name=$website_name@" ./options.conf
+
+if [ "$remote_bankup_yn" == 'y' ];then
+	> tools/iplist.txt
+	while :
+	do
+		echo
+		read -p "Please enter the remote host ip: " remote_ip
+		[ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
+		echo
+		read -p "Please enter the remote host port(Default: 22) : " remote_port
+		[ -z "$remote_port" ] && remote_port=22 
+		echo
+		read -p "Please enter the remote host user(Default: root) : " remote_user
+		[ -z "$remote_user" ] && remote_user=root 
+		echo
+		read -p "Please enter the remote host password: " remote_password
+	        IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+	        Portcode=$(echo "ibase=16;$(echo "$remote_port" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+	        PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+		[ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
+		./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
+		if [ $? -eq 0 ];then
+			[ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo -e "\033[31m$remote_ip has been added! \033[0m" 
+			while :
+			do
+				echo
+			        read -p "Do you want to add more host ? [y/n]: " more_host_yn 
+			        if [ "$more_host_yn" != 'y' -a "$more_host_yn" != 'n' ];then
+			                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+			        else
+					break
+				fi
+			done
+			[ "$more_host_yn" == 'n' ] && break
+		fi
+	done
+fi

+ 12 - 0
conf/discuz.conf

@@ -0,0 +1,12 @@
+rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
+rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
+rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
+rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
+rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
+rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
+rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
+rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
+rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
+#if (!-e $request_filename) {
+#	return 404;
+#}

+ 3 - 0
conf/drupal.conf

@@ -0,0 +1,3 @@
+if (!-e $request_filename) {
+      rewrite ^/(.*)$ /index.php?q=$1 last;
+    }

+ 32 - 0
conf/ecshop.conf

@@ -0,0 +1,32 @@
+if (!-e $request_filename)
+{
+rewrite "^/index\.html" /index.php last;
+rewrite "^/category$" /index.php last;
+rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last;
+rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last;
+rewrite "^/feed\.xml$" /feed.php last;
+rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;
+rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last;
+rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;
+rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last;
+rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last;
+rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last;
+rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last;
+rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;
+rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last;
+rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last;
+rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last;
+rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;
+rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last;
+rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last;
+rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last;
+rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last;
+rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last;
+rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last;
+rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last;
+rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last;
+rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last;
+rewrite "^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;
+rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last;
+rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last;
+}

+ 40 - 0
conf/index.html

@@ -0,0 +1,40 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>OneinStack - A PHP/JAVA Deployment Tool</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta name="keywords" content="OneinStack,lemp Stack,lamp Stack,lnmp stack">
+<meta name="description" content="OneinStack is a LEMP, LAMP stack of Nginx, Apache, Tomcat, MySQL, MariaDB, Percona, Redis, Memcached, Pureftpd, PHP & JAVA. It's quite simple to use, manage and extend.">
+<style type="text/css">
+<!--
+body {
+color:#333333;
+font-family:"Microsoft YaHei",sans-serif;
+}
+.links {color: #009900}
+#main {
+	margin-right: auto;
+	margin-left: auto;
+	width: 920px;
+}
+-->
+</style>
+</head>
+<body>
+<div id="main">
+<br>
+<div align="center"><h2>Congratulations, OneinStack a successful installation!</h2></div>
+<h3><a href="http://oneinstack.com" target="_blank" class="links">OneinStack </a><a href="http://www.linuxeye.com/" target="_blank">Linux</a>+Nginx/Tengine+MySQL/MariaDB/Percona</br>+PHP+Pureftpd+phpMyAdmin+redis+memcached+jemalloc/tcmalloc.</h3>
+<p><b>Check environment:&nbsp;&nbsp;</b><a href="/proberv.php" target="_blank" class="links">Proberv</a>&nbsp;<a href="/phpinfo.php" target="_blank" class="links">phpinfo</a>&nbsp;<a href="/xcache" target="_blank" class="links">xcache</a>&nbsp;<a href="/phpMyAdmin/" target="_blank" class="links">phpMyAdmin</a></p>
+<p><b>Create Web virtual running script:</b>&nbsp;&nbsp;<font color="#008000">./vhost.sh</font></p>
+<p><b>Create FTP virtual running script:</b>&nbsp;&nbsp;<font color="#008000">./pureftpd_vhost.sh</font></p>
+<p><b>For feedback, questions, and to follow the progress of the project:&nbsp;&nbsp;</b> <a target="_blank" class="links" href="http://oneinstack.com">http://oneinstack.com</a></p>
+<p><b>Author email:&nbsp;&nbsp;</b><a class="email" href="mailto:lj2007331@gmail.com">lj2007331@gmail.com</a></p>
+<p><b>Donate:</b></p>
+<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PayPal:&nbsp;&nbsp;lj2007331@gmail.com</p>
+<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AliPay:&nbsp;&nbsp;lj2007331@gmail.com</p>
+<div align="center"><iframe src="http://blog.linuxeye.com/ad_buttom.html" width="475" frameborder="0" scrolling="no"></iframe></div>
+<div align="center"><h3><a href="http://oneinstack.com" target="_blank">OneinStack</a> by <a href="http://blog.linuxeye.com/" target="_blank">LinuxEye</a></h3></div>
+</div>
+</body>
+</html>

+ 41 - 0
conf/index_cn.html

@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>OneinStack - PHP/JAVA环境一键部署工具</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta name="keywords" content="OneinStack,LAMP Stack,LNMP Stack,lnmpa stack">
+<meta name="description" content="OneinStack是PHP/JAVA环境一键部署工具, 包括Nginx, Apache, Tomcat, MySQL, MariaDB, Percona, Redis, Memcached, Pureftpd, PHP & JAVA.">
+<style type="text/css">
+<!--
+body {
+color:#333333;
+font-family:微软雅黑,sans-serif;
+}
+.links {color: #009900}
+#main {
+	margin-right: auto;
+	margin-left: auto;
+	width: 920px;
+}
+-->
+</style>
+</head>
+<body>
+<div id="main">
+<br>
+<div align="center"><h2>Congratulations, OneinStack安装成功!</h2></div>
+<h3><a href="http://oneinstack.com" target="_blank" class="links">OneinStack </a> <a href="http://www.linuxeye.com/" target="_blank">Linux</a>+Nginx/Tengine+MySQL/MariaDB/Percona+PHP</br>+Pureftpd+phpMyAdmin+redis+memcached+jemalloc/tcmalloc. 脚本中用到的软件包大多最新稳定版本,修复了一些安全性问题。</h3>
+<p><b>查看本地环境:</b>&nbsp;&nbsp;<a href="/tz.php" target="_blank" class="links">探针</a>&nbsp;<a href="/phpinfo.php" target="_blank" class="links">phpinfo</a>&nbsp;<a href="/xcache" target="_blank" class="links">xcache</a>&nbsp;<a href="/phpMyAdmin/" target="_blank" class="links">phpMyAdmin</a>(为了更安全,建议phpMyAdmin目录重命名!)</p>
+<p><b>创建WEB虚拟主机执行脚本:</b>&nbsp;&nbsp;<font color="#008000">./vhost.sh</font></p>
+<p><b>创建FTP虚拟账号执行脚本:</b>&nbsp;&nbsp;<font color="#008000">./pureftpd_vhost.sh</font></p>
+<p><b>Github项目地址:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://github.com/lj2007331/oneinstack">https://github.com/lj2007331/oneinstack</a></p>
+<p><b>OneinStack问题反馈请访问:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="http://oneinstack.com">http://oneinstack.com</a></p>
+<p><b>QQ群:</b>&nbsp;&nbsp;438311066(新) 235258658(满)</p>
+<p><b>赞助我们:</b></p>
+<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;支付宝:&nbsp;&nbsp;lj2007331@gmail.com</p>
+<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PayPal:&nbsp;&nbsp;lj2007331@gmail.com</p>
+<div align="center"><iframe src="http://blog.linuxeye.com/ad_buttom.html" width="475" frameborder="0" scrolling="no"></iframe></div>
+<div align="center"><h3><a href="http://oneinstack.com" target="_blank">OneinStack</a> by <a href="http://blog.linuxeye.com/" target="_blank">Linux运维笔记</a></h3></div>
+</div>
+</body>
+</html>

+ 3 - 0
conf/joomla.conf

@@ -0,0 +1,3 @@
+location / {
+        try_files $uri $uri/ /index.php?$args;
+}

+ 86 - 0
conf/nginx.conf

@@ -0,0 +1,86 @@
+user www www;
+worker_processes auto;
+
+error_log /home/wwwlogs/error_nginx.log crit;
+pid /var/run/nginx.pid;
+worker_rlimit_nofile 51200;
+
+events {
+	use epoll;
+	worker_connections 51200;
+	}
+
+http {
+	include mime.types;
+	default_type application/octet-stream;
+	server_names_hash_bucket_size 128;
+	client_header_buffer_size 32k;
+	large_client_header_buffers 4 32k;
+	client_max_body_size 50m;
+	sendfile on;
+	tcp_nopush on;
+	keepalive_timeout 120;
+	server_tokens off;
+	tcp_nodelay on;
+
+	fastcgi_connect_timeout 300;
+	fastcgi_send_timeout 300;
+	fastcgi_read_timeout 300;
+	fastcgi_buffer_size 64k;
+	fastcgi_buffers 4 64k;
+	fastcgi_busy_buffers_size 128k;
+	fastcgi_temp_file_write_size 128k;
+
+#Gzip Compression
+	gzip on;
+	gzip_buffers 16 8k;
+	gzip_comp_level 6;
+	gzip_http_version 1.1;
+	gzip_min_length 256;
+	gzip_proxied any;
+	gzip_vary on;
+	gzip_types
+	    text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
+	    text/javascript application/javascript application/x-javascript
+	    text/x-json application/json application/x-web-app-manifest+json
+	    text/css text/plain text/x-component
+	    font/opentype application/x-font-ttf application/vnd.ms-fontobject
+	    image/x-icon;
+	gzip_disable  "msie6";
+
+#If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
+        open_file_cache max=1000 inactive=20s;
+        open_file_cache_valid 30s;
+        open_file_cache_min_uses 2;
+        open_file_cache_errors on;
+
+###################pureftpd AND phpmyadmin############################
+        server {
+        listen 80;
+        server_name _;
+        access_log /home/wwwlogs/access_nginx.log combined;
+        root /home/wwwroot/default;
+        index index.html index.php;
+        if ( $query_string ~* ".*[\;'\<\>].*" ){
+                return 404;
+	        }
+
+        location ~ .*\.(php|php5)?$ {
+		#fastcgi_pass remote_php_ip:9000;
+	        fastcgi_pass unix:/dev/shm/php-cgi.sock;
+		fastcgi_index index.php;
+		include fastcgi.conf;
+		}
+
+        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+		expires 30d;
+	        }
+
+        location ~ .*\.(js|css)?$ {
+                expires 7d;
+                }
+        }
+
+##########################vhost#####################################
+	include vhost/*.conf;
+}

+ 107 - 0
conf/nginx_apache.conf

@@ -0,0 +1,107 @@
+user www www;
+worker_processes auto;
+
+error_log /home/wwwlogs/error_nginx.log crit;
+pid /var/run/nginx.pid;
+worker_rlimit_nofile 51200;
+
+events {
+	use epoll;
+	worker_connections 51200;
+	}
+
+http {
+	include mime.types;
+	default_type application/octet-stream;
+	server_names_hash_bucket_size 128;
+	client_header_buffer_size 32k;
+	large_client_header_buffers 4 32k;
+	client_max_body_size 50m;
+	sendfile on;
+	tcp_nopush on;
+	keepalive_timeout 120;
+	server_tokens off;
+	tcp_nodelay on;
+
+	proxy_connect_timeout 300s;
+	proxy_send_timeout 900;
+	proxy_read_timeout 900;
+	proxy_buffer_size 32k;
+	proxy_buffers 4 64k;
+	proxy_busy_buffers_size 128k;
+	proxy_redirect off;
+	proxy_hide_header Vary;
+	proxy_set_header Accept-Encoding '';
+	proxy_set_header Host $host;
+	proxy_set_header Referer $http_referer;
+	proxy_set_header Cookie $http_cookie;
+	proxy_set_header X-Real-IP $remote_addr;
+	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+	fastcgi_connect_timeout 300;
+	fastcgi_send_timeout 300;
+	fastcgi_read_timeout 300;
+	fastcgi_buffer_size 64k;
+	fastcgi_buffers 4 64k;
+	fastcgi_busy_buffers_size 128k;
+	fastcgi_temp_file_write_size 128k;
+
+#Gzip Compression
+        gzip on;
+        gzip_buffers 16 8k;
+        gzip_comp_level 6;
+        gzip_http_version 1.1;
+        gzip_min_length 256;
+        gzip_proxied any;
+        gzip_vary on;
+        gzip_types
+            text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
+            text/javascript application/javascript application/x-javascript
+            text/x-json application/json application/x-web-app-manifest+json
+            text/css text/plain text/x-component
+            font/opentype application/x-font-ttf application/vnd.ms-fontobject
+            image/x-icon;
+        gzip_disable  "msie6";
+
+#If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
+        open_file_cache max=1000 inactive=20s;
+        open_file_cache_valid 30s;
+        open_file_cache_min_uses 2;
+        open_file_cache_errors on;
+
+###################pureftpd AND phpmyadmin############################
+        server {
+        listen 80;
+        server_name _;
+        access_log /home/wwwlogs/access_nginx.log combined;
+        root /home/wwwroot/default;
+        index index.html index.php;
+        if ( $query_string ~* ".*[\;'\<\>].*" ){
+                return 404;
+	        }
+
+	location / {
+		try_files $uri @apache;
+		}
+
+	location @apache {
+		internal;
+		proxy_pass http://127.0.0.1:8080;
+		}
+
+        location ~ .*\.(php|php5)?$  {
+		proxy_pass http://127.0.0.1:8080;
+		}
+
+        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+                expires 30d;
+                }
+
+        location ~ .*\.(js|css)?$ {
+                expires 7d;
+                }
+        }
+
+##########################vhost#####################################
+	include vhost/*.conf;
+}

+ 2 - 0
conf/phpwind.conf

@@ -0,0 +1,2 @@
+rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
+rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;

+ 446 - 0
conf/pure-ftpd.conf

@@ -0,0 +1,446 @@
+
+############################################################
+#                                                          #
+#         Configuration file for pure-ftpd wrappers        #
+#                                                          #
+############################################################
+
+# If you want to run Pure-FTPd with this configuration   
+# instead of command-line options, please run the
+# following command :
+#
+# /usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
+#
+# Please don't forget to have a look at documentation at
+# http://www.pureftpd.org/documentation.shtml for a complete list of
+# options.
+
+# Cage in every user in his home directory
+
+ChrootEveryone              yes
+
+
+
+# If the previous option is set to "no", members of the following group
+# won't be caged. Others will be. If you don't want chroot()ing anyone,
+# just comment out ChrootEveryone and TrustedGID.
+
+# TrustedGID                    100
+
+
+
+# Turn on compatibility hacks for broken clients
+
+BrokenClientsCompatibility  no
+
+
+
+# Maximum number of simultaneous users
+
+MaxClientsNumber            50
+
+
+
+# Fork in background
+
+Daemonize                   yes
+
+
+
+# Maximum number of sim clients with the same IP address
+
+MaxClientsPerIP             5
+
+
+
+# If you want to log all client commands, set this to "yes".
+# This directive can be duplicated to also log server responses.
+
+VerboseLog                  no
+
+
+
+# List dot-files even when the client doesn't send "-a".
+
+DisplayDotFiles             yes
+
+
+
+# Don't allow authenticated users - have a public anonymous FTP only.
+
+AnonymousOnly               no
+
+
+
+# Disallow anonymous connections. Only allow authenticated users.
+
+NoAnonymous                 yes
+
+
+
+# Syslog facility (auth, authpriv, daemon, ftp, security, user, local*)
+# The default facility is "ftp". "none" disables logging.
+
+SyslogFacility              ftp
+
+
+
+# Display fortune cookies
+
+# FortunesFile              /usr/share/fortune/zippy
+
+
+
+# Don't resolve host names in log files. Logs are less verbose, but 
+# it uses less bandwidth. Set this to "yes" on very busy servers or
+# if you don't have a working DNS.
+
+DontResolve                 yes
+
+
+
+# Maximum idle time in minutes (default = 15 minutes)
+
+MaxIdleTime                 15
+
+
+
+# LDAP configuration file (see README.LDAP)
+
+# LDAPConfigFile                /etc/pureftpd-ldap.conf
+
+
+
+# MySQL configuration file (see README.MySQL)
+
+# MySQLConfigFile               /usr/local/pureftpd/etc/pureftpd-mysql.conf
+
+
+# Postgres configuration file (see README.PGSQL)
+
+# PGSQLConfigFile               /etc/pureftpd-pgsql.conf
+
+
+# PureDB user database (see README.Virtual-Users)
+
+PureDB                        /usr/local/pureftpd/etc/pureftpd.pdb
+
+
+# Path to pure-authd socket (see README.Authentication-Modules)
+
+# ExtAuth                       /var/run/ftpd.sock
+
+
+
+# If you want to enable PAM authentication, uncomment the following line
+
+# PAMAuthentication             yes
+
+
+
+# If you want simple Unix (/etc/passwd) authentication, uncomment this
+
+UnixAuthentication            yes
+
+
+
+# Please note that LDAPConfigFile, MySQLConfigFile, PAMAuthentication and
+# UnixAuthentication can be used only once, but they can be combined
+# together. For instance, if you use MySQLConfigFile, then UnixAuthentication,
+# the SQL server will be asked. If the SQL authentication fails because the
+# user wasn't found, another try # will be done with /etc/passwd and
+# /etc/shadow. If the SQL authentication fails because the password was wrong,
+# the authentication chain stops here. Authentication methods are chained in
+# the order they are given. 
+
+
+
+# 'ls' recursion limits. The first argument is the maximum number of
+# files to be displayed. The second one is the max subdirectories depth
+
+LimitRecursion              2000 8
+
+
+
+# Are anonymous users allowed to create new directories ?
+
+AnonymousCanCreateDirs      no
+
+
+
+# If the system is more loaded than the following value,
+# anonymous users aren't allowed to download.
+
+MaxLoad                     4
+
+
+
+# Port range for passive connections replies. - for firewalling.
+
+PassivePortRange          20000 30000
+
+
+
+# Force an IP address in PASV/EPSV/SPSV replies. - for NAT.
+# Symbolic host names are also accepted for gateways with dynamic IP
+# addresses.
+
+# ForcePassiveIP                192.168.0.1
+
+
+
+# Upload/download ratio for anonymous users.
+
+# AnonymousRatio                1 10
+
+
+
+# Upload/download ratio for all users.
+# This directive superscedes the previous one.
+
+# UserRatio                 1 10
+
+
+
+# Disallow downloading of files owned by "ftp", ie.
+# files that were uploaded but not validated by a local admin.
+
+AntiWarez                   yes
+
+
+
+# IP address/port to listen to (default=all IP and port 21).
+
+# Bind                      127.0.0.1,21
+
+
+
+# Maximum bandwidth for anonymous users in KB/s
+
+# AnonymousBandwidth            8
+
+
+
+# Maximum bandwidth for *all* users (including anonymous) in KB/s
+# Use AnonymousBandwidth *or* UserBandwidth, both makes no sense.
+
+# UserBandwidth             8
+
+
+
+# File creation mask. <umask for files>:<umask for dirs> .
+# 177:077 if you feel paranoid.
+
+Umask                       133:022
+
+
+
+# Minimum UID for an authenticated user to log in.
+
+MinUID                      100
+
+
+
+# Allow FXP transfers for authenticated users.
+
+AllowUserFXP                no
+
+
+
+# Allow anonymous FXP for anonymous and non-anonymous users.
+
+AllowAnonymousFXP           no
+
+
+
+# Users can't delete/write files beginning with a dot ('.')
+# even if they own them. If TrustedGID is enabled, this group
+# will have access to dot-files, though.
+
+ProhibitDotFilesWrite       no
+
+
+
+# Prohibit *reading* of files beginning with a dot (.history, .ssh...)
+
+ProhibitDotFilesRead        no
+
+
+
+# Never overwrite files. When a file whoose name already exist is uploaded,
+# it get automatically renamed to file.1, file.2, file.3, ...
+
+AutoRename                  no
+
+
+
+# Disallow anonymous users to upload new files (no = upload is allowed)
+
+AnonymousCantUpload         no
+
+
+
+# Only connections to this specific IP address are allowed to be
+# non-anonymous. You can use this directive to open several public IPs for
+# anonymous FTP, and keep a private firewalled IP for remote administration.
+# You can also only allow a non-routable local IP (like 10.x.x.x) to
+# authenticate, and keep a public anon-only FTP server on another IP.
+
+#TrustedIP                  10.1.1.1
+
+
+
+# If you want to add the PID to every logged line, uncomment the following
+# line.
+
+#LogPID                     yes
+
+
+
+# Create an additional log file with transfers logged in a Apache-like format :
+# fw.c9x.org - jedi [13/Dec/1975:19:36:39] "GET /ftp/linux.tar.bz2" 200 21809338
+# This log file can then be processed by www traffic analyzers.
+
+# AltLog                     clf:/var/log/pureftpd.log
+
+
+
+# Create an additional log file with transfers logged in a format optimized
+# for statistic reports.
+
+# AltLog                     stats:/var/log/pureftpd.log
+
+
+
+# Create an additional log file with transfers logged in the standard W3C
+# format (compatible with most commercial log analyzers)
+
+# AltLog                     w3c:/var/log/pureftpd.log
+
+
+
+# Disallow the CHMOD command. Users can't change perms of their files.
+
+#NoChmod                     yes
+
+
+
+# Allow users to resume and upload files, but *NOT* to delete them.
+
+#KeepAllFiles                yes
+
+
+
+# Automatically create home directories if they are missing
+
+CreateHomeDir               no
+
+
+
+# Enable virtual quotas. The first number is the max number of files.
+# The second number is the max size of megabytes.
+# So 1000:10 limits every user to 1000 files and 10 Mb.
+
+#Quota                       1000:10
+
+
+
+# If your pure-ftpd has been compiled with standalone support, you can change
+# the location of the pid file. The default is /var/run/pure-ftpd.pid
+
+#PIDFile                     /var/run/pure-ftpd.pid
+
+
+
+# If your pure-ftpd has been compiled with pure-uploadscript support,
+# this will make pure-ftpd write info about new uploads to
+# /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
+# spawn a script to handle the upload.
+
+#CallUploadScript yes
+
+
+
+# This option is useful with servers where anonymous upload is 
+# allowed. As /var/ftp is in /var, it save some space and protect 
+# the log files. When the partition is more that X percent full,
+# new uploads are disallowed.
+
+MaxDiskUsage               99
+
+
+
+# Set to 'yes' if you don't want your users to rename files.
+
+#NoRename                  yes
+
+
+
+# Be 'customer proof' : workaround against common customer mistakes like
+# 'chmod 0 public_html', that are valid, but that could cause ignorant
+# customers to lock their files, and then keep your technical support busy
+# with silly issues. If you're sure all your users have some basic Unix
+# knowledge, this feature is useless. If you're a hosting service, enable it.
+
+CustomerProof              yes
+
+
+
+# Per-user concurrency limits. It will only work if the FTP server has
+# been compiled with --with-peruserlimits (and this is the case on
+# most binary distributions) .
+# The format is : <max sessions per user>:<max anonymous sessions>
+# For instance, 3:20 means that the same authenticated user can have 3 active
+# sessions max. And there are 20 anonymous sessions max.
+
+# PerUserLimits            3:20
+
+
+
+# When a file is uploaded and there is already a previous version of the file
+# with the same name, the old file will neither get removed nor truncated.
+# Upload will take place in a temporary file and once the upload is complete,
+# the switch to the new version will be atomic. For instance, when a large PHP
+# script is being uploaded, the web server will still serve the old version and
+# immediatly switch to the new one as soon as the full file will have been
+# transfered. This option is incompatible with virtual quotas.
+
+# NoTruncate               yes
+
+
+
+# This option can accept three values :
+# 0 : disable SSL/TLS encryption layer (default).
+# 1 : accept both traditional and encrypted sessions.
+# 2 : refuse connections that don't use SSL/TLS security mechanisms,
+#     including anonymous sessions.
+# Do _not_ uncomment this blindly. Be sure that :
+# 1) Your server has been compiled with SSL/TLS support (--with-tls),
+# 2) A valid certificate is in place,
+# 3) Only compatible clients will log in.
+
+# TLS                      1
+
+
+
+# Listen only to IPv4 addresses in standalone mode (ie. disable IPv6)
+# By default, both IPv4 and IPv6 are enabled.
+
+# IPV4Only                 yes
+
+
+
+# Listen only to IPv6 addresses in standalone mode (ie. disable IPv4)
+# By default, both IPv4 and IPv6 are enabled.
+
+# IPV6Only                 yes
+
+# UTF-8 support for file names (RFC 2640)
+# Define charset of the server filesystem and optionnally the default charset
+# for remote clients if they don't use UTF-8.
+# Works only if pure-ftpd has been compiled with --with-rfc2640
+
+# FileSystemCharset	big5
+# ClientCharset		big5
+AllowOverwrite on
+AllowStoreRestart on

+ 45 - 0
conf/server.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Server port="8006" shutdown="SHUTDOWN">
+  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
+  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
+  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
+  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
+<!--
+  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="8081" rmiServerPortPlatform="8082" />
+-->
+  <!--GlobalNamingResources>
+    <Resource name="UserDatabase" auth="Container"
+              type="org.apache.catalina.UserDatabase"
+              description="User database that can be updated and saved"
+              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+              pathname="conf/tomcat-users.xml" />
+  </GlobalNamingResources-->
+
+  <Service name="Catalina">
+    <Connector port="8080"
+              protocol="org.apache.coyote.http11.Http11AprProtocol"
+              maxThreads="30000"
+              minSpareThreads="512"
+              maxSpareThreads="2048"
+              enableLookups="false"
+              redirectPort="8443"
+              acceptCount="35000"
+              debug="0"
+              connectionTimeout="40000"
+              disableUploadTimeout="true"
+	      useBodyEncodingForURI="true"
+              URIEncoding="UTF-8" />
+    <Engine name="Catalina" defaultHost="localhost">
+      <Realm className="org.apache.catalina.realm.LockOutRealm">
+        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+               resourceName="UserDatabase"/>
+      </Realm>
+       <Host name="localhost"  appBase="webapps"
+             unpackWARs="true" autoDeploy="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" />
+      </Host>
+    </Engine>
+  </Service>
+</Server>

+ 9 - 0
conf/typecho.conf

@@ -0,0 +1,9 @@
+if (-f $request_filename/index.html){
+    rewrite (.*) $1/index.html break;
+}
+if (-f $request_filename/index.php){
+    rewrite (.*) $1/index.php;
+}
+if (!-e $request_filename){
+    rewrite (.*) /index.php;
+}

+ 4 - 0
conf/wordpress.conf

@@ -0,0 +1,4 @@
+location / {
+	try_files $uri $uri/ /index.php?$args;
+	}
+rewrite /wp-admin$ $scheme://$host$uri/ permanent;

+ 41 - 0
functions/GraphicsMagick.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_GraphicsMagick()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/$GraphicsMagick_version/GraphicsMagick-$GraphicsMagick_version.tar.gz && Download_src
+
+tar xzf GraphicsMagick-$GraphicsMagick_version.tar.gz 
+cd GraphicsMagick-$GraphicsMagick_version
+./configure --enable-shared --prefix=/usr/local/graphicsmagick
+make && make install
+cd ../
+/bin/rm -rf GraphicsMagick-$GraphicsMagick_version
+
+if [ -e "$php_install_dir/bin/phpize" ];then
+	src_url=http://pecl.php.net/get/gmagick-$gmagick_version.tgz && Download_src
+	tar xzf gmagick-$gmagick_version.tgz 
+	cd gmagick-$gmagick_version
+	make clean
+	export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
+	$php_install_dir/bin/phpize
+	./configure --with-php-config=$php_install_dir/bin/php-config --with-gmagick=/usr/local/graphicsmagick
+	make && make install
+	cd ../
+	/bin/rm -rf gmagick-$gmagick_version
+
+	if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/gmagick.so" ];then
+		[ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini
+		sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "gmagick.so"@' $php_install_dir/etc/php.ini
+	        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+	else
+	        echo -e "\033[31mPHP Gmagick module install failed, Please contact the author! \033[0m"
+	fi
+fi
+cd ../
+}

+ 41 - 0
functions/ImageMagick.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_ImageMagick()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=http://downloads.sourceforge.net/project/imagemagick/old-sources/6.x/6.8/ImageMagick-$ImageMagick_version.tar.gz && Download_src
+
+tar xzf ImageMagick-$ImageMagick_version.tar.gz
+cd ImageMagick-$ImageMagick_version
+./configure --prefix=/usr/local/imagemagick
+make && make install
+cd ../
+/bin/rm -rf ImageMagick-$ImageMagick_version
+
+if [ -e "$php_install_dir/bin/phpize" ];then
+	src_url=http://pecl.php.net/get/imagick-$imagick_version.tgz && Download_src
+	tar xzf imagick-$imagick_version.tgz
+	cd imagick-$imagick_version
+	make clean
+	export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
+	$php_install_dir/bin/phpize
+	./configure --with-php-config=$php_install_dir/bin/php-config --with-imagick=/usr/local/imagemagick
+	make && make install
+	cd ../
+	/bin/rm -rf imagick-$imagick_version
+
+	if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/imagick.so" ];then
+		[ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini
+		sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "imagick.so"@' $php_install_dir/etc/php.ini
+	        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+	else
+	        echo -e "\033[31mPHP imagick module install failed, Please contact the author! \033[0m"
+	fi
+fi
+cd ../
+}

+ 86 - 0
functions/ZendGuardLoader.sh

@@ -0,0 +1,86 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_ZendGuardLoader()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
+PHP_version=${php_version%.*}
+
+[ ! -e "$php_install_dir/lib/php/extensions/" ] && mkdir $php_install_dir/lib/php/extensions/
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ] ;then
+        if [ "$PHP_version" == '5.6' ];then
+                src_url=http://mirrors.linuxeye.com/lnmp/src/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src
+                tar xzf zend-loader-php5.6-linux-x86_64.tar.gz 
+                /bin/cp zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+                /bin/rm -rf zend-loader-php5.6-linux-x86_64 
+        fi
+
+        if [ "$PHP_version" == '5.5' ];then
+                src_url=http://mirrors.linuxeye.com/lnmp/src/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src
+                tar xzf zend-loader-php5.5-linux-x86_64.tar.gz 
+                /bin/cp zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+                /bin/rm -rf zend-loader-php5.5-linux-x86_64 
+        fi
+
+	if [ "$PHP_version" == '5.4' ];then
+		src_url=http://mirrors.linuxeye.com/lnmp/src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src
+		tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
+		/bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+		/bin/rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64
+	fi
+
+	if [ "$PHP_version" == '5.3' ];then
+		src_url=http://mirrors.linuxeye.com/lnmp/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src
+		tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
+		/bin/cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+		/bin/rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64
+	fi
+else
+        if [ "$PHP_version" == '5.6' ];then
+                src_url=http://mirrors.linuxeye.com/lnmp/src/zend-loader-php5.6-linux-i386.tar.gz && Download_src
+                tar xzf zend-loader-php5.6-linux-i386.tar.gz 
+                /bin/cp zend-loader-php5.6-linux-i386/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+                /bin/rm -rf zend-loader-php5.6-linux-i386 
+        fi
+
+        if [ "$PHP_version" == '5.5' ];then
+                src_url=http://mirrors.linuxeye.com/lnmp/src/zend-loader-php5.5-linux-i386.tar.gz && Download_src
+                tar xzf zend-loader-php5.5-linux-i386.tar.gz
+                /bin/cp zend-loader-php5.5-linux-i386/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+                /bin/rm -rf zend-loader-php5.5-linux-x386
+        fi
+
+        if [ "$PHP_version" == '5.4' ];then
+		src_url=http://mirrors.linuxeye.com/lnmp/src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz && Download_src
+		tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz
+		/bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386/php-5.4.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+		/bin/rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386
+        fi
+
+        if [ "$PHP_version" == '5.3' ];then
+		src_url=http://mirrors.linuxeye.com/lnmp/src/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz && Download_src
+		tar xzf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
+		/bin/cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/
+		/bin/rm -rf ZendGuardLoader-php-5.3-linux-glibc23-i386
+        fi
+fi
+
+if [ -f "$php_install_dir/lib/php/extensions/ZendGuardLoader.so" ];then
+        cat >> $php_install_dir/etc/php.ini << EOF
+[Zend Guard Loader]
+zend_extension="/usr/local/php/lib/php/extensions/ZendGuardLoader.so"
+zend_loader.enable=1
+zend_loader.disable_licensing=0
+zend_loader.obfuscation_level_support=3
+EOF
+        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+else
+        echo -e "\033[31meZendGuardLoader module install failed, Please contact the author! \033[0m"
+fi
+cd ../
+}

+ 124 - 0
functions/apache-2.2.sh

@@ -0,0 +1,124 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_Apache-2-2()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://www.apache.org/dist/httpd/httpd-$apache_2_version.tar.gz && Download_src 
+
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+tar xzf httpd-$apache_2_version.tar.gz
+cd httpd-$apache_2_version
+[ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
+./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=prefork --disable-userdir
+make && make install
+if [ -d "$apache_install_dir/conf" ];then
+        echo -e "\033[32mApache install successfully! \033[0m"
+else
+	rm -rf $apache_install_dir
+        echo -e "\033[31mApache install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$apache_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $apache_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$apache_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+cd ..
+[ -d "$apache_install_dir/conf" ] && /bin/rm -rf httpd-$apache_2_version
+/bin/cp $apache_install_dir/bin/apachectl  /etc/init.d/httpd
+sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
+sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
+chmod +x /etc/init.d/httpd
+OS_CentOS='chkconfig --add httpd \n
+chkconfig httpd on'
+OS_Debian_Ubuntu='update-rc.d httpd defaults'
+OS_command
+
+sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
+sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
+if [ "$Nginx_version" == '3' ];then
+	sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
+	TMP_PORT=80
+        TMP_IP=$local_IP
+elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' ];then
+	sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:9090/' $apache_install_dir/conf/httpd.conf
+	sed -i 's@^Listen.*@Listen 127.0.0.1:9090@' $apache_install_dir/conf/httpd.conf
+	TMP_PORT=9090
+	TMP_IP=127.0.0.1
+fi
+sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
+sed -i 's@^#LoadModule rewrite_module@LoadModule rewrite_module@' $apache_install_dir/conf/httpd.conf
+sed -i 's@^#LoadModule\(.*\)mod_deflate.so@LoadModule\1mod_deflate.so@' $apache_install_dir/conf/httpd.conf
+sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
+sed -i "s@^DocumentRoot.*@DocumentRoot \"$home_dir/default\"@" $apache_install_dir/conf/httpd.conf
+sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$home_dir/default\">@" $apache_install_dir/conf/httpd.conf
+sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" $apache_install_dir/conf/httpd.conf
+
+#logrotate apache log
+cat > /etc/logrotate.d/apache << EOF
+$wwwlogs_dir/*apache.log {
+daily
+rotate 5
+missingok
+dateext
+compress
+notifempty
+sharedscripts
+postrotate
+[ -f $apache_install_dir/logs/httpd.pid ] && kill -USR1 \`cat $apache_install_dir/logs/httpd.pid\`
+endscript
+}
+EOF
+
+mkdir $apache_install_dir/conf/vhost
+cat >> $apache_install_dir/conf/vhost/0.conf << EOF
+NameVirtualHost *:$TMP_PORT
+<VirtualHost *:$TMP_PORT>
+    ServerAdmin admin@linuxeye.com
+    DocumentRoot "$home_dir/default"
+    ServerName $TMP_IP 
+    ErrorLog "$wwwlogs_dir/error_apache.log"
+    CustomLog "$wwwlogs_dir/access_apache.log" common
+<Directory "$home_dir/default">
+    SetOutputFilter DEFLATE
+    Options FollowSymLinks
+    AllowOverride All
+    Order allow,deny
+    Allow from all
+    DirectoryIndex index.html index.php
+</Directory>
+</VirtualHost>
+EOF
+
+cat >> $apache_install_dir/conf/httpd.conf <<EOF
+ServerTokens ProductOnly
+ServerSignature Off
+AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
+DeflateCompressionLevel 6
+SetOutputFilter DEFLATE
+Include conf/vhost/*.conf
+EOF
+
+if [ "$Nginx_version" != '3' ];then
+	mkdir mod_remoteip;cd mod_remoteip
+	src_url=https://raw.githubusercontent.com/ttkzw/mod_remoteip-httpd22/master/mod_remoteip.c && Download_src
+	$apache_install_dir/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
+	cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
+LoadModule remoteip_module modules/mod_remoteip.so
+RemoteIPHeader X-Forwarded-For
+`ifconfig | awk -F"[: ]+" '/inet addr/{print "RemoteIPInternalProxy " $4}'`
+EOF
+	sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
+	cd ..
+fi
+cd ..
+[ "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && sed -i "s@^web_install_dir.*@web_install_dir=$apache_install_dir@" options.conf
+service httpd start
+}

+ 134 - 0
functions/apache-2.4.sh

@@ -0,0 +1,134 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_Apache-2-4()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://downloads.sourceforge.net/project/pcre/pcre/$pcre_version/pcre-$pcre_version.tar.gz && Download_src
+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 
+src_url=http://www.apache.org/dist/httpd/httpd-$apache_4_version.tar.gz && Download_src 
+
+tar xzf pcre-$pcre_version.tar.gz
+cd pcre-$pcre_version
+./configure
+make && make install
+cd ../
+
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+tar xzf httpd-$apache_4_version.tar.gz
+tar xzf apr-$apr_version.tar.gz
+tar xzf apr-util-$apr_util_version.tar.gz
+cd httpd-$apache_4_version
+[ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
+/bin/cp -R ../apr-$apr_version ./srclib/apr
+/bin/cp -R ../apr-util-$apr_util_version ./srclib/apr-util
+./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=prefork --disable-userdir
+make && make install
+if [ -d "$apache_install_dir/conf" ];then
+        echo -e "\033[32mApache install successfully! \033[0m"
+else
+	rm -rf $apache_install_dir
+        echo -e "\033[31mApache install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$apache_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $apache_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$apache_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+cd ..
+[ -d "$apache_install_dir/conf" ] && /bin/rm -rf httpd-$apache_4_version
+/bin/cp $apache_install_dir/bin/apachectl  /etc/init.d/httpd
+sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
+sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
+chmod +x /etc/init.d/httpd
+OS_CentOS='chkconfig --add httpd \n
+chkconfig httpd on'
+OS_Debian_Ubuntu='update-rc.d httpd defaults'
+OS_command
+
+sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
+sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
+if [ "$Nginx_version" == '3' ];then
+	sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
+	TMP_PORT=80
+        TMP_IP=$local_IP
+elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' ];then
+	sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:9090/' $apache_install_dir/conf/httpd.conf
+	sed -i 's@^Listen.*@Listen 127.0.0.1:9090@' $apache_install_dir/conf/httpd.conf
+	TMP_PORT=9090
+	TMP_IP=127.0.0.1
+fi
+sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
+sed -i 's@^#LoadModule rewrite_module@LoadModule rewrite_module@' $apache_install_dir/conf/httpd.conf
+sed -i 's@^#LoadModule\(.*\)mod_deflate.so@LoadModule\1mod_deflate.so@' $apache_install_dir/conf/httpd.conf
+sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
+sed -i "s@^DocumentRoot.*@DocumentRoot \"$home_dir/default\"@" $apache_install_dir/conf/httpd.conf
+sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$home_dir/default\">@" $apache_install_dir/conf/httpd.conf
+sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" $apache_install_dir/conf/httpd.conf
+
+#logrotate apache log
+cat > /etc/logrotate.d/apache << EOF
+$wwwlogs_dir/*apache.log {
+daily
+rotate 5
+missingok
+dateext
+compress
+notifempty
+sharedscripts
+postrotate
+[ -f $apache_install_dir/logs/httpd.pid ] && kill -USR1 \`cat $apache_install_dir/logs/httpd.pid\`
+endscript
+}
+EOF
+
+mkdir $apache_install_dir/conf/vhost
+cat >> $apache_install_dir/conf/vhost/0.conf << EOF
+<VirtualHost *:$TMP_PORT>
+    ServerAdmin admin@linuxeye.com
+    DocumentRoot "$home_dir/default"
+    ServerName $TMP_IP 
+    ErrorLog "$wwwlogs_dir/error_apache.log"
+    CustomLog "$wwwlogs_dir/access_apache.log" common
+<Directory "$home_dir/default">
+    SetOutputFilter DEFLATE
+    Options FollowSymLinks
+    Require all granted
+    AllowOverride All
+    Order allow,deny
+    Allow from all
+    DirectoryIndex index.html index.php
+</Directory>
+</VirtualHost>
+EOF
+
+cat >> $apache_install_dir/conf/httpd.conf <<EOF
+ServerTokens ProductOnly
+ServerSignature Off
+AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
+DeflateCompressionLevel 6
+SetOutputFilter DEFLATE
+Include conf/vhost/*.conf
+EOF
+
+if [ "$Nginx_version" != '3' ];then
+	cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
+LoadModule remoteip_module modules/mod_remoteip.so
+RemoteIPHeader X-Forwarded-For
+`ifconfig | awk -F"[: ]+" '/inet addr/{print "RemoteIPInternalProxy " $4}'`
+EOF
+	sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
+	sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" $apache_install_dir/conf/httpd.conf
+fi
+cd ..
+[ "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && sed -i "s@^web_install_dir.*@web_install_dir=$apache_install_dir@" options.conf
+service httpd start
+}

+ 32 - 0
functions/apcu.sh

@@ -0,0 +1,32 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_APCU()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=http://pecl.php.net/get/apcu-$apcu_version.tgz && Download_src
+tar xzf apcu-$apcu_version.tgz
+cd apcu-$apcu_version
+make clean
+$php_install_dir/bin/phpize
+./configure --with-php-config=$php_install_dir/bin/php-config
+make && make install
+if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/apcu.so" ];then
+	cat >> $php_install_dir/etc/php.ini << EOF
+extension = apcu.so
+apc.enabled=1
+apc.shm_size=32M
+apc.ttl=7200
+apc.enable_cli=1
+EOF
+	[ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+	/bin/cp apc.php $home_dir/default
+else
+        echo -e "\033[31meAPCU module install failed, Please contact the author! \033[0m"
+fi
+cd ../../
+}

+ 26 - 0
functions/check_os.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+if [ -f /etc/redhat-release -o -n "`grep 'Aliyun Linux release6 15' /etc/issue`" ];then
+        OS=CentOS
+elif [ -n "`grep bian /etc/issue`" ];then
+        OS=Debian
+elif [ -n "`grep Ubuntu /etc/issue`" ];then
+        OS=Ubuntu
+else
+        echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+OS_command()
+{
+	if [ $OS == 'CentOS' ];then
+	        echo -e $OS_CentOS | bash
+	elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
+		echo -e $OS_Debian_Ubuntu | bash
+	else
+		echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m"
+		kill -9 $$
+	fi
+}

+ 12 - 0
functions/download.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Download_src()
+{
+	[ -s "${src_url##*/}" ] && echo "${src_url##*/} found" || wget -c --no-check-certificate $src_url
+        if [ ! -e "${src_url##*/}" ];then
+                echo -e "\033[31m${src_url##*/} download failed, Please contact the author! \033[0m"
+                kill -9 $$
+        fi
+}

+ 50 - 0
functions/eaccelerator-0.9.sh

@@ -0,0 +1,50 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_eAccelerator-0-9()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-0.9.6.1.tar.bz2 && Download_src
+tar jxf eaccelerator-0.9.6.1.tar.bz2
+cd eaccelerator-0.9.6.1
+make clean
+$php_install_dir/bin/phpize
+./configure --enable-eaccelerator=shared --with-php-config=$php_install_dir/bin/php-config
+make && make install
+
+if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so" ];then
+	mkdir /var/eaccelerator_cache;chown -R ${run_user}.$run_user /var/eaccelerator_cache
+	cat >> $php_install_dir/etc/php.ini << EOF
+[eaccelerator]
+zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so"
+eaccelerator.shm_size="64"
+eaccelerator.cache_dir="/var/eaccelerator_cache"
+eaccelerator.enable="1"
+eaccelerator.optimizer="1"
+eaccelerator.check_mtime="1"
+eaccelerator.debug="0"
+eaccelerator.filter=""
+eaccelerator.shm_max="0"
+eaccelerator.shm_ttl="0"
+eaccelerator.shm_prune_period="0"
+eaccelerator.shm_only="0"
+eaccelerator.compress="0"
+eaccelerator.compress_level="9"
+eaccelerator.keys = "disk_only"
+eaccelerator.sessions = "disk_only"
+eaccelerator.content = "disk_only"
+EOF
+	echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
+	sysctl -p
+        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+else
+        echo -e "\033[31meAccelerator module install failed, Please contact the author! \033[0m"
+fi
+cd ..
+/bin/rm -rf eaccelerator-0.9.6.1
+cd ..
+}

+ 50 - 0
functions/eaccelerator-1.0-dev.sh

@@ -0,0 +1,50 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_eAccelerator-1-0-dev()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src
+/bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
+tar xzf eaccelerator-eaccelerator-42067ac.tar.gz 
+cd eaccelerator-eaccelerator-42067ac 
+make clean
+$php_install_dir/bin/phpize
+./configure --enable-eaccelerator=shared --with-php-config=$php_install_dir/bin/php-config
+make && make install
+if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so" ];then
+        mkdir /var/eaccelerator_cache;chown -R ${run_user}.$run_user /var/eaccelerator_cache
+        cat >> $php_install_dir/etc/php.ini << EOF
+[eaccelerator]
+zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so"
+eaccelerator.shm_size="64"
+eaccelerator.cache_dir="/var/eaccelerator_cache"
+eaccelerator.enable="1"
+eaccelerator.optimizer="1"
+eaccelerator.check_mtime="1"
+eaccelerator.debug="0"
+eaccelerator.filter=""
+eaccelerator.shm_max="0"
+eaccelerator.shm_ttl="0"
+eaccelerator.shm_prune_period="0"
+eaccelerator.shm_only="0"
+eaccelerator.compress="0"
+eaccelerator.compress_level="9"
+eaccelerator.keys = "disk_only"
+eaccelerator.sessions = "disk_only"
+eaccelerator.content = "disk_only"
+EOF
+	echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
+	sysctl -p
+        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+else
+        echo -e "\033[31meAccelerator module install failed, Please contact the author! \033[0m"
+fi
+cd ..
+/bin/rm -rf eaccelerator-eaccelerator-42067ac
+cd ..
+}

+ 14 - 0
functions/get_ip_area.py

@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+#coding:utf-8
+try:
+    import sys,urllib2
+    apiurl = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=%s" % sys.argv[1]
+    content = urllib2.urlopen(apiurl).read()
+    content=eval(content)
+    ret = content['ret']
+    country = content['country']
+    if ret == 1:
+        #print country.decode('unicode_escape')
+        print country
+except:
+    print "Usage:%s IP" % sys.argv[0]

+ 22 - 0
functions/get_local_ip.py

@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+import socket
+def Get_local_ip():
+    """
+    Returns the actual ip of the local machine.
+    This code figures out what source address would be used if some traffic
+    were to be sent out to some well known address on the Internet. In this
+    case, a Google DNS server is used, but the specific address does not
+    matter much.  No traffic is actually sent.
+    """
+    try:
+        csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        csock.connect(('8.8.8.8', 80))
+        (addr, port) = csock.getsockname()
+        csock.close()
+        return addr
+    except socket.error:
+        return "127.0.0.1"
+
+if __name__ == "__main__":
+    local_IP = Get_local_ip() 
+    print local_IP

+ 21 - 0
functions/get_public_ip.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+import re,urllib2
+class Get_public_ip:
+    def getip(self):
+        try:
+            myip = self.visit("http://ipv4.icanhazip.com/")
+        except:
+            try:
+                myip = self.visit("http://www.whereismyip.com/")
+            except:
+                myip = "So sorry!!!"
+        return myip
+    def visit(self,url):
+        opener = urllib2.urlopen(url)
+        if url == opener.geturl():
+            str = opener.read()
+        return re.search('\d+\.\d+\.\d+\.\d+',str).group(0)
+
+if __name__ == "__main__":
+    getmyip = Get_public_ip()
+    print getmyip.getip()

+ 218 - 0
functions/hhvm_CentOS.sh

@@ -0,0 +1,218 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_hhvm_CentOS()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../options.conf
+
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+
+if [ -n "$(grep ' 7\.' /etc/redhat-release)" ];then
+	CentOS_RHL=7
+elif [ -n "$(grep ' 6\.' /etc/redhat-release)" ];then
+	CentOS_RHL=6
+fi
+
+if [ "$CentOS_RHL" == '7' ];then
+if [ -e /etc/yum.repos.d/epel.repo_bk ];then
+	/bin/mv /etc/yum.repos.d/epel.repo{_bk,}
+elif [ ! -e /etc/yum.repos.d/epel.repo ];then
+cat > /etc/yum.repos.d/epel.repo << EOF
+[epel]
+name=Extra Packages for Enterprise Linux 7 - \$basearch
+#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
+mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
+failovermethod=priority
+enabled=1
+gpgcheck=0
+EOF
+fi
+cat > /etc/yum.repos.d/hhvm.repo << EOF
+[hhvm]
+name=Copr repo for hhvm-repo owned by no1youknowz
+baseurl=https://copr-be.cloud.fedoraproject.org/results/no1youknowz/hhvm-repo/epel-7-\$basearch/
+skip_if_unavailable=True
+gpgcheck=0
+enabled=0
+EOF
+yum --enablerepo=hhvm -y install hhvm
+[ ! -e "/usr/bin/hhvm" -a "/usr/local/bin/hhvm" ] && ln -s /usr/local/bin/hhvm /usr/bin/hhvm
+fi
+
+if [ "$CentOS_RHL" == '6' ];then
+if [ -e /etc/yum.repos.d/epel.repo_bk ];then
+	/bin/mv /etc/yum.repos.d/epel.repo{_bk,}
+elif [ ! -e /etc/yum.repos.d/epel.repo ];then
+cat > /etc/yum.repos.d/epel.repo << EOF 
+[epel]
+name=Extra Packages for Enterprise Linux 6 - \$basearch
+#baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
+mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch
+failovermethod=priority
+enabled=1
+gpgcheck=0
+EOF
+fi
+yum -y install libmcrypt-devel glog-devel jemalloc-devel tbb-devel libdwarf-devel mysql-devel \
+libxml2-devel libicu-devel pcre-devel gd-devel boost-devel sqlite-devel pam-devel \
+bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel \
+libevent-devel libcurl-devel libmemcached-devel lcms2 inotify-tools
+
+public_IP=`../functions/get_public_ip.py`
+if [ "`../functions/get_ip_area.py $public_IP`" == '\u4e2d\u56fd' ];then
+        FLAG_IP=CN
+fi
+
+echo $public_IP $FLAG_IP
+
+[ "$FLAG_IP"x == "CN"x ] && REMI_ADDR=http://mirrors.swu.edu.cn || REMI_ADDR=http://mirrors.mediatemple.net
+
+cat > /etc/yum.repos.d/remi.repo << EOF
+[remi]
+name=Les RPM de remi pour Enterprise Linux 6 - \$basearch
+baseurl=$REMI_ADDR/remi/enterprise/6/remi/\$basearch/
+#mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
+enabled=0
+gpgcheck=0
+EOF
+
+yum -y remove libwebp
+src_url=http://mirrors.linuxeye.com/lnmp/src/libwebp-0.3.1-2.el6.remi.x86_64.rpm && Download_src
+src_url=http://mirrors.linuxeye.com/lnmp/src/hhvm-3.5.0-4.el6.x86_64.rpm && Download_src
+rpm -ivh libwebp-0.3.1-2.el6.remi.x86_64.rpm
+yum --enablerepo=remi --disablerepo=epel -y install mysql mysql-devel mysql-libs
+
+yum -y remove boost-system boost-filesystem
+
+cat > /etc/yum.repos.d/gleez.repo << EOF
+[gleez]
+name=Gleez repo
+baseurl=http://yum.gleez.com/6/\$basearch/
+enabled=0
+gpgcheck=0
+EOF
+ping yum.gleez.com -c 4 >/dev/null 2>&1
+yum --enablerepo=gleez --disablerepo=epel -y install -R 2 ./hhvm-3.5.0-4.el6.x86_64.rpm
+fi
+
+userdel -r nginx;userdel -r saslauth
+rm -rf /var/log/hhvm
+mkdir /var/log/hhvm
+chown -R ${run_user}.$run_user /var/log/hhvm
+cat > /etc/hhvm/config.hdf << EOF
+ResourceLimit {
+  CoreFileSize = 0          # in bytes
+  MaxSocket = 10000         # must be not 0, otherwise HHVM will not start
+  SocketDefaultTimeout = 5  # in seconds
+  MaxRSS = 0
+  MaxRSSPollingCycle = 0    # in seconds, how often to check max memory
+  DropCacheCycle = 0        # in seconds, how often to drop disk cache
+}
+
+Log {
+  Level = Info
+  AlwaysLogUnhandledExceptions = true
+  RuntimeErrorReportingLevel = 8191
+  UseLogFile = true
+  UseSyslog = false
+  File = /var/log/hhvm/error.log
+  Access {
+    * {
+      File = /var/log/hhvm/access.log
+      Format = %h %l %u % t \"%r\" %>s %b
+    }
+  }
+}
+
+MySQL {
+  ReadOnly = false
+  ConnectTimeout = 1000      # in ms
+  ReadTimeout = 1000         # in ms
+  SlowQueryThreshold = 1000  # in ms, log slow queries as errors
+  KillOnTimeout = false
+}
+
+Mail {
+  SendmailPath = /usr/sbin/sendmail -t -i
+  ForceExtraParameters =
+}
+EOF
+
+cat > /etc/hhvm/server.ini << EOF
+; php options
+pid = /var/log/hhvm/pid
+
+; hhvm specific
+;hhvm.server.port = 9001
+hhvm.server.file_socket = /var/log/hhvm/sock
+hhvm.server.type = fastcgi
+hhvm.server.default_document = index.php
+hhvm.log.use_log_file = true
+hhvm.log.file = /var/log/hhvm/error.log
+hhvm.repo.central.path = /var/log/hhvm/hhvm.hhbc
+EOF
+
+cat > /etc/hhvm/php.ini << EOF
+hhvm.mysql.socket = /tmp/mysql.sock
+expose_php = 0
+memory_limit = 400000000
+post_max_size = 50000000
+EOF
+
+if [ "$CentOS_RHL" == '7' ];then
+cat > /etc/systemd/system/hhvm.service << EOF
+[Unit]
+Description=HHVM HipHop Virtual Machine (FCGI)
+
+[Service]
+ExecStartPre=/usr/bin/rm -rf /var/log/hhvm ; /usr/bin/mkdir /var/log/hhvm ; /usr/bin/chown ${run_user}.$run_user /var/log/hhvm 
+ExecStart=/usr/bin/hhvm --mode server --user $run_user --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+#systemctl enable hhvm
+#systemctl start hhvm
+elif [ "$CentOS_RHL" == '6' ];then
+/bin/cp ../init/hhvm-init-CentOS6 /etc/init.d/hhvm
+sed -i "s@^USER=www@USER=$run_user@" /etc/init.d/hhvm
+chmod +x /etc/init.d/hhvm
+#chkconfig hhvm on
+#service hhvm start
+fi
+if [ -e "/usr/bin/hhvm" -a ! -e "$php_install_dir" ];then
+	sed -i 's@/dev/shm/php-cgi.sock@/var/log/hhvm/sock@' $web_install_dir/conf/nginx.conf 
+	[ -z "`grep 'fastcgi_param SCRIPT_FILENAME' $web_install_dir/conf/nginx.conf`" ] && sed -i "s@fastcgi_index index.php;@&\n\t\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;@" $web_install_dir/conf/nginx.conf 
+	sed -i 's@include fastcgi.conf;@include fastcgi_params;@' $web_install_dir/conf/nginx.conf 
+	service nginx reload
+fi
+
+rm -rf /etc/ld.so.conf.d/*_64.conf
+ldconfig
+# Supervisor
+yum -y install python-setuptools
+ping pypi.python.org -c 4 >/dev/null 2>&1
+easy_install supervisor
+echo_supervisord_conf > /etc/supervisord.conf
+sed -i 's@pidfile=/tmp/supervisord.pid@pidfile=/var/run/supervisord.pid@' /etc/supervisord.conf
+[ -z "`grep 'program:hhvm' /etc/supervisord.conf`" ] && cat >> /etc/supervisord.conf << EOF
+[program:hhvm]
+command=/usr/bin/hhvm --mode server --user $run_user --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
+numprocs=1 ; number of processes copies to start (def 1)
+directory=/tmp ; directory to cwd to before exec (def no cwd)
+autostart=true ; start at supervisord start (default: true)
+autorestart=unexpected ; whether/when to restart (default: unexpected)
+stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
+EOF
+src_url=https://github.com/Supervisor/initscripts/raw/master/redhat-init-mingalevme && Download_src
+/bin/mv redhat-init-mingalevme /etc/init.d/supervisord
+chmod +x /etc/init.d/supervisord
+chkconfig supervisord on
+service supervisord start
+cd ..
+}

+ 50 - 0
functions/ioncube.sh

@@ -0,0 +1,50 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_ionCube()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
+PHP_version=${php_version%.*}
+
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ] ;then
+	src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && Download_src
+	tar xzf ioncube_loaders_lin_x86-64.tar.gz
+else
+	src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && Download_src
+	tar xzf ioncube_loaders_lin_x86.tar.gz
+fi
+
+[ ! -e "$php_install_dir/lib/php/extensions/" ] && mkdir $php_install_dir/lib/php/extensions/
+if [ "$PHP_version" == '5.6' ];then
+        /bin/cp ioncube/ioncube_loader_lin_5.6.so $php_install_dir/lib/php/extensions/
+	zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.6.so"
+elif [ "$PHP_version" == '5.5' ];then
+        /bin/cp ioncube/ioncube_loader_lin_5.5.so $php_install_dir/lib/php/extensions/
+	zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.5.so"
+elif [ "$PHP_version" == '5.4' ];then
+        /bin/cp ioncube/ioncube_loader_lin_5.4.so $php_install_dir/lib/php/extensions/
+	zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.4.so"
+elif [ "$PHP_version" == '5.3' ];then
+        /bin/cp ioncube/ioncube_loader_lin_5.3.so $php_install_dir/lib/php/extensions/
+	zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.3.so"
+else
+	exit 1
+fi
+
+/bin/rm -rf ioncube
+if [ -n "`grep '^\[opcache\]' $php_install_dir/etc/php.ini`" -a -z "`grep '^\[ionCube Loader\]' $php_install_dir/etc/php.ini`" ];then
+	sed -i "s@^\[opcache\]@[ionCube Loader]\nzend_extension=\"$zend_extension\"\n[opcache]@" $php_install_dir/etc/php.ini
+elif [ -z "`grep '^\[ionCube Loader\]' $php_install_dir/etc/php.ini`" ];then
+	cat >> $php_install_dir/etc/php.ini << EOF
+[ionCube Loader]
+zend_extension="$zend_extension"
+EOF
+fi
+[ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+cd ../
+}

+ 46 - 0
functions/jdk-1.6.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+Install-JDK-1-6(){
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then
+	SYS_BIG_FLAG=x64
+else
+	SYS_BIG_FLAG=i586
+fi
+
+JDK_VERSION="jdk-`echo $jdk_6_version | awk -F. '{print $2}'`u`echo $jdk_6_version | awk -F. '{print $3}'`"
+JAVA_dir=/usr/java
+JDK_NAME="jdk1.`echo $jdk_6_version | awk -F. '{print $2}'`.0_`echo $jdk_6_version | awk -F. '{print $3}'`"
+JDK_PATH=$JAVA_dir/$JDK_NAME
+src_url=http://mirrors.linuxeye.com/jdk/${JDK_VERSION}-linux-$SYS_BIG_FLAG.bin && Download_src
+
+chmod + ${JDK_VERSION}-linux-$SYS_BIG_FLAG.bin
+
+OS_CentOS='[ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`'
+OS_command
+
+./${JDK_VERSION}-linux-$SYS_BIG_FLAG.bin
+
+if [ -d "$JDK_NAME" ];then
+        rm -rf $JAVA_dir; mkdir -p $JAVA_dir
+        mv $JDK_NAME $JAVA_dir
+        [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
+        [ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile
+        [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile
+        [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
+        . /etc/profile
+        echo -e "\033[32m$JDK_VERSION install successfully! \033[0m"
+fi
+}

+ 44 - 0
functions/jdk-1.7.sh

@@ -0,0 +1,44 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+Install-JDK-1-7(){
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then
+	SYS_BIG_FLAG=x64
+else
+	SYS_BIG_FLAG=i586
+fi
+
+JDK_VERSION="jdk-`echo $jdk_7_version | awk -F. '{print $2}'`u`echo $jdk_7_version | awk -F. '{print $3}'`"
+JAVA_dir=/usr/java
+JDK_NAME="jdk1.`echo $jdk_7_version | awk -F. '{print $2}'`.0_`echo $jdk_7_version | awk -F. '{print $3}'`"
+JDK_PATH=$JAVA_dir/$JDK_NAME
+src_url=http://mirrors.linuxeye.com/jdk/${JDK_VERSION}-linux-$SYS_BIG_FLAG.tar.gz && Download_src
+
+OS_CentOS='[ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`'
+OS_command
+
+tar xzf ${JDK_VERSION}-linux-$SYS_BIG_FLAG.tar.gz
+
+if [ -d "$JDK_NAME" ];then
+	rm -rf $JAVA_dir; mkdir -p $JAVA_dir
+	mv $JDK_NAME $JAVA_dir 
+        [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
+        [ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile
+	[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile
+	[ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
+        . /etc/profile
+        echo -e "\033[32m$JDK_VERSION install successfully! \033[0m"
+fi
+}

+ 44 - 0
functions/jdk-1.8.sh

@@ -0,0 +1,44 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+Install-JDK-1-8(){
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then
+	SYS_BIG_FLAG=x64
+else
+	SYS_BIG_FLAG=i586
+fi
+
+JDK_VERSION="jdk-`echo $jdk_8_version | awk -F. '{print $2}'`u`echo $jdk_8_version | awk -F. '{print $3}'`"
+JAVA_dir=/usr/java
+JDK_NAME="jdk1.`echo $jdk_8_version | awk -F. '{print $2}'`.0_`echo $jdk_8_version | awk -F. '{print $3}'`"
+JDK_PATH=$JAVA_dir/$JDK_NAME
+src_url=http://mirrors.linuxeye.com/jdk/${JDK_VERSION}-linux-$SYS_BIG_FLAG.tar.gz && Download_src
+
+OS_CentOS='[ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`'
+OS_command
+
+tar xzf ${JDK_VERSION}-linux-$SYS_BIG_FLAG.tar.gz
+
+if [ -d "$JDK_NAME" ];then
+	rm -rf $JAVA_dir; mkdir -p $JAVA_dir
+	mv $JDK_NAME $JAVA_dir 
+        [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
+        [ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile
+	[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile
+	[ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
+        . /etc/profile
+        echo -e "\033[32m$JDK_VERSION install successfully! \033[0m"
+fi
+}

+ 26 - 0
functions/jemalloc.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_jemalloc()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+
+src_url=http://www.canonware.com/download/jemalloc/jemalloc-$jemalloc_version.tar.bz2 && Download_src
+
+tar xjf jemalloc-$jemalloc_version.tar.bz2
+cd jemalloc-$jemalloc_version
+./configure
+make && make install
+if [ -f "/usr/local/lib/libjemalloc.so" ];then
+        echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+        ldconfig
+else
+        echo -e "\033[31mjemalloc install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+cd ..
+/bin/rm -rf jemalloc-$jemalloc_version
+cd ..
+}

+ 195 - 0
functions/mariadb-10.0.sh

@@ -0,0 +1,195 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_MariaDB-10-0()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+public_IP=`../functions/get_public_ip.py`
+if [ "`../functions/get_ip_area.py $public_IP`" == '\u4e2d\u56fd' ];then
+	FLAG_IP=CN
+fi
+
+echo $public_IP $FLAG_IP
+
+[ "$FLAG_IP"x == "CN"x ] && DOWN_ADDR=http://mirrors.aliyun.com/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
+[ -d "/lib64" ] && { SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; } || { SYS_BIT_a=x86;SYS_BIT_b=i686; }
+LIBC_VERSION=`getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}'`
+LIBC_YN=`echo "$LIBC_VERSION < 2.14" | bc`
+[ $LIBC_YN == '1' ] && GLIBC_FLAG=linux || GLIBC_FLAG=linux-glibc_214 
+
+src_url=$DOWN_ADDR/mariadb-${mariadb_10_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a/mariadb-${mariadb_10_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz && Download_src
+
+useradd -M -s /sbin/nologin mysql
+mkdir -p $mariadb_data_dir;chown mysql.mysql -R $mariadb_data_dir
+tar zxf mariadb-${mariadb_10_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz 
+[ ! -d "$mariadb_install_dir" ] && mkdir -p $mariadb_install_dir
+mv mariadb-${mariadb_10_version}-linux-${SYS_BIT_b}/* $mariadb_install_dir 
+if [ "$je_tc_malloc" == '1' ];then
+	sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mariadb_install_dir/bin/mysqld_safe
+elif [ "$je_tc_malloc" == '2' ];then
+	sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mariadb_install_dir/bin/mysqld_safe
+fi
+
+if [ -d "$mariadb_install_dir/bin" ];then
+        echo -e "\033[32mMariaDB install successfully! \033[0m"
+else
+	rm -rf $mariadb_install_dir
+        echo -e "\033[31mMariaDB install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+/bin/cp $mariadb_install_dir/support-files/mysql.server /etc/init.d/mysqld
+sed -i "s@^basedir=.*@basedir=$mariadb_install_dir@" /etc/init.d/mysqld
+sed -i "s@^datadir=.*@datadir=$mariadb_data_dir@" /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+
+# my.cf
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $mariadb_install_dir
+datadir = $mariadb_data_dir
+pid-file = $mariadb_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $mariadb_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $mariadb_data_dir/mysql-slow.log
+
+performance_schema = 0
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Memtatol -gt 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$mariadb_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mariadb_install_dir --datadir=$mariadb_data_dir
+
+chown mysql.mysql -R $mariadb_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$mariadb_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $mariadb_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$mariadb_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$mariadb_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$mariadb_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+sed -i "s@^db_install_dir.*@db_install_dir=$mariadb_install_dir@" options.conf
+sed -i "s@^db_data_dir.*@db_data_dir=$mariadb_data_dir@" options.conf
+service mysqld stop
+}

+ 195 - 0
functions/mariadb-5.5.sh

@@ -0,0 +1,195 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_MariaDB-5-5()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+public_IP=`../functions/get_public_ip.py`
+if [ "`../functions/get_ip_area.py $public_IP`" == '\u4e2d\u56fd' ];then
+	FLAG_IP=CN
+fi
+
+echo $public_IP $FLAG_IP
+
+[ "$FLAG_IP"x == "CN"x ] && DOWN_ADDR=http://mirrors.aliyun.com/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
+[ -d "/lib64" ] && { SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; } || { SYS_BIT_a=x86;SYS_BIT_b=i686; }
+LIBC_VERSION=`getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}'`
+LIBC_YN=`echo "$LIBC_VERSION < 2.14" | bc`
+[ $LIBC_YN == '1' ] && GLIBC_FLAG=linux || GLIBC_FLAG=linux-glibc_214 
+
+src_url=$DOWN_ADDR/mariadb-${mariadb_5_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a/mariadb-${mariadb_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz && Download_src
+
+useradd -M -s /sbin/nologin mysql
+mkdir -p $mariadb_data_dir;chown mysql.mysql -R $mariadb_data_dir
+tar zxf mariadb-${mariadb_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz 
+[ ! -d "$mariadb_install_dir" ] && mkdir -p $mariadb_install_dir
+mv mariadb-${mariadb_5_version}-linux-${SYS_BIT_b}/* $mariadb_install_dir 
+if [ "$je_tc_malloc" == '1' ];then
+	sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mariadb_install_dir/bin/mysqld_safe
+elif [ "$je_tc_malloc" == '2' ];then
+	sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mariadb_install_dir/bin/mysqld_safe
+fi
+
+if [ -d "$mariadb_install_dir/bin" ];then
+        echo -e "\033[32mMariaDB install successfully! \033[0m"
+else
+	rm -rf $mariadb_install_dir
+        echo -e "\033[31mMariaDB install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+/bin/cp $mariadb_install_dir/support-files/mysql.server /etc/init.d/mysqld
+sed -i "s@^basedir=.*@basedir=$mariadb_install_dir@" /etc/init.d/mysqld
+sed -i "s@^datadir=.*@datadir=$mariadb_data_dir@" /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+
+# my.cf
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $mariadb_install_dir
+datadir = $mariadb_data_dir
+pid-file = $mariadb_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $mariadb_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $mariadb_data_dir/mysql-slow.log
+
+performance_schema = 0
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Memtatol -gt 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$mariadb_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mariadb_install_dir --datadir=$mariadb_data_dir
+
+chown mysql.mysql -R $mariadb_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$mariadb_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $mariadb_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$mariadb_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$mariadb_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$mariadb_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
+$mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+sed -i "s@^db_install_dir.*@db_install_dir=$mariadb_install_dir@" options.conf
+sed -i "s@^db_data_dir.*@db_data_dir=$mariadb_data_dir@" options.conf
+service mysqld stop
+}

+ 89 - 0
functions/memcached.sh

@@ -0,0 +1,89 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_memcached()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://www.memcached.org/files/memcached-$memcached_version.tar.gz && Download_src
+
+# memcached server
+useradd -M -s /sbin/nologin memcached
+tar xzf memcached-$memcached_version.tar.gz
+cd memcached-$memcached_version
+[ ! -d "$memcached_install_dir" ] && mkdir -p $memcached_install_dir
+./configure --prefix=$memcached_install_dir
+make && make install
+cd ../
+/bin/rm -rf memcached-$memcached_version
+if [ -d "$memcached_install_dir/bin" ];then
+        echo -e "\033[32mmemcached install successfully! \033[0m"
+	ln -s $memcached_install_dir/bin/memcached /usr/bin/memcached
+	OS_CentOS='/bin/cp ../init/Memcached-init-CentOS /etc/init.d/memcached \n
+chkconfig --add memcached \n
+chkconfig memcached on'
+	OS_Debian_Ubuntu='/bin/cp ../init/Memcached-init-Ubuntu /etc/init.d/memcached \n
+update-rc.d memcached defaults'
+	OS_command
+	sed -i "s@/usr/local/memcached@$memcached_install_dir@g" /etc/init.d/memcached
+	service memcached start
+else
+	rm -rf $memcached_install_dir
+        echo -e "\033[31mmemcached install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+if [ -e "$php_install_dir/bin/phpize" ];then
+	src_url=https://launchpad.net/libmemcached/1.0/$libmemcached_version/+download/libmemcached-$libmemcached_version.tar.gz && Download_src
+	src_url=http://pecl.php.net/get/memcached-$memcached_pecl_version.tgz && Download_src
+	src_url=http://pecl.php.net/get/memcache-$memcache_pecl_version.tgz && Download_src
+	# php memcache extension
+	tar xzf memcache-$memcache_pecl_version.tgz 
+	cd memcache-$memcache_pecl_version 
+	make clean
+	$php_install_dir/bin/phpize
+	./configure --with-php-config=$php_install_dir/bin/php-config
+	make && make install
+	cd ..
+	/bin/rm -rf memcache-$memcache_pecl_version
+	if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/memcache.so" ];then
+		[ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini
+	        sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcache.so"@' $php_install_dir/etc/php.ini
+	        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+	else
+	        echo -e "\033[31mPHP memcache module install failed, Please contact the author! \033[0m"
+	fi
+
+	# php memcached extension
+	tar xzf libmemcached-$libmemcached_version.tar.gz
+	cd libmemcached-$libmemcached_version
+	OS_CentOS='yum -y install cyrus-sasl-devel'
+	OS_Debian_Ubuntu='sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure'
+	OS_command
+	./configure --with-memcached=$memcached_install_dir
+	make && make install
+	cd ..
+	/bin/rm -rf libmemcached-$libmemcached_version
+
+	tar xzf memcached-$memcached_pecl_version.tgz
+	cd memcached-$memcached_pecl_version
+	make clean
+	$php_install_dir/bin/phpize
+	./configure --with-php-config=$php_install_dir/bin/php-config
+	make && make install
+	cd ../
+	/bin/rm -rf memcached-$memcached_pecl_version
+	if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/memcached.so" ];then
+		[ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions/ | grep zts`\"@" $php_install_dir/etc/php.ini
+	        sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcached.so"\nmemcached.use_sasl = 1@' $php_install_dir/etc/php.ini
+	        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+	else
+	        echo -e "\033[31mPHP memcached module install failed, Please contact the author! \033[0m"
+	fi
+fi
+cd ../
+}

+ 201 - 0
functions/mysql-5.5.sh

@@ -0,0 +1,201 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_MySQL-5-5()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-$mysql_5_version.tar.gz && Download_src
+
+useradd -M -s /sbin/nologin mysql
+mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
+tar zxf mysql-$mysql_5_version.tar.gz
+cd mysql-$mysql_5_version
+if [ "$je_tc_malloc" == '1' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
+elif [ "$je_tc_malloc" == '2' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
+fi
+make clean
+[ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir 
+cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
+-DMYSQL_DATADIR=$mysql_data_dir \
+-DSYSCONFDIR=/etc \
+-DWITH_INNOBASE_STORAGE_ENGINE=1 \
+-DWITH_PARTITION_STORAGE_ENGINE=1 \
+-DWITH_FEDERATED_STORAGE_ENGINE=1 \
+-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+-DWITH_MYISAM_STORAGE_ENGINE=1 \
+-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
+-DWITH_READLINE=1 \
+-DENABLED_LOCAL_INFILE=1 \
+-DENABLE_DTRACE=0 \
+-DDEFAULT_CHARSET=utf8 \
+-DDEFAULT_COLLATION=utf8_general_ci \
+-DWITH_EMBEDDED_SERVER=1 \
+$EXE_LINKER
+make -j `grep processor /proc/cpuinfo | wc -l` 
+make install
+
+if [ -d "$mysql_install_dir/bin" ];then
+        echo -e "\033[32mMySQL install successfully! \033[0m"
+else
+	rm -rf $mysql_install_dir
+        echo -e "\033[31mMySQL install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+/bin/cp support-files/mysql.server /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+[ -d "$mysql_install_dir" ] && /bin/rm -rf mysql-$mysql_5_version
+cd ..
+
+# my.cf
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $mysql_install_dir
+datadir = $mysql_data_dir
+pid-file = $mysql_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $mysql_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $mysql_data_dir/mysql-slow.log
+
+performance_schema = 0
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Memtatol -gt 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+
+chown mysql.mysql -R $mysql_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$mysql_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $mysql_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$mysql_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+sed -i "s@^db_install_dir.*@db_install_dir=$mysql_install_dir@" options.conf
+sed -i "s@^db_data_dir.*@db_data_dir=$mysql_data_dir@" options.conf
+service mysqld stop
+}

+ 200 - 0
functions/mysql-5.6.sh

@@ -0,0 +1,200 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_MySQL-5-6()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-$mysql_6_version.tar.gz && Download_src
+
+useradd -M -s /sbin/nologin mysql
+mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
+tar zxf mysql-$mysql_6_version.tar.gz
+cd mysql-$mysql_6_version
+if [ "$je_tc_malloc" == '1' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
+elif [ "$je_tc_malloc" == '2' ];then
+	EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
+fi
+make clean
+[ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir 
+cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
+-DMYSQL_DATADIR=$mysql_data_dir \
+-DSYSCONFDIR=/etc \
+-DWITH_INNOBASE_STORAGE_ENGINE=1 \
+-DWITH_PARTITION_STORAGE_ENGINE=1 \
+-DWITH_FEDERATED_STORAGE_ENGINE=1 \
+-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+-DWITH_MYISAM_STORAGE_ENGINE=1 \
+-DENABLED_LOCAL_INFILE=1 \
+-DENABLE_DTRACE=0 \
+-DDEFAULT_CHARSET=utf8 \
+-DDEFAULT_COLLATION=utf8_general_ci \
+-DWITH_EMBEDDED_SERVER=1 \
+$EXE_LINKER
+make -j `grep processor /proc/cpuinfo | wc -l` 
+make install
+
+if [ -d "$mysql_install_dir/bin" ];then
+        echo -e "\033[32mMySQL install successfully! \033[0m"
+else
+	rm -rf $mysql_install_dir
+        echo -e "\033[31mMySQL install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+/bin/cp support-files/mysql.server /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+[ -d "$mysql_install_dir" ] && /bin/rm -rf mysql-$mysql_6_version
+cd ..
+
+# my.cf
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $mysql_install_dir 
+datadir = $mysql_data_dir
+pid-file = $mysql_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $mysql_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $mysql_data_dir/mysql-slow.log
+
+performance_schema = 0
+explicit_defaults_for_timestamp
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Memtatol -gt 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+
+chown mysql.mysql -R $mysql_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$mysql_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $mysql_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$mysql_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+sed -i "s@^db_install_dir.*@db_install_dir=$mysql_install_dir@" options.conf
+sed -i "s@^db_data_dir.*@db_data_dir=$mysql_data_dir@" options.conf
+service mysqld stop
+}

+ 112 - 0
functions/nginx.sh

@@ -0,0 +1,112 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_Nginx()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh 
+. ../options.conf
+
+src_url=http://downloads.sourceforge.net/project/pcre/pcre/$pcre_version/pcre-$pcre_version.tar.gz && Download_src
+src_url=http://nginx.org/download/nginx-$nginx_version.tar.gz && Download_src
+
+tar xzf pcre-$pcre_version.tar.gz
+cd pcre-$pcre_version
+./configure
+make && make install
+cd ../
+
+tar xzf nginx-$nginx_version.tar.gz
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+cd nginx-$nginx_version
+
+# Modify Nginx version
+#sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "1.2"@' src/core/nginx.h
+#sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER          "Linuxeye/" NGINX_VERSION@' src/core/nginx.h
+#sed -i 's@Server: nginx@Server: linuxeye@' src/http/ngx_http_header_filter_module.c
+
+# close debug
+sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
+
+if [ "$je_tc_malloc" == '1' ];then
+	malloc_module="--with-ld-opt='-ljemalloc'"
+elif [ "$je_tc_malloc" == '2' ];then
+	malloc_module='--with-google_perftools_module'
+	mkdir /tmp/tcmalloc
+	chown -R ${run_user}.$run_user /tmp/tcmalloc
+fi
+
+[ ! -d "$nginx_install_dir" ] && mkdir -p $nginx_install_dir
+./configure --prefix=$nginx_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module $malloc_module
+make && make install
+if [ -d "$nginx_install_dir/conf" ];then
+        echo -e "\033[32mNginx install successfully! \033[0m"
+else
+	rm -rf $nginx_install_dir
+        echo -e "\033[31mNginx install failed, Please Contact the author! \033[0m"
+        kill -9 $$
+fi
+
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$nginx_install_dir/sbin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $nginx_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+cd ../../
+OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n
+chkconfig --add nginx \n
+chkconfig nginx on'
+OS_Debian_Ubuntu='/bin/cp init/Nginx-init-Ubuntu /etc/init.d/nginx \n
+update-rc.d nginx defaults'
+OS_command
+sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx
+
+mv $nginx_install_dir/conf/nginx.conf{,_bk}
+if [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+	/bin/cp conf/nginx_apache.conf $nginx_install_dir/conf/nginx.conf
+else
+	/bin/cp conf/nginx.conf $nginx_install_dir/conf/nginx.conf
+fi
+sed -i "s@/home/wwwroot/default@$home_dir/default@" $nginx_install_dir/conf/nginx.conf
+sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf
+sed -i "s@^user www www@user $run_user $run_user@" $nginx_install_dir/conf/nginx.conf
+[ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $nginx_install_dir/conf/nginx.conf 
+
+# worker_cpu_affinity
+CPU_num=`cat /proc/cpuinfo | grep processor | wc -l`
+if [ $CPU_num == 2 ];then
+        sed -i 's@^worker_processes.*@worker_processes 2;\nworker_cpu_affinity 10 01;@' $nginx_install_dir/conf/nginx.conf
+elif [ $CPU_num == 3 ];then
+        sed -i 's@^worker_processes.*@worker_processes 3;\nworker_cpu_affinity 100 010 001;@' $nginx_install_dir/conf/nginx.conf
+elif [ $CPU_num == 4 ];then
+        sed -i 's@^worker_processes.*@worker_processes 4;\nworker_cpu_affinity 1000 0100 0010 0001;@' $nginx_install_dir/conf/nginx.conf
+elif [ $CPU_num == 6 ];then
+        sed -i 's@^worker_processes.*@worker_processes 6;\nworker_cpu_affinity 100000 010000 001000 000100 000010 000001;@' $nginx_install_dir/conf/nginx.conf
+elif [ $CPU_num == 8 ];then
+        sed -i 's@^worker_processes.*@worker_processes 8;\nworker_cpu_affinity 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001;@' $nginx_install_dir/conf/nginx.conf
+else
+        echo Google worker_cpu_affinity
+fi
+
+# logrotate nginx log
+cat > /etc/logrotate.d/nginx << EOF
+$wwwlogs_dir/*nginx.log {
+daily
+rotate 5
+missingok
+dateext
+compress
+notifempty
+sharedscripts
+postrotate
+    [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\`
+endscript
+}
+EOF
+
+sed -i "s@^web_install_dir.*@web_install_dir=$nginx_install_dir@" options.conf
+ldconfig
+service nginx start
+}

+ 204 - 0
functions/percona-5.5.sh

@@ -0,0 +1,204 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_Percona-5-5()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/tarball/percona-server-$percona_5_version.tar.gz && Download_src
+
+useradd -M -s /sbin/nologin mysql
+mkdir -p $percona_data_dir;chown mysql.mysql -R $percona_data_dir
+tar zxf percona-server-$percona_5_version.tar.gz 
+cd percona-server-$percona_5_version 
+if [ "$je_tc_malloc" == '1' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
+elif [ "$je_tc_malloc" == '2' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
+fi
+make clean
+[ ! -d "$percona_install_dir" ] && mkdir -p $percona_install_dir
+cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \
+-DMYSQL_DATADIR=$percona_data_dir \
+-DSYSCONFDIR=/etc \
+-DWITH_INNOBASE_STORAGE_ENGINE=1 \
+-DWITH_PARTITION_STORAGE_ENGINE=1 \
+-DWITH_FEDERATED_STORAGE_ENGINE=1 \
+-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+-DWITH_MYISAM_STORAGE_ENGINE=1 \
+-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
+-DWITH_READLINE=1 \
+-DENABLE_DTRACE=0 \
+-DENABLED_LOCAL_INFILE=1 \
+-DDEFAULT_CHARSET=utf8 \
+-DDEFAULT_COLLATION=utf8_general_ci \
+$EXE_LINKER
+make -j `grep processor /proc/cpuinfo | wc -l` 
+make install
+
+cd $percona_install_dir/lib/
+ln -s libperconaserverclient.so libmysqlclient.so
+cd -
+
+if [ -d "$percona_install_dir/bin" ];then
+        echo -e "\033[32mPercona install successfully! \033[0m"
+else
+	rm -rf $percona_install_dir
+        echo -e "\033[31mPercona install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+/bin/cp support-files/mysql.server /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+[ -d "$percona_install_dir" ] && /bin/rm -rf percona-server-$percona_5_version
+cd ..
+
+# my.cf
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $percona_install_dir
+datadir = $percona_data_dir
+pid-file = $percona_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $percona_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $percona_data_dir/mysql-slow.log
+
+performance_schema = 0
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Memtatol -gt 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$percona_install_dir/scripts/mysql_install_db --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir
+
+chown mysql.mysql -R $percona_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$percona_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $percona_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$percona_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$percona_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$percona_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+sed -i "s@^db_install_dir.*@db_install_dir=$percona_install_dir@" options.conf
+sed -i "s@^db_data_dir.*@db_data_dir=$percona_data_dir@" options.conf
+service mysqld stop
+}

+ 204 - 0
functions/percona-5.6.sh

@@ -0,0 +1,204 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_Percona-5-6()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://www.percona.com/redir/downloads/Percona-Server-5.6/LATEST/source/tarball/percona-server-$percona_6_version.tar.gz && Download_src
+
+useradd -M -s /sbin/nologin mysql
+mkdir -p $percona_data_dir;chown mysql.mysql -R $percona_data_dir
+tar zxf percona-server-$percona_6_version.tar.gz 
+cd percona-server-$percona_6_version 
+if [ "$je_tc_malloc" == '1' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
+elif [ "$je_tc_malloc" == '2' ];then
+        EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
+fi
+make clean
+[ ! -d "$percona_install_dir" ] && mkdir -p $percona_install_dir
+cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \
+-DMYSQL_DATADIR=$percona_data_dir \
+-DSYSCONFDIR=/etc \
+-DWITH_INNOBASE_STORAGE_ENGINE=1 \
+-DWITH_PARTITION_STORAGE_ENGINE=1 \
+-DWITH_FEDERATED_STORAGE_ENGINE=1 \
+-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+-DWITH_MYISAM_STORAGE_ENGINE=1 \
+-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
+-DENABLED_LOCAL_INFILE=1 \
+-DENABLE_DTRACE=0 \
+-DDEFAULT_CHARSET=utf8 \
+-DDEFAULT_COLLATION=utf8_general_ci \
+$EXE_LINKER
+make -j `grep processor /proc/cpuinfo | wc -l` 
+make install
+
+cd $percona_install_dir/lib/
+ln -s libperconaserverclient.so libmysqlclient.so
+cd -
+
+if [ -d "$percona_install_dir/bin" ];then
+        echo -e "\033[32mPercona install successfully! \033[0m"
+else
+	rm -rf $percona_install_dir
+        echo -e "\033[31mPercona install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+/bin/cp support-files/mysql.server /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+[ -d "$percona_install_dir" ] && /bin/rm -rf percona-server-$percona_6_version
+cd ..
+
+# my.cf
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $percona_install_dir
+datadir = $percona_data_dir
+pid-file = $percona_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $percona_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $percona_data_dir/mysql-slow.log
+
+performance_schema = 0
+explicit_defaults_for_timestamp
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Memtatol -gt 3500 ];then
+        sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+        sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+        sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+        sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+        sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+        sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+        sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$percona_install_dir/scripts/mysql_install_db --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir
+
+chown mysql.mysql -R $percona_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$percona_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $percona_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$percona_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$percona_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$percona_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
+$percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+sed -i "s@^db_install_dir.*@db_install_dir=$percona_install_dir@" options.conf
+sed -i "s@^db_data_dir.*@db_data_dir=$percona_data_dir@" options.conf
+service mysqld stop
+}

+ 244 - 0
functions/php-5.3.sh

@@ -0,0 +1,244 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_PHP-5-3()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$libiconv_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/$libmcrypt_version/libmcrypt-$libmcrypt_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mhash/mhash/$mhash_version/mhash-$mhash_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/$mcrypt_version/mcrypt-$mcrypt_version.tar.gz && Download_src
+src_url=http://www.php.net/distributions/php-$php_3_version.tar.gz && Download_src
+src_url=http://mirrors.linuxeye.com/lnmp/src/php5.3patch && Download_src
+
+tar xzf libiconv-$libiconv_version.tar.gz
+cd libiconv-$libiconv_version
+./configure --prefix=/usr/local
+[ -n "`cat /etc/issue | grep 'Ubuntu 13'`" ] && sed -i 's@_GL_WARN_ON_USE (gets@//_GL_WARN_ON_USE (gets@' srclib/stdio.h 
+[ -n "`cat /etc/issue | grep 'Ubuntu 14'`" ] && sed -i 's@gets is a security@@' srclib/stdio.h 
+make && make install
+cd ../
+/bin/rm -rf libiconv-$libiconv_version
+
+tar xzf libmcrypt-$libmcrypt_version.tar.gz
+cd libmcrypt-$libmcrypt_version
+./configure
+make && make install
+ldconfig
+cd libltdl/
+./configure --enable-ltdl-install
+make && make install
+cd ../../
+/bin/rm -rf libmcrypt-$libmcrypt_version
+
+tar xzf mhash-$mhash_version.tar.gz
+cd mhash-$mhash_version
+./configure
+make && make install
+cd ../
+/bin/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 \n
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
+        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
+else \n
+        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
+fi'
+OS_command
+
+tar xzf mcrypt-$mcrypt_version.tar.gz
+cd mcrypt-$mcrypt_version
+ldconfig
+./configure
+make && make install
+cd ../
+/bin/rm -rf mcrypt-$mcrypt_version 
+
+tar xzf php-$php_3_version.tar.gz
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+[ ! -e "fpm-race-condition.patch" ] && wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
+patch -d php-$php_3_version -p0 < fpm-race-condition.patch
+cd php-$php_3_version
+patch -p1 < ../php5.3patch 
+make clean
+[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+if [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \
+--with-mysql=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 --enable-mbregex \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+else
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \
+--with-mysql=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 --enable-mbregex \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+fi
+make ZEND_EXTRA_LIBS='-liconv'
+make install
+
+if [ -d "$php_install_dir/bin" ];then
+        echo -e "\033[32mPHP install successfully! \033[0m"
+else
+	rm -rf $php_install_dir
+        echo -e "\033[31mPHP install failed, Please Contact the author! \033[0m"
+        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
+
+/bin/cp php.ini-production $php_install_dir/etc/php.ini
+
+# Modify php.ini
+Mem=`free -m | awk '/Mem:/{print $2}'`
+if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
+        Memory_limit=192
+elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
+        Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
+        Memory_limit=320
+elif [ $Mem -gt 4500 ];then
+        Memory_limit=448
+else
+        Memory_limit=128
+fi
+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 = 50M@' $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@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
+sed -i 's@^max_execution_time.*@max_execution_time = 5@' $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
+sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
+sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $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
+
+if [ "$Apache_version" != '1' -a "$Apache_version" != '2' ];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 \n
+chkconfig php-fpm on'
+OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
+OS_command
+
+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
+
+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/conf/nginx.conf 
+
+if [ $Mem -le 3000 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/2/20))@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/2/30))@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/2/40))@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/2/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 = 80@" $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 = 80@" $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 = 90@" $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 = 90@" $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 = 100@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 100@" $php_install_dir/etc/php-fpm.conf
+elif [ $Mem -gt 8500 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = 120@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 80@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 120@" $php_install_dir/etc/php-fpm.conf
+fi
+
+#[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $local_IP:9000@" $php_install_dir/etc/php-fpm.conf 
+service php-fpm start
+elif [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+service httpd restart
+fi
+cd ..
+[ -d "$php_install_dir" ] && /bin/rm -rf php-$php_3_version 
+cd ..
+}

+ 242 - 0
functions/php-5.4.sh

@@ -0,0 +1,242 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_PHP-5-4()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$libiconv_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/$libmcrypt_version/libmcrypt-$libmcrypt_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mhash/mhash/$mhash_version/mhash-$mhash_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/$mcrypt_version/mcrypt-$mcrypt_version.tar.gz && Download_src
+src_url=http://www.php.net/distributions/php-$php_4_version.tar.gz && Download_src
+
+tar xzf libiconv-$libiconv_version.tar.gz
+cd libiconv-$libiconv_version
+./configure --prefix=/usr/local
+[ -n "`cat /etc/issue | grep 'Ubuntu 13'`" ] && sed -i 's@_GL_WARN_ON_USE (gets@//_GL_WARN_ON_USE (gets@' srclib/stdio.h 
+[ -n "`cat /etc/issue | grep 'Ubuntu 14'`" ] && sed -i 's@gets is a security@@' srclib/stdio.h 
+make && make install
+cd ../
+/bin/rm -rf libiconv-$libiconv_version 
+
+tar xzf libmcrypt-$libmcrypt_version.tar.gz
+cd libmcrypt-$libmcrypt_version
+./configure
+make && make install
+ldconfig
+cd libltdl/
+./configure --enable-ltdl-install
+make && make install
+cd ../../
+/bin/rm -rf libmcrypt-$libmcrypt_version 
+
+tar xzf mhash-$mhash_version.tar.gz
+cd mhash-$mhash_version
+./configure
+make && make install
+cd ../
+/bin/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 \n
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
+        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
+else \n
+        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
+fi'
+OS_command
+
+tar xzf mcrypt-$mcrypt_version.tar.gz
+cd mcrypt-$mcrypt_version
+ldconfig
+./configure
+make && make install
+cd ../
+/bin/rm -rf mcrypt-$mcrypt_version 
+
+tar xzf php-$php_4_version.tar.gz
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+[ ! -e "fpm-race-condition.patch" ] && wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
+patch -d php-$php_4_version -p0 < fpm-race-condition.patch
+cd php-$php_4_version
+make clean
+[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+if [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+else
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+fi
+make ZEND_EXTRA_LIBS='-liconv'
+make install
+
+if [ -d "$php_install_dir/bin" ];then
+        echo -e "\033[32mPHP install successfully! \033[0m"
+else
+	rm -rf $php_install_dir
+        echo -e "\033[31mPHP install failed, Please Contact the author! \033[0m"
+        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
+
+/bin/cp php.ini-production $php_install_dir/etc/php.ini
+
+# Modify php.ini
+Mem=`free -m | awk '/Mem:/{print $2}'`
+if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
+        Memory_limit=192
+elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
+        Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
+        Memory_limit=320
+elif [ $Mem -gt 4500 ];then
+        Memory_limit=448
+else
+        Memory_limit=128
+fi
+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 = 50M@' $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@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
+sed -i 's@^max_execution_time.*@max_execution_time = 5@' $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
+sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
+sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $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
+
+if [ "$Apache_version" != '1' -a "$Apache_version" != '2' ];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 \n
+chkconfig php-fpm on'
+OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
+OS_command
+
+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
+
+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/conf/nginx.conf 
+
+if [ $Mem -le 3000 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/2/20))@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/2/30))@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/2/40))@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/2/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 = 80@" $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 = 80@" $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 = 90@" $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 = 90@" $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 = 100@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 100@" $php_install_dir/etc/php-fpm.conf
+elif [ $Mem -gt 8500 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = 120@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 80@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 120@" $php_install_dir/etc/php-fpm.conf
+fi
+
+#[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $local_IP:9000@" $php_install_dir/etc/php-fpm.conf 
+service php-fpm start
+elif [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+service httpd restart
+fi
+cd ..
+[ -d "$php_install_dir" ] && /bin/rm -rf php-$php_4_version 
+cd ..
+}

+ 257 - 0
functions/php-5.5.sh

@@ -0,0 +1,257 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_PHP-5-5()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$libiconv_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/$libmcrypt_version/libmcrypt-$libmcrypt_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mhash/mhash/$mhash_version/mhash-$mhash_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/$mcrypt_version/mcrypt-$mcrypt_version.tar.gz && Download_src
+src_url=http://www.php.net/distributions/php-$php_5_version.tar.gz && Download_src
+
+tar xzf libiconv-$libiconv_version.tar.gz
+cd libiconv-$libiconv_version
+./configure --prefix=/usr/local
+[ -n "`cat /etc/issue | grep 'Ubuntu 13'`" ] && sed -i 's@_GL_WARN_ON_USE (gets@//_GL_WARN_ON_USE (gets@' srclib/stdio.h 
+[ -n "`cat /etc/issue | grep 'Ubuntu 14'`" ] && sed -i 's@gets is a security@@' srclib/stdio.h 
+
+make && make install
+cd ../
+/bin/rm -rf libiconv-$libiconv_version
+
+tar xzf libmcrypt-$libmcrypt_version.tar.gz
+cd libmcrypt-$libmcrypt_version
+./configure
+make && make install
+ldconfig
+cd libltdl/
+./configure --enable-ltdl-install
+make && make install
+cd ../../
+/bin/rm -rf libmcrypt-$libmcrypt_version
+
+tar xzf mhash-$mhash_version.tar.gz
+cd mhash-$mhash_version
+./configure
+make && make install
+cd ../
+/bin/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 \n
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
+        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
+else \n
+        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
+fi'
+OS_command
+
+tar xzf mcrypt-$mcrypt_version.tar.gz
+cd mcrypt-$mcrypt_version
+ldconfig
+./configure
+make && make install
+cd ../
+/bin/rm -rf mcrypt-$mcrypt_version
+
+tar xzf php-$php_5_version.tar.gz
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+[ ! -e "fpm-race-condition.patch" ] && wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
+patch -d php-$php_5_version -p0 < fpm-race-condition.patch
+cd php-$php_5_version
+make clean
+[ ! -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' -o "$Apache_version" == '2' ];then
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+else
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+fi
+make ZEND_EXTRA_LIBS='-liconv'
+make install
+
+if [ -d "$php_install_dir/bin" ];then
+        echo -e "\033[32mPHP install successfully! \033[0m"
+else
+	rm -rf $php_install_dir
+        echo -e "\033[31mPHP install failed, Please Contact the author! \033[0m"
+        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
+
+/bin/cp php.ini-production $php_install_dir/etc/php.ini
+
+# Modify php.ini
+Mem=`free -m | awk '/Mem:/{print $2}'`
+if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
+	Memory_limit=192
+elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
+	Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
+	Memory_limit=320
+elif [ $Mem -gt 4500 ];then
+	Memory_limit=448
+else
+	Memory_limit=128
+fi
+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 = 50M@' $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@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
+sed -i 's@^max_execution_time.*@max_execution_time = 5@' $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
+sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
+sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $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
+
+if [ "$PHP_cache" == '1' ];then
+sed -i 's@^\[opcache\]@[opcache]\nzend_extension=opcache.so@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.enable=.*@opcache.enable=1@' $php_install_dir/etc/php.ini
+sed -i "s@^;opcache.memory_consumption.*@opcache.memory_consumption=$Memory_limit@" $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.interned_strings_buffer.*@opcache.interned_strings_buffer=8@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.max_accelerated_files.*@opcache.max_accelerated_files=4000@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.revalidate_freq.*@opcache.revalidate_freq=60@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.save_comments.*@opcache.save_comments=0@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.fast_shutdown.*@opcache.fast_shutdown=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.enable_cli.*@opcache.enable_cli=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.optimization_level.*@;opcache.optimization_level=0@' $php_install_dir/etc/php.ini
+fi
+
+if [ "$Apache_version" != '1' -a "$Apache_version" != '2' ];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 \n
+chkconfig php-fpm on'
+OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
+OS_command
+
+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
+
+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/conf/nginx.conf 
+
+if [ $Mem -le 3000 ];then
+	sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/2/20))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/2/30))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/2/40))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/2/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 = 80@" $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 = 80@" $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 = 90@" $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 = 90@" $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 = 100@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 100@" $php_install_dir/etc/php-fpm.conf
+elif [ $Mem -gt 8500 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = 120@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 80@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 120@" $php_install_dir/etc/php-fpm.conf
+fi
+
+#[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $local_IP:9000@" $php_install_dir/etc/php-fpm.conf 
+service php-fpm start
+elif [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+service httpd restart
+fi
+cd ..
+[ -d "$php_install_dir" ] && /bin/rm -rf php-$php_5_version
+cd ..
+}

+ 256 - 0
functions/php-5.6.sh

@@ -0,0 +1,256 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_PHP-5-6()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$libiconv_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/$libmcrypt_version/libmcrypt-$libmcrypt_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mhash/mhash/$mhash_version/mhash-$mhash_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/$mcrypt_version/mcrypt-$mcrypt_version.tar.gz && Download_src
+src_url=http://www.php.net/distributions/php-$php_6_version.tar.gz && Download_src
+
+tar xzf libiconv-$libiconv_version.tar.gz
+cd libiconv-$libiconv_version
+./configure --prefix=/usr/local
+[ -n "`cat /etc/issue | grep 'Ubuntu 13'`" ] && sed -i 's@_GL_WARN_ON_USE (gets@//_GL_WARN_ON_USE (gets@' srclib/stdio.h 
+[ -n "`cat /etc/issue | grep 'Ubuntu 14'`" ] && sed -i 's@gets is a security@@' srclib/stdio.h 
+make && make install
+cd ../
+/bin/rm -rf libiconv-$libiconv_version
+
+tar xzf libmcrypt-$libmcrypt_version.tar.gz
+cd libmcrypt-$libmcrypt_version
+./configure
+make && make install
+ldconfig
+cd libltdl/
+./configure --enable-ltdl-install
+make && make install
+cd ../../
+/bin/rm -rf libmcrypt-$libmcrypt_version
+
+tar xzf mhash-$mhash_version.tar.gz
+cd mhash-$mhash_version
+./configure
+make && make install
+cd ../
+/bin/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 \n
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
+        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
+else \n
+        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
+fi'
+OS_command
+
+tar xzf mcrypt-$mcrypt_version.tar.gz
+cd mcrypt-$mcrypt_version
+ldconfig
+./configure
+make && make install
+cd ../
+/bin/rm -rf mcrypt-$mcrypt_version
+
+tar xzf php-$php_6_version.tar.gz
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+[ ! -e "fpm-race-condition.patch" ] && wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
+patch -d php-$php_6_version -p0 < fpm-race-condition.patch
+cd php-$php_6_version
+make clean
+[ ! -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' -o "$Apache_version" == '2' ];then
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+else
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+fi
+make ZEND_EXTRA_LIBS='-liconv'
+make install
+
+if [ -d "$php_install_dir/bin" ];then
+        echo -e "\033[32mPHP install successfully! \033[0m"
+else
+	rm -rf $php_install_dir
+        echo -e "\033[31mPHP install failed, Please Contact the author! \033[0m"
+        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
+
+/bin/cp php.ini-production $php_install_dir/etc/php.ini
+
+# Modify php.ini
+Mem=`free -m | awk '/Mem:/{print $2}'`
+if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
+	Memory_limit=192
+elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
+	Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
+	Memory_limit=320
+elif [ $Mem -gt 4500 ];then
+	Memory_limit=448
+else
+	Memory_limit=128
+fi
+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 = 50M@' $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@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
+sed -i 's@^max_execution_time.*@max_execution_time = 5@' $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
+sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
+sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $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
+
+if [ "$PHP_cache" == '1' ];then
+sed -i 's@^\[opcache\]@[opcache]\nzend_extension=opcache.so@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.enable=.*@opcache.enable=1@' $php_install_dir/etc/php.ini
+sed -i "s@^;opcache.memory_consumption.*@opcache.memory_consumption=$Memory_limit@" $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.interned_strings_buffer.*@opcache.interned_strings_buffer=8@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.max_accelerated_files.*@opcache.max_accelerated_files=4000@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.revalidate_freq.*@opcache.revalidate_freq=60@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.save_comments.*@opcache.save_comments=0@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.fast_shutdown.*@opcache.fast_shutdown=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.enable_cli.*@opcache.enable_cli=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.optimization_level.*@;opcache.optimization_level=0@' $php_install_dir/etc/php.ini
+fi
+
+if [ "$Apache_version" != '1' -a "$Apache_version" != '2' ];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 \n
+chkconfig php-fpm on'
+OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
+OS_command
+
+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
+
+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/conf/nginx.conf 
+
+if [ $Mem -le 3000 ];then
+	sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/2/20))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/2/30))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/2/40))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/2/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 = 80@" $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 = 80@" $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 = 90@" $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 = 90@" $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 = 100@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 100@" $php_install_dir/etc/php-fpm.conf
+elif [ $Mem -gt 8500 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = 120@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 80@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 120@" $php_install_dir/etc/php-fpm.conf
+fi
+
+#[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $local_IP:9000@" $php_install_dir/etc/php-fpm.conf 
+service php-fpm start
+elif [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+service httpd restart
+fi
+cd ..
+[ -d "$php_install_dir" ] && /bin/rm -rf php-$php_6_version
+cd ..
+}

+ 261 - 0
functions/php-7.sh

@@ -0,0 +1,261 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_PHP-7()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$libiconv_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/$libmcrypt_version/libmcrypt-$libmcrypt_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mhash/mhash/$mhash_version/mhash-$mhash_version.tar.gz && Download_src
+src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/$mcrypt_version/mcrypt-$mcrypt_version.tar.gz && Download_src
+src_url=https://downloads.php.net/~ab/php-$php_7_version.tar.gz && Download_src
+
+tar xzf libiconv-$libiconv_version.tar.gz
+cd libiconv-$libiconv_version
+./configure --prefix=/usr/local
+[ -n "`cat /etc/issue | grep 'Ubuntu 13'`" ] && sed -i 's@_GL_WARN_ON_USE (gets@//_GL_WARN_ON_USE (gets@' srclib/stdio.h 
+[ -n "`cat /etc/issue | grep 'Ubuntu 14'`" ] && sed -i 's@gets is a security@@' srclib/stdio.h 
+make && make install
+cd ../
+/bin/rm -rf libiconv-$libiconv_version
+
+tar xzf libmcrypt-$libmcrypt_version.tar.gz
+cd libmcrypt-$libmcrypt_version
+./configure
+make && make install
+ldconfig
+cd libltdl/
+./configure --enable-ltdl-install
+make && make install
+cd ../../
+/bin/rm -rf libmcrypt-$libmcrypt_version
+
+tar xzf mhash-$mhash_version.tar.gz
+cd mhash-$mhash_version
+./configure
+make && make install
+cd ../
+/bin/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 \n
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
+        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
+else \n
+        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
+fi'
+OS_command
+
+tar xzf mcrypt-$mcrypt_version.tar.gz
+cd mcrypt-$mcrypt_version
+ldconfig
+./configure
+make && make install
+cd ../
+/bin/rm -rf mcrypt-$mcrypt_version
+
+tar xzf php-$php_7_version.tar.gz 
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+cd php-$php_7_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' -o "$Apache_version" == '2' ];then
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+else
+CFLAGS= CXXFLAGS= ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
+--with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+--with-mysql=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 --enable-mbregex --enable-inline-optimization \
+--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
+--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+fi
+make ZEND_EXTRA_LIBS='-liconv'
+make install
+
+if [ -d "$php_install_dir/bin" ];then
+        echo -e "\033[32mPHP install successfully! \033[0m"
+else
+	rm -rf $php_install_dir
+        echo -e "\033[31mPHP install failed, Please Contact the author! \033[0m"
+        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
+
+/bin/cp php.ini-production $php_install_dir/etc/php.ini
+
+# Modify php.ini
+Mem=`free -m | awk '/Mem:/{print $2}'`
+if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
+	Memory_limit=192
+elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
+	Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
+	Memory_limit=320
+elif [ $Mem -gt 4500 ];then
+	Memory_limit=448
+else
+	Memory_limit=128
+fi
+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 = 50M@' $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@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $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
+sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
+sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $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
+
+if [ "$PHP_cache" == '1' ];then
+sed -i 's@^\[opcache\]@[opcache]\nzend_extension=opcache.so@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.enable=.*@opcache.enable=1@' $php_install_dir/etc/php.ini
+sed -i "s@^;opcache.memory_consumption.*@opcache.memory_consumption=$Memory_limit@" $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.interned_strings_buffer.*@opcache.interned_strings_buffer=8@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.max_accelerated_files.*@opcache.max_accelerated_files=4000@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.revalidate_freq.*@opcache.revalidate_freq=60@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.save_comments.*@opcache.save_comments=0@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.fast_shutdown.*@opcache.fast_shutdown=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.validate_timestamps.*@opcache.validate_timestamps=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.enable_cli.*@opcache.enable_cli=1@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.use_cwd.*@opcache.use_cwd=1@' $php_install_dir/etc/php.ini
+sed -i 's@^opcache.max_accelerated_files.*@opcache.max_accelerated_files=100000@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.max_wasted_percentage.*@opcache.max_wasted_percentage=5@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.consistency_checks.*@opcache.consistency_checks=0@' $php_install_dir/etc/php.ini
+sed -i 's@^;opcache.optimization_level.*@;opcache.optimization_level=0@' $php_install_dir/etc/php.ini
+fi
+
+if [ "$Apache_version" != '1' -a "$Apache_version" != '2' ];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 \n
+chkconfig php-fpm on'
+OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
+OS_command
+
+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
+
+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/conf/nginx.conf 
+
+if [ $Mem -le 3000 ];then
+	sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/2/20))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/2/30))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/2/40))@" $php_install_dir/etc/php-fpm.conf
+	sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/2/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 = 80@" $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 = 80@" $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 = 90@" $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 = 90@" $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 = 100@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 100@" $php_install_dir/etc/php-fpm.conf
+elif [ $Mem -gt 8500 ];then
+        sed -i "s@^pm.max_children.*@pm.max_children = 120@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.start_servers.*@pm.start_servers = 80@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 120@" $php_install_dir/etc/php-fpm.conf
+fi
+
+#[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $local_IP:9000@" $php_install_dir/etc/php-fpm.conf 
+service php-fpm start
+elif [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+service httpd restart
+fi
+cd ..
+[ -d "$php_install_dir" ] && /bin/rm -rf php-$php_7_version
+cd ..
+}

+ 21 - 0
functions/phpmyadmin.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_phpMyAdmin()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../options.conf 
+
+src_url=http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/${phpMyAdmin_version}/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz && Download_src
+
+tar xzf phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz
+/bin/mv phpMyAdmin-${phpMyAdmin_version}-all-languages $home_dir/default/phpMyAdmin
+/bin/cp $home_dir/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
+mkdir $home_dir/default/phpMyAdmin/{upload,save}
+sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" $home_dir/default/phpMyAdmin/config.inc.php
+sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" $home_dir/default/phpMyAdmin/config.inc.php
+chown -R ${run_user}.$run_user $home_dir/default/phpMyAdmin
+cd ..
+}

+ 65 - 0
functions/pureftpd.sh

@@ -0,0 +1,65 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_PureFTPd()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+src_url=http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-$pureftpd_version.tar.gz && Download_src
+
+tar xzf pure-ftpd-$pureftpd_version.tar.gz
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+cd pure-ftpd-$pureftpd_version
+[ ! -d "$pureftpd_install_dir" ] && mkdir -p $pureftpd_install_dir
+./configure --prefix=$pureftpd_install_dir CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg  --with-throttling --with-uploadscript --with-language=english --with-rfc2640
+make && make install
+if [ -d "$pureftpd_install_dir/bin" ];then
+        echo -e "\033[32mPure-Ftp install successfully! \033[0m"
+	[ ! -e "$pureftpd_install_dir/etc" ] && mkdir $pureftpd_install_dir/etc
+	cp configuration-file/pure-config.pl $pureftpd_install_dir/sbin
+	sed -i "s@/usr/local/pureftpd@$pureftpd_install_dir@" $pureftpd_install_dir/sbin/pure-config.pl
+	chmod +x $pureftpd_install_dir/sbin/pure-config.pl
+	cp contrib/redhat.init /etc/init.d/pureftpd
+	cd ../../
+	sed -i "s@fullpath=.*@fullpath=$pureftpd_install_dir/sbin/\$prog@" /etc/init.d/pureftpd
+	sed -i "s@pureftpwho=.*@pureftpwho=$pureftpd_install_dir/sbin/pure-ftpwho@" /etc/init.d/pureftpd
+	sed -i "s@/etc/pure-ftpd.conf@$pureftpd_install_dir/etc/pure-ftpd.conf@" /etc/init.d/pureftpd
+	chmod +x /etc/init.d/pureftpd
+	OS_CentOS='chkconfig --add pureftpd \n
+chkconfig pureftpd on'
+	OS_Debian_Ubuntu="sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd \n
+update-rc.d pureftpd defaults"
+	OS_command
+
+	/bin/cp conf/pure-ftpd.conf $pureftpd_install_dir/etc
+	sed -i "s@^PureDB.*@PureDB	$pureftpd_install_dir/etc/pureftpd.pdb@" $pureftpd_install_dir/etc/pure-ftpd.conf
+	sed -i "s@^LimitRecursion.*@LimitRecursion	65535 8@" $pureftpd_install_dir/etc/pure-ftpd.conf
+	ulimit -s unlimited
+	service pureftpd start
+
+	# iptables Ftp
+	if [ -e '/etc/sysconfig/iptables' ];then
+		if [ -z "`grep '20000:30000' /etc/sysconfig/iptables`" ];then
+			iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+			iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+		fi
+	elif [ -e '/etc/iptables.up.rules' ];then
+		if [ -z "`grep '20000:30000' /etc/iptables.up.rules`" ];then
+			iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+			iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+		fi
+	fi
+	OS_CentOS='service iptables save'
+	OS_Debian_Ubuntu='iptables-save > /etc/iptables.up.rules'
+	OS_command
+else
+	cd ../../
+        echo -e "\033[31mPure-Ftp install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+}

+ 85 - 0
functions/redis.sh

@@ -0,0 +1,85 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_redis()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh
+. ../options.conf
+
+if [ -e "$php_install_dir/bin/phpize" ];then
+	src_url=http://pecl.php.net/get/redis-$redis_pecl_version.tgz && Download_src
+	tar xzf redis-$redis_pecl_version.tgz
+	cd redis-$redis_pecl_version
+	make clean
+	$php_install_dir/bin/phpize
+	./configure --with-php-config=$php_install_dir/bin/php-config
+	make && make install
+	cd ..
+	/bin/rm -rf redis-$redis_pecl_version
+	if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/redis.so" ];then
+		[ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions  | grep zts`\"@" $php_install_dir/etc/php.ini
+		sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "redis.so"@' $php_install_dir/etc/php.ini
+		[ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+	else
+	        echo -e "\033[31mPHP Redis module install failed, Please contact the author! \033[0m"
+	fi
+fi
+
+src_url=http://download.redis.io/releases/redis-$redis_version.tar.gz && Download_src
+tar xzf redis-$redis_version.tar.gz
+cd redis-$redis_version
+if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 32 ];then
+	sed -i '1i\CFLAGS= -march=i686' src/Makefile
+	sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
+fi
+
+make
+
+if [ -f "src/redis-server" ];then
+	mkdir -p $redis_install_dir/{bin,etc,var}
+	/bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/
+	/bin/cp redis.conf $redis_install_dir/etc/
+	ln -s $redis_install_dir/bin/* /usr/local/bin/
+	sed -i 's@pidfile.*@pidfile /var/run/redis.pid@' $redis_install_dir/etc/redis.conf
+	sed -i "s@logfile.*@logfile $redis_install_dir/var/redis.log@" $redis_install_dir/etc/redis.conf
+	sed -i "s@^dir.*@dir $redis_install_dir/var@" $redis_install_dir/etc/redis.conf
+	sed -i 's@daemonize no@daemonize yes@' $redis_install_dir/etc/redis.conf
+
+	Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+	if [ $Memtatol -le 512 ];then
+		[ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 64000000@' $redis_install_dir/etc/redis.conf
+	elif [ $Memtatol -gt 512 -a $Memtatol -le 1024 ];then
+		[ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 128000000@' $redis_install_dir/etc/redis.conf
+	elif [ $Memtatol -gt 1024 -a $Memtatol -le 1500 ];then
+		[ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 256000000@' $redis_install_dir/etc/redis.conf
+	elif [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+		[ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 360000000@' $redis_install_dir/etc/redis.conf
+	elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+		[ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 512000000@' $redis_install_dir/etc/redis.conf
+	elif [ $Memtatol -gt 3500 ];then
+		[ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 1024000000@' $redis_install_dir/etc/redis.conf
+	fi
+
+	cd ..
+	/bin/rm -rf redis-$redis_version
+	cd ..
+	OS_CentOS='/bin/cp init/Redis-server-init-CentOS /etc/init.d/redis-server \n
+chkconfig --add redis-server \n
+chkconfig redis-server on'
+	OS_Debian_Ubuntu="useradd -M -s /sbin/nologin redis \n
+chown -R redis:redis $redis_install_dir/var/ \n
+/bin/cp init/Redis-server-init-Ubuntu /etc/init.d/redis-server \n
+update-rc.d redis-server defaults"
+	OS_command
+	sed -i "s@/usr/local/redis@$redis_install_dir@g" /etc/init.d/redis-server
+	#[ -z "`grep 'vm.overcommit_memory' /etc/sysctl.conf`" ] && echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
+	#sysctl -p
+	service redis-server start
+else
+	cd ../../
+	echo -e "\033[31mRedis install failed, Please contact the author! \033[0m"
+fi
+}

+ 27 - 0
functions/tcmalloc.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_tcmalloc()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+
+src_url=https://googledrive.com/host/0B6NtGsLhIcf7MWxMMF9JdTN3UVk/gperftools-$tcmalloc_version.tar.gz && Download_src
+
+tar xzf gperftools-$tcmalloc_version.tar.gz 
+cd gperftools-$tcmalloc_version
+./configure --enable-frame-pointers
+make && make install
+cd ..
+/bin/rm -rf gperftools-$tcmalloc_version
+
+if [ -f "/usr/local/lib/libtcmalloc.so" ];then
+	echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+	ldconfig
+else
+	echo -e "\033[31mgperftools install failed, Please contact the author! \033[0m"
+	kill -9 $$
+fi
+cd ..
+}

+ 101 - 0
functions/tengine.sh

@@ -0,0 +1,101 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_Tengine()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../functions/check_os.sh 
+. ../options.conf
+
+src_url=http://downloads.sourceforge.net/project/pcre/pcre/$pcre_version/pcre-$pcre_version.tar.gz && Download_src
+src_url=http://tengine.taobao.org/download/tengine-$tengine_version.tar.gz && Download_src
+
+tar xzf pcre-$pcre_version.tar.gz
+cd pcre-$pcre_version
+./configure
+make && make install
+cd ../
+
+tar xzf tengine-$tengine_version.tar.gz 
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+cd tengine-$tengine_version 
+
+# Modify Tengine version
+#sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h
+
+# close debug
+sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
+
+# make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
+sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c
+sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c
+
+if [ "$je_tc_malloc" == '1' ];then
+	malloc_module='--with-jemalloc'
+elif [ "$je_tc_malloc" == '2' ];then
+	malloc_module='--with-google_perftools_module'
+	mkdir /tmp/tcmalloc
+	chown -R ${run_user}.$run_user /tmp/tcmalloc
+fi
+
+[ ! -d "$tengine_install_dir" ] && mkdir -p $tengine_install_dir
+./configure --prefix=$tengine_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_concat_module=shared --with-http_sysguard_module=shared $malloc_module
+make && make install
+if [ -d "$tengine_install_dir/conf" ];then
+        echo -e "\033[32mTengine install successfully! \033[0m"
+else
+	rm -rf $tengine_install_dir
+        echo -e "\033[31mTengine install failed, Please Contact the author! \033[0m"
+        kill -9 $$
+fi
+
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$tengine_install_dir/sbin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $tengine_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+cd ../../
+OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n
+chkconfig --add nginx \n
+chkconfig nginx on'
+OS_Debian_Ubuntu='/bin/cp init/Nginx-init-Ubuntu /etc/init.d/nginx \n
+update-rc.d nginx defaults'
+OS_command
+sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx
+
+mv $tengine_install_dir/conf/nginx.conf{,_bk}
+if [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then
+        /bin/cp conf/nginx_apache.conf $tengine_install_dir/conf/nginx.conf
+else
+        /bin/cp conf/nginx.conf $tengine_install_dir/conf/nginx.conf
+fi
+sed -i "s@/home/wwwroot/default@$home_dir/default@" $tengine_install_dir/conf/nginx.conf
+sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf
+sed -i "s@^user www www@user $run_user $run_user@" $tengine_install_dir/conf/nginx.conf
+[ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $tengine_install_dir/conf/nginx.conf 
+
+# worker_cpu_affinity
+sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf
+
+# logrotate nginx log
+cat > /etc/logrotate.d/nginx << EOF
+$wwwlogs_dir/*nginx.log {
+daily
+rotate 5
+missingok
+dateext
+compress
+notifempty
+sharedscripts
+postrotate
+    [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\`
+endscript
+}
+EOF
+
+sed -i "s@^web_install_dir.*@web_install_dir=$tengine_install_dir@" options.conf
+ldconfig
+service nginx start
+}

+ 38 - 0
functions/test.sh

@@ -0,0 +1,38 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+TEST()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh 
+. ../options.conf
+
+public_IP=`../functions/get_public_ip.py`
+if [ "`../functions/get_ip_area.py $public_IP`" == '\u4e2d\u56fd' ];then
+	FLAG_IP=CN
+fi
+
+echo $public_IP $FLAG_IP
+
+if [ "$FLAG_IP"x == "CN"x ];then
+	src_url=http://mirrors.linuxeye.com/lnmp/src/tz.zip && Download_src
+	unzip -q tz.zip -d $home_dir/default
+	/bin/cp $oneinstack_dir/conf/index_cn.html $home_dir/default/index.html
+else
+	src_url=http://mirrors.linuxeye.com/lnmp/src/tz_e.zip && Download_src
+	unzip -q tz_e.zip -d $home_dir/default;/bin/mv $home_dir/default/{tz_e.php,proberv.php}
+	sed -i 's@https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js@http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js@' $home_dir/default/proberv.php 
+	/bin/cp $oneinstack_dir/conf/index.html $home_dir/default
+fi
+src_url=https://gist.githubusercontent.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php && Download_src
+
+echo '<?php phpinfo() ?>' > $home_dir/default/phpinfo.php
+[ "$PHP_cache" == '1' ] && /bin/cp ocp.php $home_dir/default && sed -i 's@<a href="/xcache" target="_blank" class="links">xcache</a>@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@' $home_dir/default/index.html
+[ "$PHP_cache" == '3' ] && sed -i 's@<a href="/xcache" target="_blank" class="links">xcache</a>@<a href="/apc.php" target="_blank" class="links">APC</a>@' $home_dir/default/index.html
+[ "$PHP_cache" == '4' ] && /bin/cp eaccelerator-*/control.php $home_dir/default && sed -i 's@<a href="/xcache" target="_blank" class="links">xcache</a>@<a href="/control.php" target="_blank" class="links">eAccelerator</a>@' $home_dir/default/index.html
+chown -R ${run_user}.$run_user $home_dir/default
+[ -e "$db_install_dir" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld restart 
+[ -e "$apache_install_dir" -a -z "`ps -ef | grep -v grep | grep apache`" ] && /etc/init.d/httpd restart 
+cd ..
+}

+ 99 - 0
functions/tomcat-7.sh

@@ -0,0 +1,99 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+Install_tomcat-7()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+. /etc/profile
+
+public_IP=`../functions/get_public_ip.py`
+if [ "`../functions/get_ip_area.py $public_IP`" == '\u4e2d\u56fd' ];then
+        FLAG_IP=CN
+fi
+
+echo $public_IP $FLAG_IP
+
+[ "$FLAG_IP"x == "CN"x ] && DOWN_ADDR=http://mirrors.aliyun.com/apache || DOWN_ADDR=http://www.apache.org/dist
+
+src_url=$DOWN_ADDR/tomcat/tomcat-7/v$tomcat_7_version/bin/apache-tomcat-$tomcat_7_version.tar.gz && Download_src
+src_url=$DOWN_ADDR/tomcat/tomcat-7/v$tomcat_7_version/bin/extras/catalina-jmx-remote.jar && Download_src
+
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
+tar xzf apache-tomcat-$tomcat_7_version.tar.gz
+[ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
+/bin/cp -R apache-tomcat-$tomcat_7_version/* $tomcat_install_dir/ 
+
+if [ -d "$tomcat_install_dir/conf" ];then
+	/bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
+	cd $tomcat_install_dir/lib
+	[ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina 
+	cd $tomcat_install_dir/lib/catalina
+	jar xf ../catalina.jar
+	sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
+	sed -i 's@^server.number=.*@server.number=7@' org/apache/catalina/util/ServerInfo.properties
+	sed -i "s@^server.built=.*@server.built=`date`@" org/apache/catalina/util/ServerInfo.properties
+	jar cf ../catalina.jar ./*
+	cd ../../bin 
+	rm -rf $tomcat_install_dir/lib/catalina 
+	OS_CentOS='yum -y install apr apr-devel'
+        OS_Debian_Ubuntu='apt-get -y install libapr1-dev libaprutil1-dev'
+        OS_command
+	tar xzf tomcat-native.tar.gz 
+	cd tomcat-native-*-src/jni/native/
+	rm -rf /usr/local/apr
+	./configure --with-apr=/usr/bin/apr-1-config
+	make && make install
+	if [ -d "/usr/local/apr/lib" ];then
+		Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+		cat > $tomcat_install_dir/bin/setenv.sh << EOF
+JAVA_OPTS='-server -Xms256m -Xmx`expr $Memtatol / 2`m'
+CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
+#  -Djava.rmi.server.hostname=$local_IP
+#  -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
+# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
+#  -Dcom.sun.management.jmxremote.ssl=false"
+EOF
+		cd ../../../;rm -rf tomcat-native-*
+		chmod +x $tomcat_install_dir/bin/*.sh
+		/bin/mv $tomcat_install_dir/conf/server.xml{,_bk} 
+		cd $oneinstack_dir/src
+		/bin/cp ../conf/server.xml $tomcat_install_dir/conf/
+		cat > $tomcat_install_dir/conf/jmxremote.access << EOF
+monitorRole   readonly
+controlRole   readwrite \
+              create javax.management.monitor.*,javax.management.timer.* \
+              unregister
+EOF
+		cat > $tomcat_install_dir/conf/jmxremote.password << EOF
+monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8` 
+# controlRole   R&D
+EOF
+		chown -R $run_user.$run_user $tomcat_install_dir
+		/bin/cp ../init/Tomcat-init /etc/init.d/tomcat
+		sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
+		sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
+		sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
+		OS_CentOS='chkconfig --add tomcat \n
+		chkconfig tomcat on'
+		OS_Debian_Ubuntu='update-rc.d tomcat defaults'
+		OS_command
+	        echo -e "\033[32mTomcat-7 install successfully! \033[0m"
+	fi
+else
+	rm -rf $tomcat_install_dir
+        echo -e "\033[31mTomcat-7 install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+}

+ 99 - 0
functions/tomcat-8.sh

@@ -0,0 +1,99 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+Install_tomcat-8()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../functions/check_os.sh
+. ../options.conf
+. /etc/profile
+
+public_IP=`../functions/get_public_ip.py`
+if [ "`../functions/get_ip_area.py $public_IP`" == '\u4e2d\u56fd' ];then
+        FLAG_IP=CN
+fi
+
+echo $public_IP $FLAG_IP
+
+[ "$FLAG_IP"x == "CN"x ] && DOWN_ADDR=http://mirrors.aliyun.com/apache || DOWN_ADDR=http://www.apache.org/dist
+
+src_url=$DOWN_ADDR/tomcat/tomcat-8/v$tomcat_8_version/bin/apache-tomcat-$tomcat_8_version.tar.gz && Download_src
+src_url=$DOWN_ADDR/tomcat/tomcat-8/v$tomcat_8_version/bin/extras/catalina-jmx-remote.jar && Download_src
+
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
+tar xzf apache-tomcat-$tomcat_8_version.tar.gz
+[ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
+/bin/cp -R apache-tomcat-$tomcat_8_version/* $tomcat_install_dir/ 
+
+if [ -d "$tomcat_install_dir/conf" ];then
+	/bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
+	cd $tomcat_install_dir/lib
+	[ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina 
+	cd $tomcat_install_dir/lib/catalina
+	jar xf ../catalina.jar
+	sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
+	sed -i 's@^server.number=.*@server.number=7@' org/apache/catalina/util/ServerInfo.properties
+	sed -i "s@^server.built=.*@server.built=`date`@" org/apache/catalina/util/ServerInfo.properties
+	jar cf ../catalina.jar ./*
+	cd ../../bin 
+	rm -rf $tomcat_install_dir/lib/catalina 
+	OS_CentOS='yum -y install apr apr-devel'
+        OS_Debian_Ubuntu='apt-get -y install libapr1-dev libaprutil1-dev'
+        OS_command
+	tar xzf tomcat-native.tar.gz 
+	cd tomcat-native-*-src/jni/native/
+	rm -rf /usr/local/apr
+	./configure --with-apr=/usr/bin/apr-1-config
+	make && make install
+	if [ -d "/usr/local/apr/lib" ];then
+		Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+		cat > $tomcat_install_dir/bin/setenv.sh << EOF
+JAVA_OPTS='-server -Xms256m -Xmx`expr $Memtatol / 2`m'
+CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
+#  -Djava.rmi.server.hostname=$local_IP
+#  -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
+# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
+#  -Dcom.sun.management.jmxremote.ssl=false"
+EOF
+		cd ../../../;rm -rf tomcat-native-*
+		chmod +x $tomcat_install_dir/bin/*.sh
+		/bin/mv $tomcat_install_dir/conf/server.xml{,_bk} 
+		cd $oneinstack_dir/src
+		/bin/cp ../conf/server.xml $tomcat_install_dir/conf/
+		cat > $tomcat_install_dir/conf/jmxremote.access << EOF
+monitorRole   readonly
+controlRole   readwrite \
+              create javax.management.monitor.*,javax.management.timer.* \
+              unregister
+EOF
+		cat > $tomcat_install_dir/conf/jmxremote.password << EOF
+monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8` 
+# controlRole   R&D
+EOF
+		chown -R $run_user.$run_user $tomcat_install_dir
+		/bin/cp ../init/Tomcat-init /etc/init.d/tomcat
+		sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
+		sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
+		sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
+		OS_CentOS='chkconfig --add tomcat \n
+		chkconfig tomcat on'
+		OS_Debian_Ubuntu='update-rc.d tomcat defaults'
+		OS_command
+	        echo -e "\033[32mTomcat-8 install successfully! \033[0m"
+	fi
+else
+	rm -rf $tomcat_install_dir
+        echo -e "\033[31mTomcat-8 install failed, Please contact the author! \033[0m"
+        kill -9 $$
+fi
+
+}

+ 82 - 0
functions/xcache.sh

@@ -0,0 +1,82 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_XCache()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=http://xcache.lighttpd.net/pub/Releases/$xcache_version/xcache-$xcache_version.tar.gz && Download_src
+tar xzf xcache-$xcache_version.tar.gz 
+cd xcache-$xcache_version
+make clean
+$php_install_dir/bin/phpize
+./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=$php_install_dir/bin/php-config
+make && make install
+if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/xcache.so" ];then
+	/bin/cp -R htdocs $home_dir/default/xcache
+	chown -R ${run_user}.$run_user $home_dir/default/xcache
+	touch /tmp/xcache;chown ${run_user}.$run_user /tmp/xcache
+
+        Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
+        if [ $Memtatol -le 512 ];then
+		xcache_size=40M
+        elif [ $Memtatol -gt 512 -a $Memtatol -le 1024 ];then
+		xcache_size=80M
+        elif [ $Memtatol -gt 1024 -a $Memtatol -le 1500 ];then
+		xcache_size=100M
+        elif [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
+		xcache_size=160M
+        elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
+		xcache_size=180M
+        elif [ $Memtatol -gt 3500 ];then
+		xcache_size=200M
+        fi
+
+	cat >> $php_install_dir/etc/php.ini << EOF
+[xcache-common]
+extension = "xcache.so"
+[xcache.admin]
+xcache.admin.enable_auth = On
+xcache.admin.user = "admin"
+xcache.admin.pass = "$xcache_admin_md5_pass"
+
+[xcache]
+xcache.size  = $xcache_size 
+xcache.count = $(expr `cat /proc/cpuinfo | grep -c processor` + 1) 
+xcache.slots = 8K
+xcache.ttl = 3600
+xcache.gc_interval = 300
+xcache.var_size = $xcache_size 
+xcache.var_count = $(expr `cat /proc/cpuinfo | grep -c processor` + 1) 
+xcache.var_slots = 8K
+xcache.var_ttl = 0
+xcache.var_maxttl = 0
+xcache.var_gc_interval = 300
+xcache.test = Off
+xcache.readonly_protection = Off
+xcache.shm_scheme = "mmap"
+xcache.mmap_path = "/tmp/xcache"
+xcache.coredump_directory = ""
+xcache.cacher = On
+xcache.stat = On
+xcache.optimizer = Off
+
+[xcache.coverager]
+; enabling this feature will impact performance
+; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value"
+; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions
+xcache.coverager = Off
+xcache.coverager_autostart = On
+xcache.coveragedump_directory = ""
+EOF
+	[ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+else
+        echo -e "\033[31meXcache module install failed, Please contact the author! \033[0m"
+fi
+cd ..
+/bin/rm -rf xcache-$xcache_version
+cd ..
+}

+ 50 - 0
functions/zendopcache.sh

@@ -0,0 +1,50 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+Install_ZendOPcache()
+{
+cd $oneinstack_dir/src
+. ../functions/download.sh
+. ../options.conf
+
+src_url=https://pecl.php.net/get/zendopcache-$zendopcache_version.tgz && Download_src
+tar xzf zendopcache-$zendopcache_version.tgz 
+cd zendopcache-$zendopcache_version 
+make clean
+$php_install_dir/bin/phpize
+./configure --with-php-config=$php_install_dir/bin/php-config
+make && make install
+Mem=`free -m | awk '/Mem:/{print $2}'`
+if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
+        Memory_limit=192
+elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
+        Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
+        Memory_limit=320
+elif [ $Mem -gt 4500 ];then
+        Memory_limit=448
+else
+        Memory_limit=128
+fi
+if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/opcache.so" ];then
+        cat >> $php_install_dir/etc/php.ini << EOF
+[opcache]
+zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/opcache.so"
+opcache.memory_consumption=$Memory_limit
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=4000
+opcache.revalidate_freq=60
+opcache.save_comments=0
+opcache.fast_shutdown=1
+opcache.enable_cli=1
+;opcache.optimization_level=0
+EOF
+        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
+else
+        echo -e "\033[31meZend OPcache module install failed, Please contact the author! \033[0m"
+fi
+cd ..
+/bin/rm -rf zendopcache-$zendopcache_version 
+cd ..
+}

+ 81 - 0
init/Memcached-init-CentOS

@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# chkconfig: - 55 45
+# description:  The memcached daemon is a network memory cache service.
+# processname: memcached
+# config: /etc/sysconfig/memcached
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+PORT=11211
+USER=memcached
+MAXCONN=1024
+CACHESIZE=256
+OPTIONS=""
+
+if [ -f /etc/sysconfig/memcached ];then
+    . /etc/sysconfig/memcached
+fi
+
+# Check that networking is up.
+if [ "$NETWORKING" = "no" ]
+then
+    exit 0
+fi
+
+RETVAL=0
+prog="memcached"
+
+start () {
+    echo -n $"Starting $prog: "
+    # insure that /var/run/memcached has proper permissions
+    mkdir -p /var/run/memcached
+    if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
+        chown $USER /var/run/memcached
+    fi
+    daemon memcached -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS
+    RETVAL=$?
+    echo
+    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
+}
+stop () {
+    echo -n $"Stopping $prog: "
+    killproc memcached
+    RETVAL=$?
+    echo
+    if [ $RETVAL -eq 0 ] ; then
+        rm -f /var/lock/subsys/memcached
+        rm -f /var/run/memcached/memcached.pid 
+    fi
+}
+
+restart () {
+    stop
+    start
+}
+
+
+# See how we were called.
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+    stop
+    ;;
+    status)
+    status memcached
+    ;;
+    restart|reload)
+    restart
+    ;;
+    condrestart)
+    [ -f /var/lock/subsys/memcached ] && restart || :
+    ;;
+    *)
+    echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
+    exit 1
+esac
+
+exit $?

+ 85 - 0
init/Memcached-init-Ubuntu

@@ -0,0 +1,85 @@
+#! /bin/sh
+#
+ 
+PORT=11211
+USER=memcached
+MAXCONN=1024
+OPTIONS=""
+DAEMON=/usr/local/memcached/bin/memcached
+ 
+RETVAL=0
+prog="/usr/local/memcached/bin/memcached"
+ 
+start_instance() {
+        echo -n $"Starting $prog ($1): "
+        start-stop-daemon --start --quiet --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON -- -d -p $PORT -u $USER  -m $2 -c $MAXCONN -P /var/run/memcached/memcached.$1.pid $OPTIONS
+        RETVAL=$?
+        echo
+        [ $RETVAL -eq 0 ] && touch /var/lock/memcached.$1
+        PORT=`expr $PORT + 1`
+}
+ 
+stop_instance() {
+        echo -n $"Stopping $prog ($1): "
+        start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON
+        RETVAL=$?
+        echo
+        if [ $RETVAL -eq 0 ] ; then
+            rm -f /var/lock/memcached.$1
+            rm -f /var/run/memcached/memcached.$1.pid
+        fi
+}
+start () {
+        # insure that /var/run/memcached has proper permissions
+        mkdir -p /var/run/memcached
+        if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
+                chown $USER /var/run/memcached
+        fi
+ 
+        start_instance default 256;
+        #start_instance block 16;
+        #start_instance content 128;
+        #start_instance filter 128;
+        #start_instance form 32;
+        #start_instance menu 16;
+        #start_instance page 8;
+        #start_instance update 8;
+        #start_instance views 8;
+}
+stop () {
+        stop_instance default;
+        #stop_instance block;
+        #stop_instance content;
+        #stop_instance filter;
+        #stop_instance form;
+        #stop_instance menu;
+        #stop_instance page;
+        #stop_instance update;
+        #stop_instance views;
+}
+ 
+restart () {
+        stop
+        start
+}
+ 
+# See how we were called.
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  status)
+        status memcached
+        ;;
+  restart|reload|force-reload)
+        restart
+        ;;
+  *)
+        echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
+        exit 1
+esac
+ 
+exit $?

+ 128 - 0
init/Nginx-init-CentOS

@@ -0,0 +1,128 @@
+#!/bin/sh
+#
+# nginx - this script starts and stops the nginx daemon
+#
+# chkconfig:   - 85 15 
+# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
+#               proxy and IMAP/POP3 proxy server
+# processname: nginx
+# config:      /usr/local/nginx/conf/nginx.conf 
+# pidfile:     /var/run/nginx.pid
+ 
+# Source function library.
+. /etc/rc.d/init.d/functions
+ 
+# Source networking configuration.
+. /etc/sysconfig/network
+ 
+# Check that networking is up.
+[ "$NETWORKING" = "no" ] && exit 0
+ 
+nginx="/usr/local/nginx/sbin/nginx"
+prog=$(basename $nginx)
+ 
+NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
+ 
+[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
+ 
+lockfile=/var/lock/subsys/nginx
+ 
+make_dirs() {
+   # make required directories
+   user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
+   if [ -z "`grep $user /etc/passwd`" ]; then
+       useradd -M -s /bin/nologin $user
+   fi
+   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
+   for opt in $options; do
+       if [ `echo $opt | grep '.*-temp-path'` ]; then
+           value=`echo $opt | cut -d "=" -f 2`
+           if [ ! -d "$value" ]; then
+               # echo "creating" $value
+               mkdir -p $value && chown -R $user $value
+           fi
+       fi
+   done
+}
+ 
+start() {
+    [ -x $nginx ] || exit 5
+    [ -f $NGINX_CONF_FILE ] || exit 6
+    make_dirs
+    echo -n $"Starting $prog: "
+    daemon $nginx -c $NGINX_CONF_FILE
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+ 
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc $prog -QUIT
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+ 
+restart() {
+    configtest || return $?
+    stop
+    sleep 3 
+    start
+}
+ 
+reload() {
+    configtest || return $?
+    echo -n $"Reloading $prog: "
+    killproc $nginx -HUP
+    RETVAL=$?
+    echo
+}
+ 
+force_reload() {
+    restart
+}
+ 
+configtest() {
+  $nginx -t -c $NGINX_CONF_FILE
+}
+ 
+rh_status() {
+    status $prog
+}
+ 
+rh_status_q() {
+    rh_status >/dev/null 2>&1
+}
+ 
+case "$1" in
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart|configtest)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
+        $1
+        ;;
+    force-reload)
+        force_reload
+        ;;
+    status)
+        rh_status
+        ;;
+    condrestart|try-restart)
+        rh_status_q || exit 0
+            ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
+        exit 2
+esac

+ 336 - 0
init/Nginx-init-Ubuntu

@@ -0,0 +1,336 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          nginx
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: nginx init.d dash script for Ubuntu <=9.10.
+# Description:       nginx init.d dash script for Ubuntu <=9.10.
+### END INIT INFO
+#------------------------------------------------------------------------------
+# nginx - this Debian Almquist shell (dash) script, starts and stops the nginx 
+#         daemon for ubuntu 9.10 and lesser version numbered releases.
+#
+# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
+#               proxy and IMAP/POP3 proxy server.  This \
+#		script will manage the initiation of the \
+#		server and it's process state.
+#
+# processname: nginx
+# config:      /usr/local/nginx/conf/nginx.conf
+# pidfile:     /var/run/nginx.pid
+# Provides:    nginx
+#
+# Author:  Jason Giedymin
+#          <jason.giedymin AT gmail.com>.
+#
+# Version: 2.0 02-NOV-2009 jason.giedymin AT gmail.com
+# Notes: nginx init.d dash script for Ubuntu <=9.10.
+# 
+# This script's project home is:
+# 	http://code.google.com/p/nginx-init-ubuntu/
+#
+#------------------------------------------------------------------------------
+#                               Functions
+#------------------------------------------------------------------------------
+. /lib/lsb/init-functions
+ 
+#------------------------------------------------------------------------------
+#                               Consts
+#------------------------------------------------------------------------------
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/nginx/sbin/nginx
+ 
+PS="nginx"
+PIDNAME="nginx"				#lets you do $PS-slave
+PIDFILE=$PIDNAME.pid                    #pid file
+PIDSPATH=/var/run
+ 
+DESCRIPTION="Nginx Server..."
+ 
+RUNAS=root                              #user to run as
+ 
+SCRIPT_OK=0                             #ala error codes
+SCRIPT_ERROR=1                          #ala error codes
+TRUE=1                                  #boolean
+FALSE=0                                 #boolean
+ 
+lockfile=/var/lock/subsys/nginx
+NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
+ 
+#------------------------------------------------------------------------------
+#                               Simple Tests
+#------------------------------------------------------------------------------
+ 
+#test if nginx is a file and executable
+test -x $DAEMON || exit 0
+ 
+# Include nginx defaults if available
+if [ -f /etc/default/nginx ] ; then
+        . /etc/default/nginx
+fi
+ 
+#set exit condition
+#set -e
+ 
+#------------------------------------------------------------------------------
+#                               Functions
+#------------------------------------------------------------------------------
+ 
+setFilePerms(){
+ 
+        if [ -f $PIDSPATH/$PIDFILE ]; then
+                chmod 400 $PIDSPATH/$PIDFILE
+        fi
+}
+ 
+configtest() {
+	$DAEMON -t -c $NGINX_CONF_FILE
+}
+ 
+getPSCount() {
+	return `pgrep -f $PS | wc -l`
+}
+ 
+isRunning() {
+        if [ $1 ]; then
+                pidof_daemon $1
+                PID=$?
+ 
+                if [ $PID -gt 0 ]; then
+                        return 1
+                else
+                        return 0
+                fi
+        else
+                pidof_daemon
+                PID=$?
+ 
+                if [ $PID -gt 0 ]; then
+                        return 1
+                else
+                        return 0
+                fi
+        fi
+}
+ 
+#courtesy of php-fpm
+wait_for_pid () {
+        try=0
+ 
+        while test $try -lt 35 ; do
+ 
+                case "$1" in
+                        'created')
+                        if [ -f "$2" ] ; then
+                                try=''
+                                break
+                        fi
+                        ;;
+ 
+                        'removed')
+                        if [ ! -f "$2" ] ; then
+                                try=''
+                                break
+                        fi
+                        ;;
+                esac
+ 
+                #echo -n .
+                try=`expr $try + 1`
+                sleep 1
+        done
+}
+ 
+status(){
+	isRunning
+	isAlive=$?
+ 
+	if [ "${isAlive}" -eq $TRUE ]; then
+                echo "$PIDNAME found running with processes:  `pidof $PS`"
+        else
+                echo "$PIDNAME is NOT running."
+        fi
+ 
+ 
+}
+ 
+removePIDFile(){
+	if [ $1 ]; then
+                if [ -f $1 ]; then
+        	        rm -f $1
+	        fi
+        else
+		#Do default removal
+		if [ -f $PIDSPATH/$PIDFILE ]; then
+        	        rm -f $PIDSPATH/$PIDFILE
+	        fi
+        fi
+}
+ 
+start() {
+        log_daemon_msg "Starting $DESCRIPTION"
+ 
+	isRunning
+	isAlive=$?
+ 
+        if [ "${isAlive}" -eq $TRUE ]; then
+                log_end_msg $SCRIPT_ERROR
+        else
+                start-stop-daemon --start --quiet --chuid $RUNAS --pidfile $PIDSPATH/$PIDFILE --exec $DAEMON \
+                -- -c $NGINX_CONF_FILE
+                setFilePerms
+                log_end_msg $SCRIPT_OK
+        fi
+}
+ 
+stop() {
+	log_daemon_msg "Stopping $DESCRIPTION"
+ 
+	isRunning
+	isAlive=$?
+        if [ "${isAlive}" -eq $TRUE ]; then
+                start-stop-daemon --stop --quiet --pidfile $PIDSPATH/$PIDFILE
+ 
+		wait_for_pid 'removed' $PIDSPATH/$PIDFILE
+ 
+                if [ -n "$try" ] ; then
+                        log_end_msg $SCRIPT_ERROR
+                else
+                        removePIDFile
+	                log_end_msg $SCRIPT_OK
+                fi
+ 
+        else
+                log_end_msg $SCRIPT_ERROR
+        fi
+}
+ 
+reload() {
+	configtest || return $?
+ 
+	log_daemon_msg "Reloading (via HUP) $DESCRIPTION"
+ 
+        isRunning
+        if [ $? -eq $TRUE ]; then
+		`killall -HUP $PS` #to be safe
+ 
+                log_end_msg $SCRIPT_OK
+        else
+                log_end_msg $SCRIPT_ERROR
+        fi
+}
+ 
+quietupgrade() {
+	log_daemon_msg "Peforming Quiet Upgrade $DESCRIPTION"
+ 
+        isRunning
+        isAlive=$?
+        if [ "${isAlive}" -eq $TRUE ]; then
+		kill -USR2 `cat $PIDSPATH/$PIDFILE`
+		kill -WINCH `cat $PIDSPATH/$PIDFILE.oldbin`
+ 
+		isRunning
+		isAlive=$?
+		if [ "${isAlive}" -eq $TRUE ]; then
+			kill -QUIT `cat $PIDSPATH/$PIDFILE.oldbin`
+			wait_for_pid 'removed' $PIDSPATH/$PIDFILE.oldbin
+                        removePIDFile $PIDSPATH/$PIDFILE.oldbin
+ 
+			log_end_msg $SCRIPT_OK
+		else
+			log_end_msg $SCRIPT_ERROR
+ 
+			log_daemon_msg "ERROR! Reverting back to original $DESCRIPTION"
+ 
+			kill -HUP `cat $PIDSPATH/$PIDFILE`
+			kill -TERM `cat $PIDSPATH/$PIDFILE.oldbin`
+			kill -QUIT `cat $PIDSPATH/$PIDFILE.oldbin`
+ 
+			wait_for_pid 'removed' $PIDSPATH/$PIDFILE.oldbin
+                        removePIDFile $PIDSPATH/$PIDFILE.oldbin
+ 
+			log_end_msg $SCRIPT_ok
+		fi
+        else
+                log_end_msg $SCRIPT_ERROR
+        fi
+}
+ 
+terminate() {
+        log_daemon_msg "Force terminating (via KILL) $DESCRIPTION"
+ 
+	PIDS=`pidof $PS` || true
+ 
+	[ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`
+ 
+	for i in $PIDS; do
+		if [ "$i" = "$PIDS2" ]; then
+	        	kill $i
+                        wait_for_pid 'removed' $PIDSPATH/$PIDFILE
+			removePIDFile
+		fi
+	done
+ 
+	log_end_msg $SCRIPT_OK
+}
+ 
+destroy() {
+	log_daemon_msg "Force terminating and may include self (via KILLALL) $DESCRIPTION"
+	killall $PS -q >> /dev/null 2>&1
+	log_end_msg $SCRIPT_OK
+}
+ 
+pidof_daemon() {
+    PIDS=`pidof $PS` || true
+ 
+    [ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`
+ 
+    for i in $PIDS; do
+        if [ "$i" = "$PIDS2" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
+ 
+case "$1" in
+  start)
+	start
+        ;;
+  stop)
+	stop
+        ;;
+  restart|force-reload)
+	stop
+	sleep 3 
+	start
+        ;;
+  reload)
+	$1
+	;;
+  status)
+	status
+	;;
+  configtest)
+        $1
+        ;;
+  quietupgrade)
+	$1
+	;;
+  terminate)
+	$1
+	;;
+  destroy)
+	$1
+	;;
+  *)
+	FULLPATH=/etc/init.d/$PS
+	echo "Usage: $FULLPATH {start|stop|restart|force-reload|status|configtest|quietupgrade|terminate|destroy}"
+	echo "       The 'destroy' command should only be used as a last resort." 
+	exit 1
+	;;
+esac
+ 
+exit 0

+ 102 - 0
init/Redis-server-init-CentOS

@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# redis - this script starts and stops the redis-server daemon
+#
+# chkconfig:   - 85 15 
+# description:  Redis is a persistent key-value database
+# processname: redis-server
+# config:      /usr/local/redis/etc/redis.conf 
+# config:      /etc/sysconfig/redis
+# pidfile:     /var/run/redis.pid
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ "$NETWORKING" = "no" ] && exit 0
+
+redis="/usr/local/redis/bin/redis-server"
+prog=$(basename $redis)
+
+REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf"
+
+[ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis
+
+lockfile=/var/lock/subsys/redis
+
+start() {
+    [ -x $redis ] || exit 5
+    [ -f $REDIS_CONF_FILE ] || exit 6
+    echo -n $"Starting $prog: "
+    daemon $redis $REDIS_CONF_FILE
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc $prog -QUIT
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+reload() {
+    echo -n $"Reloading $prog: "
+    killproc $redis -HUP
+    RETVAL=$?
+    echo
+}
+
+force_reload() {
+    restart
+}
+
+rh_status() {
+    status $prog
+}
+
+rh_status_q() {
+    rh_status >/dev/null 2>&1
+}
+
+case "$1" in
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart|configtest)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
+        $1
+        ;;
+    force-reload)
+        force_reload
+        ;;
+    status)
+        rh_status
+        ;;
+    condrestart|try-restart)
+        rh_status_q || exit 0
+	    ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+        exit 2
+esac

+ 60 - 0
init/Redis-server-init-Ubuntu

@@ -0,0 +1,60 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:		redis-server
+# Required-Start:	$syslog
+# Required-Stop:	$syslog
+# Should-Start:		$local_fs
+# Should-Stop:		$local_fs
+# Default-Start:	2 3 4 5
+# Default-Stop:		0 1 6
+# Short-Description:	redis-server - Persistent key-value db
+# Description:		redis-server - Persistent key-value db
+### END INIT INFO
+
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/redis/bin/redis-server
+DAEMON_ARGS=/usr/local/redis/etc/redis.conf
+NAME=redis-server
+DESC=redis-server
+PIDFILE=/var/run/redis.pid
+
+test -x $DAEMON || exit 0
+test -x $DAEMONBOOTSTRAP || exit 0
+
+set -e
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+	touch $PIDFILE
+	chown redis:redis $PIDFILE
+	if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
+	then
+		echo "$NAME."
+	else
+		echo "failed"
+	fi
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
+	then
+		echo "$NAME."
+	else
+		echo "failed"
+	fi
+	rm -f $PIDFILE
+	;;
+
+  restart|force-reload)
+	${0} stop
+	${0} start
+	;;
+  *)
+	echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0

+ 109 - 0
init/Tomcat-init

@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# chkconfig: - 95 15 
+# description: Tomcat start/stop/status script
+
+#Location of JAVA_HOME (bin files)
+export JAVA_HOME=
+
+#Add Java binary files to PATH
+export PATH=$JAVA_HOME/bin:$PATH
+
+#CATALINA_HOME is the location of the configuration files of this instance of Tomcat
+CATALINA_HOME=/usr/local/tomcat
+
+#TOMCAT_USER is the default user of tomcat
+TOMCAT_USER=www
+
+#TOMCAT_USAGE is the message if this script is called without any options
+TOMCAT_USAGE="Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;32mstatus\e[00m|\e[00;31mrestart\e[00m}"
+
+#SHUTDOWN_WAIT is wait time in seconds for java proccess to stop
+SHUTDOWN_WAIT=20
+
+tomcat_pid() {
+        echo `ps -ef | grep $CATALINA_HOME | grep -v grep | tr -s " "|cut -d" " -f2`
+}
+
+start() {
+  pid=$(tomcat_pid)
+  if [ -n "$pid" ];then
+    echo -e "\e[00;31mTomcat is already running (pid: $pid)\e[00m"
+  else
+    echo -e "\e[00;32mStarting tomcat\e[00m"
+    if [ `user_exists $TOMCAT_USER` = "1" ];then
+      su $TOMCAT_USER -c $CATALINA_HOME/bin/startup.sh
+    else
+      $CATALINA_HOME/bin/startup.sh
+    fi
+    status
+  fi
+  return 0
+}
+
+status(){
+  pid=$(tomcat_pid)
+  if [ -n "$pid" ];then
+    echo -e "\e[00;32mTomcat is running with pid: $pid\e[00m"
+  else
+    echo -e "\e[00;31mTomcat is not running\e[00m"
+  fi
+}
+
+stop() {
+  pid=$(tomcat_pid)
+  if [ -n "$pid" ];then
+    echo -e "\e[00;31mStoping Tomcat\e[00m"
+        $CATALINA_HOME/bin/shutdown.sh
+
+    let kwait=$SHUTDOWN_WAIT
+    count=0;
+    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
+    do
+      echo -n -e "\e[00;31mwaiting for processes to exit\e[00m\n";
+      sleep 1
+      let count=$count+1;
+    done
+
+    if [ $count -gt $kwait ];then
+      echo -n -e "\n\e[00;31mkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\e[00m"
+      kill -9 $pid
+    fi
+  else
+    echo -e "\e[00;31mTomcat is not running\e[00m"
+  fi
+
+  return 0
+}
+
+user_exists(){
+  if id -u $1 >/dev/null 2>&1; then
+    echo "1"
+  else
+    echo "0"
+  fi
+}
+
+case $1 in
+        start)
+          start
+        ;;
+
+        stop)  
+          stop
+        ;;
+
+        restart)
+          stop
+          start
+        ;;
+
+        status)
+	  status
+        ;;
+
+        *)
+	  echo -e $TOMCAT_USAGE
+        ;;
+esac    
+exit 0

+ 96 - 0
init/hhvm-init-CentOS6

@@ -0,0 +1,96 @@
+#!/bin/sh
+#
+# hhvm        Starts The HHVM FastCGI Daemon
+#
+# chkconfig: - 85 15
+# description: Starts The HHVM FastCGI Daemon
+# processname: hhvm
+# config: /etc/hhvm/server.ini
+# config: /etc/sysconfig/hhvm
+# pidfile: /var/run/hhvm/hhvm.pid
+#
+### BEGIN INIT INFO
+# Provides: hhvm
+# Short-Description: start and stop the HHVM FastCGI Daemon
+# Description: Starts The HHVM FastCGI Daemon
+### END INIT INFO
+
+# Standard LSB functions
+#. /lib/lsb/init-functions
+
+# Source function library.
+. /etc/init.d/functions
+
+# Check that networking is up.
+. /etc/sysconfig/network
+
+if [ "$NETWORKING" = "no" ]
+then
+	exit 0
+fi
+
+RETVAL=0
+HHVM=/usr/bin/hhvm
+prog="hhvm"
+pidfile=${PIDFILE-/var/run/hhvm/pid}
+lockfile=${LOCKFILE-/var/run/hhvm/lock}
+
+CONFIG_HDF_FILE="/etc/hhvm/config.hdf"
+CONFIG_FILE="/etc/hhvm/server.ini"
+SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini"
+MODE=server
+USER=www
+ARGS="--config ${CONFIG_FILE} --config ${SYSTEM_CONFIG_FILE} --config ${CONFIG_HDF_FILE}"
+
+if [ -f /etc/sysconfig/hhvm ]; then
+	. /etc/sysconfig/hhvm
+fi
+
+
+start() {
+	echo -n $"Starting $prog: "
+	dir=$(dirname ${pidfile})
+	[ -d $dir ] || { mkdir $dir; chown $USER:$USER $dir; }
+	daemon ${HHVM} --mode ${MODE} --user ${USER} ${ARGS}
+	RETVAL=$?
+	echo
+	[ $RETVAL -eq 0 ] && touch ${lockfile}
+}
+
+
+stop() {
+	echo -n $"Stopping $prog: "
+	killproc -p ${pidfile} ${HHVM}
+	RETVAL=$?
+	echo
+	if [ $RETVAL -eq 0 ] ; then
+		rm -f ${lockfile} ${pidfile}
+	fi
+}
+
+restart () {
+	stop
+	start
+}
+
+# See how we were called.
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  status)
+        status -p ${pidfile} ${HHVM}
+        RETVAL=$?
+        ;;
+  restart)
+	restart
+        ;;
+  *)
+        echo $"Usage: $prog {start|stop|status|restart}"
+        RETVAL=2
+esac
+
+exit $RETVAL

+ 250 - 0
init/init_CentOS.sh

@@ -0,0 +1,250 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+cd src
+. ../functions/download.sh
+
+# add swapfile
+Mem=`free -m | awk '/Mem:/{print $2}'`
+Swap=`free -m | awk '/Swap:/{print $2}'`
+if [ "$Swap" == '0' ] ;then
+if [ $Mem -le 1024 ];then
+        dd if=/dev/zero of=/swapfile count=1024 bs=1M
+        mkswap /swapfile
+        swapon /swapfile
+        chmod 600 /swapfile
+elif [ $Mem -gt 1024 -a $Mem -le 2048 ];then
+        dd if=/dev/zero of=/swapfile count=2048 bs=1M
+        mkswap /swapfile
+        swapon /swapfile
+        chmod 600 /swapfile
+fi
+cat >> /etc/fstab << EOF
+/swapfile    swap    swap    defaults    0 0
+EOF
+fi
+
+sed -i 's@^exclude@#exclude@' /etc/yum.conf
+yum clean all
+
+#if [ -n "`grep ' 7\.' /etc/redhat-release`" ];then
+#        if [ -n "`grep 'Red Hat' /etc/redhat-release`" ];then
+#                /bin/mv /etc/yum.repos.d/CentOS-Base.repo{,_bk}
+#                wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
+#                sed -i 's@\$releasever@7@g' /etc/yum.repos.d/CentOS-Base.repo
+#                sed -i 's@gpgcheck=1@gpgcheck=0@g' /etc/yum.repos.d/CentOS-Base.repo
+#        fi
+#elif [ -n "`grep ' 6\.' /etc/redhat-release`" ];then
+#        if [ -n "`grep 'Red Hat' /etc/redhat-release`" ];then
+#        	/bin/mv /etc/yum.repos.d/CentOS-Base.repo{,_bk}
+#		wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
+#		sed -i 's@\$releasever@6@g' /etc/yum.repos.d/CentOS-Base.repo
+#                sed -i 's@gpgcheck=1@gpgcheck=0@g' /etc/yum.repos.d/CentOS-Base.repo
+#	fi
+#elif [ -n "`grep ' 5\.' /etc/redhat-release`" ];then
+#        if [ -n "`grep 'Red Hat' /etc/redhat-release`" ];then
+#        	/bin/mv /etc/yum.repos.d/CentOS-Base.repo{,_bk}
+#		wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
+#		sed -i 's@\$releasever@5@g' /etc/yum.repos.d/CentOS-Base.repo
+#                sed -i 's@gpgcheck=1@gpgcheck=0@g' /etc/yum.repos.d/CentOS-Base.repo
+#	fi
+#fi
+
+yum makecache
+
+if [ -n "`grep ' 7\.' /etc/redhat-release`" ];then
+	yum -y install iptables-services 
+	systemctl mask firewalld.service
+	systemctl enable iptables.service
+elif [ -n "`grep ' 6\.' /etc/redhat-release`" ];then
+	yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server" "Office Suite and Productivity" "E-mail server" "Ruby Support" "Printing client" 
+elif [ -n "`grep ' 5\.' /etc/redhat-release`" ];then
+	yum -y groupremove "FTP Server" "Windows File Server" "PostgreSQL Database" "News Server" "MySQL Database" "DNS Name Server" "Web Server" "Dialup Networking Support" "Mail Server" "Ruby" "Office/Productivity" "Sound and Video" "Printing Support" "OpenFabrics Enterprise Distribution"
+fi
+
+yum check-update
+
+# check upgrade OS
+[ "$upgrade_yn" == 'y' ] && yum -y upgrade
+
+cd /etc/yum.repos.d/
+if [ -e "CentOS-Base.repo" -a ! -e "centos.repo" ];then
+	rename repo repo_bk *.repo
+	/bin/mv CentOS-Base.repo{_bk,}
+elif [ -e "CentOS-Base.repo" -a -e "centos.repo" ];then
+	rename repo repo_bk *.repo
+	/bin/mv centos.repo{_bk,}
+fi
+cd -
+
+# Install needed packages
+for Package in gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libaio readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libxslt-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel zip unzip ntpdate sysstat patch bc expect rsync git
+do
+	yum -y install $Package
+done
+
+yum -y update bash openssl glibc
+
+# use gcc-4.4
+if [ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ];then
+        yum -y install gcc44 gcc44-c++ libstdc++44-devel
+	export CC="gcc44" CXX="g++44"
+fi
+
+# check sendmail
+#[ "$sendmail_yn" == 'y' ] && yum -y install sendmail && service sendmail restart
+
+# closed Unnecessary services and remove obsolete rpm package
+for Service in `chkconfig --list | grep 3:on | awk '{print $1}'`;do chkconfig --level 3 $Service off;done
+for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog sendmail;do chkconfig --level 3 $Service on;done
+
+# Close SELINUX
+setenforce 0
+sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
+
+# initdefault
+sed -i 's/^id:.*$/id:3:initdefault:/' /etc/inittab
+init q
+
+# PS1
+[ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo 'PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\$ "' >> ~/.bashrc 
+
+# history size 
+sed -i 's/^HISTSIZE=.*$/HISTSIZE=100/' /etc/profile
+[ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+
+# /etc/security/limits.conf
+[ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <<EOF
+* soft nproc 65535
+* hard nproc 65535
+* soft nofile 65535
+* hard nofile 65535
+EOF
+[ -z "`cat /etc/rc.local | grep 'ulimit -SH 65535'`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
+
+# /etc/hosts
+[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts
+
+# Set timezone
+rm -rf /etc/localtime
+ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+# Set DNS
+#cat > /etc/resolv.conf << EOF
+#nameserver 114.114.114.114 
+#nameserver 8.8.8.8 
+#EOF
+
+# Wrong password five times locked 180s
+[ -z "`cat /etc/pam.d/system-auth | grep 'pam_tally2.so'`" ] && sed -i '4a auth        required      pam_tally2.so deny=5 unlock_time=180' /etc/pam.d/system-auth
+
+# alias vi
+[ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@alias mv=\(.*\)@alias mv=\1\nalias vi=vim@" ~/.bashrc && echo 'syntax on' >> /etc/vimrc
+
+# /etc/sysctl.conf
+sed -i 's/net.ipv4.tcp_syncookies.*$/net.ipv4.tcp_syncookies = 1/g' /etc/sysctl.conf
+[ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
+fs.file-max=65535
+net.ipv4.tcp_fin_timeout = 30 
+net.ipv4.tcp_tw_reuse = 1
+net.ipv4.tcp_tw_recycle = 1
+net.ipv4.ip_local_port_range = 1024 65000
+net.ipv4.tcp_max_syn_backlog = 65536 
+net.ipv4.tcp_max_tw_buckets = 20000
+net.ipv4.route.gc_timeout = 100
+net.ipv4.tcp_syn_retries = 1
+net.ipv4.tcp_synack_retries = 1
+net.core.somaxconn = 65535 
+net.core.netdev_max_backlog = 262144
+net.ipv4.tcp_timestamps = 0
+net.ipv4.tcp_max_orphans = 262144
+EOF
+sysctl -p
+
+if [ -n "`grep ' 5\.' /etc/redhat-release`" ];then
+	sed -i 's@^[3-6]:2345:respawn@#&@g' /etc/inittab
+	sed -i 's@^ca::ctrlaltdel@#&@' /etc/inittab
+	sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
+elif [ -n "`grep ' 6\.' /etc/redhat-release`" ];then
+	sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init	
+	sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf
+fi
+init q
+
+# Update time
+ntpdate pool.ntp.org 
+[ -z "`grep 'pool.ntp.org' /var/spool/cron/root`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root;chmod 600 /var/spool/cron/root; }
+service crond restart
+
+# iptables
+if [ -e '/etc/sysconfig/iptables' ] && [ -n "`grep ':INPUT DROP' /etc/sysconfig/iptables`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/sysconfig/iptables`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables`" ];then
+	IPTABLES_STATUS=yes
+else
+	IPTABLES_STATUS=no
+fi 
+
+if [ "$IPTABLES_STATUS" == 'no' ];then
+cat > /etc/sysconfig/iptables << EOF
+# Firewall configuration written by system-config-securitylevel
+# Manual customization of this file is not recommended.
+*filter
+:INPUT DROP [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+:syn-flood - [0:0]
+-A INPUT -i lo -j ACCEPT
+-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
+-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
+-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
+-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood
+-A INPUT -j REJECT --reject-with icmp-host-prohibited
+-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN
+-A syn-flood -j REJECT --reject-with icmp-port-unreachable
+COMMIT
+EOF
+fi
+
+FW_PORT_FLAG=`grep -ow "dport $SSH_PORT" /etc/sysconfig/iptables`
+[ -z "$FW_PORT_FLAG" -a "$SSH_PORT" != '22' ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport $SSH_PORT -j ACCEPT@" /etc/sysconfig/iptables 
+service iptables restart
+service sshd restart
+
+# install tmux
+if [ ! -e "`which tmux`" ];then
+	src_url=http://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz && Download_src 
+	src_url=http://downloads.sourceforge.net/project/tmux/tmux/tmux-2.0/tmux-2.0.tar.gz && Download_src 
+	tar xzf libevent-2.0.22-stable.tar.gz
+	cd libevent-2.0.22-stable
+	./configure
+	make && make install
+	cd ..
+
+	tar xzf tmux-2.0.tar.gz
+	cd tmux-2.0
+	CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
+	make && make install
+	cd ..
+
+	if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then
+	    ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
+	else
+	    ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
+	fi
+fi
+
+# install htop
+if [ ! -e "`which htop`" ];then
+	src_url=http://hisham.hm/htop/releases/1.0.3/htop-1.0.3.tar.gz && Download_src 
+	tar xzf htop-1.0.3.tar.gz
+	cd htop-1.0.3
+	./configure
+	make && make install
+	cd ..
+fi
+cd ..
+. /etc/profile
+. ~/.bashrc

+ 145 - 0
init/init_Debian.sh

@@ -0,0 +1,145 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+# add swapfile
+Mem=`free -m | awk '/Mem:/{print $2}'`
+Swap=`free -m | awk '/Swap:/{print $2}'`
+if [ "$Swap" == '0' ] ;then
+if [ $Mem -le 1024 ];then
+        dd if=/dev/zero of=/swapfile count=1024 bs=1M
+        mkswap /swapfile
+        swapon /swapfile
+        chmod 600 /swapfile
+elif [ $Mem -gt 1024 -a $Mem -le 2048 ];then
+        dd if=/dev/zero of=/swapfile count=2048 bs=1M
+        mkswap /swapfile
+        swapon /swapfile
+        chmod 600 /swapfile
+fi
+cat >> /etc/fstab << EOF
+/swapfile    swap    swap    defaults    0 0
+EOF
+fi
+
+for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*
+do
+        apt-get -y remove --purge $Package
+done
+dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
+
+apt-get -y update
+
+# check upgrade OS
+[ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 
+
+# Install needed packages
+for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev locales libcloog-ppl0 patch vim zip unzip tmux htop wget bc expect rsync git
+do
+	apt-get -y install $Package
+done
+
+# PS1
+[ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc 
+
+# history size 
+[ -z "`cat ~/.bashrc | grep ^HISTSIZE`" ] && echo 'HISTSIZE=100' >> ~/.bashrc 
+[ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+
+# /etc/security/limits.conf
+[ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <<EOF
+* soft nproc 65535
+* hard nproc 65535
+* soft nofile 65535
+* hard nofile 65535
+EOF
+[ -z "`cat /etc/rc.local | grep 'ulimit -SH 65535'`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
+
+# /etc/hosts
+[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts
+
+# Set timezone
+rm -rf /etc/localtime
+ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+# Set DNS
+#cat > /etc/resolv.conf << EOF
+#nameserver 114.114.114.114
+#nameserver 8.8.8.8
+#EOF
+
+# alias vi
+[ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@^alias l=\(.*\)@alias l=\1\nalias vi='vim'@" ~/.bashrc
+[ -z "`cat /etc/vim/vimrc | grep 'syntax on'`" ] && echo 'syntax on' >> /etc/vim/vimrc
+sed -i 's@^# export LS_OPTIONS@export LS_OPTIONS@' ~/.bashrc
+sed -i 's@^# alias@alias@g' ~/.bashrc
+
+# /etc/sysctl.conf
+[ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
+fs.file-max=65535
+net.ipv4.tcp_syncookies = 1
+net.ipv4.tcp_fin_timeout = 30
+net.ipv4.tcp_tw_reuse = 1
+net.ipv4.tcp_tw_recycle = 1
+net.ipv4.ip_local_port_range = 1024 65000
+net.ipv4.tcp_max_syn_backlog = 65536 
+net.ipv4.tcp_max_tw_buckets = 20000
+net.ipv4.route.gc_timeout = 100
+net.ipv4.tcp_syn_retries = 1
+net.ipv4.tcp_synack_retries = 1
+net.core.somaxconn = 65535 
+net.core.netdev_max_backlog = 262144
+net.ipv4.tcp_timestamps = 0
+net.ipv4.tcp_max_orphans = 262144
+EOF
+sysctl -p
+
+sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup 
+sed -i 's@^[3-6]:23:respawn@#&@g' /etc/inittab
+sed -i "s@^ctrlaltdel@#&@" /etc/inittab
+sed -i 's@^# en_US.UTF-8@en_US.UTF-8@' /etc/locale.gen
+init q
+
+# Update time
+ntpdate pool.ntp.org 
+[ -z "`grep 'pool.ntp.org' /var/spool/cron/root`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; }
+service cron restart
+
+# iptables
+if [ -e '/etc/iptables.up.rules' ] && [ -n "`grep ':INPUT DROP' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules`" ];then
+        IPTABLES_STATUS=yes
+else
+        IPTABLES_STATUS=no
+fi
+
+if [ "$IPTABLES_STATUS" == 'no' ];then
+cat > /etc/iptables.up.rules << EOF
+# Firewall configuration written by system-config-securitylevel
+# Manual customization of this file is not recommended.
+*filter
+:INPUT DROP [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+:syn-flood - [0:0]
+-A INPUT -i lo -j ACCEPT
+-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
+-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
+-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
+-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood
+-A INPUT -j REJECT --reject-with icmp-host-prohibited
+-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN
+-A syn-flood -j REJECT --reject-with icmp-port-unreachable
+COMMIT
+EOF
+fi
+
+FW_PORT_FLAG=`grep -ow "dport $SSH_PORT" /etc/iptables.up.rules` 
+[ -z "$FW_PORT_FLAG" -a "$SSH_PORT" != '22' ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport $SSH_PORT -j ACCEPT@" /etc/iptables.up.rules 
+iptables-restore < /etc/iptables.up.rules
+echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> /etc/network/interfaces
+service ssh restart
+
+. ~/.bashrc

+ 164 - 0
init/init_Ubuntu.sh

@@ -0,0 +1,164 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+cd src
+. ../functions/download.sh
+
+# add swapfile
+Mem=`free -m | awk '/Mem:/{print $2}'`
+Swap=`free -m | awk '/Swap:/{print $2}'`
+if [ "$Swap" == '0' ] ;then
+if [ $Mem -le 1024 ];then
+        dd if=/dev/zero of=/swapfile count=1024 bs=1M
+        mkswap /swapfile
+        swapon /swapfile
+        chmod 600 /swapfile
+elif [ $Mem -gt 1024 -a $Mem -le 2048 ];then
+        dd if=/dev/zero of=/swapfile count=2048 bs=1M
+        mkswap /swapfile
+        swapon /swapfile
+        chmod 600 /swapfile
+fi
+cat >> /etc/fstab << EOF
+/swapfile    swap    swap    defaults    0 0
+EOF
+fi
+
+for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*
+do
+        apt-get -y remove --purge $Package
+done
+dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
+
+apt-get -y update
+
+# check upgrade OS
+[ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 
+
+# Install needed packages
+for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev patch vim zip unzip tmux htop wget bc expect rsync git
+do
+	apt-get -y install $Package
+done
+
+if [ -n "`cat /etc/issue | grep -E 14`" ];then
+	apt-get -y install libcloog-ppl1
+	apt-get -y remove bison
+	src_url=http://ftp.gnu.org/gnu/bison/bison-2.7.1.tar.gz && Download_src 
+	tar xzf bison-2.7.1.tar.gz
+	cd bison-2.7.1
+	./configure
+	make && make install
+	cd ..
+	rm -rf bison-2.7.1
+	ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype
+elif [ -n "`cat /etc/issue | grep -E 13`" ];then
+	apt-get -y install bison libcloog-ppl1
+elif [ -n "`cat /etc/issue | grep -E 12`" ];then
+	apt-get -y install bison libcloog-ppl0
+fi
+
+# check sendmail
+#[ "$sendmail_yn" == 'y' ] && apt-get -y install sendmail
+
+# PS1
+[ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc 
+
+# history size 
+sed -i 's/HISTSIZE=.*$/HISTSIZE=100/g' ~/.bashrc 
+[ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+
+# /etc/security/limits.conf
+[ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <<EOF
+* soft nproc 65535
+* hard nproc 65535
+* soft nofile 65535
+* hard nofile 65535
+EOF
+[ -z "`cat /etc/rc.local | grep 'ulimit -SH 65535'`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
+
+# /etc/hosts
+[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts
+
+# Set timezone
+rm -rf /etc/localtime
+ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+# Set DNS
+#cat > /etc/resolv.conf << EOF
+#nameserver 114.114.114.114
+#nameserver 8.8.8.8
+#EOF
+
+# alias vi
+[ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@^alias l=\(.*\)@alias l=\1\nalias vi='vim'@" ~/.bashrc
+
+# /etc/sysctl.conf
+[ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
+fs.file-max=65535
+net.ipv4.tcp_syncookies = 1
+net.ipv4.tcp_fin_timeout = 30 
+net.ipv4.tcp_tw_reuse = 1
+net.ipv4.tcp_tw_recycle = 1
+net.ipv4.ip_local_port_range = 1024 65000
+net.ipv4.tcp_max_syn_backlog = 65536 
+net.ipv4.tcp_max_tw_buckets = 20000
+net.ipv4.route.gc_timeout = 100
+net.ipv4.tcp_syn_retries = 1
+net.ipv4.tcp_synack_retries = 1
+net.core.somaxconn = 65535 
+net.core.netdev_max_backlog = 262144
+net.ipv4.tcp_timestamps = 0
+net.ipv4.tcp_max_orphans = 262144
+EOF
+sysctl -p
+
+sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup 
+sed -i 's@^@#@g' /etc/init/tty[3-6].conf
+echo 'en_US.UTF-8 UTF-8' > /var/lib/locales/supported.d/local
+sed -i 's@^@#@g' /etc/init/control-alt-delete.conf 
+
+# Update time
+ntpdate pool.ntp.org 
+[ -z "`grep 'pool.ntp.org' /var/spool/cron/root`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; } 
+service cron restart
+
+# iptables
+if [ -e '/etc/iptables.up.rules' ] && [ -n "`grep ':INPUT DROP' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules`" ];then
+        IPTABLES_STATUS=yes
+else
+        IPTABLES_STATUS=no
+fi
+
+if [ "$IPTABLES_STATUS" == 'no' ];then
+cat > /etc/iptables.up.rules << EOF
+# Firewall configuration written by system-config-securitylevel
+# Manual customization of this file is not recommended.
+*filter
+:INPUT DROP [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+:syn-flood - [0:0]
+-A INPUT -i lo -j ACCEPT
+-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
+-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
+-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
+-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood
+-A INPUT -j REJECT --reject-with icmp-host-prohibited
+-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN
+-A syn-flood -j REJECT --reject-with icmp-port-unreachable
+COMMIT
+EOF
+fi
+
+FW_PORT_FLAG=`grep -ow "dport $SSH_PORT" /etc/iptables.up.rules` 
+[ -z "$FW_PORT_FLAG" -a "$SSH_PORT" != '22' ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport $SSH_PORT -j ACCEPT@" /etc/iptables.up.rules 
+iptables-restore < /etc/iptables.up.rules
+echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> /etc/network/interfaces
+service ssh restart
+
+. ~/.bashrc

+ 733 - 0
install.sh

@@ -0,0 +1,733 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+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
+}
+
+#get pwd
+sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
+
+# get local ip address
+local_IP=`./functions/get_local_ip.py`
+
+# import apps version
+. ./apps.conf
+
+# Definition Directory
+. ./options.conf
+. functions/check_os.sh
+mkdir -p $home_dir/default $wwwlogs_dir $oneinstack_dir/{src,conf}
+
+# choice upgrade OS
+while :
+do
+	echo
+        read -p "Do you want to upgrade operating system? [y/n]: " upgrade_yn
+        if [ "$upgrade_yn" != 'y' -a "$upgrade_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+		[ -e init/init_*.ed -a "$upgrade_yn" == 'y' ] && { echo -e "\033[31mYour system is already upgraded! \033[0m" ; upgrade_yn=n ; }
+                # check sendmail
+		#if [ "$OS" != 'Debian' ];then
+	        #        while :
+	        #        do
+	        #                echo
+	        #                read -p "Do you want to install sendmail? [y/n]: " sendmail_yn
+	        #                if [ "$sendmail_yn" != 'y' -a "$sendmail_yn" != 'n' ];then
+	        #                        echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+	        #                else
+	        #                        break
+	        #                fi
+	        #        done
+		#fi
+                break
+        fi
+done
+
+# Use default SSH port 22. If you use another SSH port on your server
+[ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
+while :
+do
+        echo
+        read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT 
+	[ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port
+        if [ $SSH_PORT -eq 22 >/dev/null 2>&1 -o $SSH_PORT -gt 1024 >/dev/null 2>&1 -a $SSH_PORT -lt 65535 >/dev/null 2>&1 ];then
+                break
+        else
+                echo -e "\033[31minput error! Input range: 22,1024~65535\033[0m"
+        fi
+done
+
+if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "$SSH_PORT" != '22' ];then
+	sed -i "s@^#Port.*@&\nPort $SSH_PORT@" /etc/ssh/sshd_config
+elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ];then
+	sed -i "s@^Port.*@Port $SSH_PORT@" /etc/ssh/sshd_config 
+fi
+
+# check Web server
+while :
+do
+        echo
+        read -p "Do you want to install Web server? [y/n]: " Web_yn
+        if [ "$Web_yn" != 'y' -a "$Web_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                if [ "$Web_yn" == 'y' ];then
+                        [ -d "$web_install_dir/conf" ] && { echo -e "\033[31mThe web service already installed! \033[0m" ; Web_yn=Other ; break ; }
+                        while :
+                        do
+                                echo
+                                echo 'Please select Nginx server:'
+                                echo -e "\t\033[32m1\033[0m. Install Nginx"
+                                echo -e "\t\033[32m2\033[0m. Install Tengine"
+                                echo -e "\t\033[32m3\033[0m. Do not install"
+                                read -p "Please input a number:(Default 1 press Enter) " Nginx_version
+                                [ -z "$Nginx_version" ] && Nginx_version=1
+                                if [ $Nginx_version != 1 -a $Nginx_version != 2 -a $Nginx_version != 3 ];then
+                                        echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+                                else
+				while :
+				do
+                                	echo
+	                                echo 'Please select Apache server:'
+	                                echo -e "\t\033[32m1\033[0m. Install Apache-2.4"
+	                                echo -e "\t\033[32m2\033[0m. Install Apache-2.2"
+	                                echo -e "\t\033[32m3\033[0m. Do not install"
+	                                read -p "Please input a number:(Default 3 press Enter) " Apache_version
+	                                [ -z "$Apache_version" ] && Apache_version=3
+	                                if [ $Apache_version != 1 -a $Apache_version != 2 -a $Apache_version != 3 ];then
+	                                        echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+	                                else
+	                                        break
+	                                fi
+				done
+                                while :
+                                do
+                                        echo
+                                        echo 'Please select tomcat server:'
+                                        echo -e "\t\033[32m1\033[0m. Install Tomcat-8"
+                                        echo -e "\t\033[32m2\033[0m. Install Tomcat-7"
+                                        echo -e "\t\033[32m3\033[0m. Do not install"
+                                        read -p "Please input a number:(Default 3 press Enter) " Tomcat_version
+                                        [ -z "$Tomcat_version" ] && Tomcat_version=3
+                                        if [ $Tomcat_version != 1 -a $Tomcat_version != 2 -a $Tomcat_version != 3 ];then
+                                                echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+                                        else
+					if [ "$Tomcat_version" == '1' ];then
+					while :
+					do
+						echo
+						echo 'Please select JDK version:'
+	                                        echo -e "\t\033[32m1\033[0m. Install JDK-1.8"
+	                                        echo -e "\t\033[32m2\033[0m. Install JDK-1.7"
+						read -p "Please input a number:(Default 2 press Enter) " JDK_version
+						[ -z "$JDK_version" ] && JDK_version=2
+						if [ $JDK_version != 1 -a $JDK_version != 2 ];then
+							echo -e "\033[31minput error! Please only input number 1,2\033[0m"
+						else
+							break
+						fi
+					done
+					fi
+					if [ "$Tomcat_version" == '2' ];then
+                                        while :
+                                        do
+                                                echo
+                                                echo 'Please select JDK version:'
+                                                echo -e "\t\033[32m1\033[0m. Install JDK-1.8"
+                                                echo -e "\t\033[32m2\033[0m. Install JDK-1.7"
+                                                echo -e "\t\033[32m3\033[0m. Install JDK-1.6"
+                                                read -p "Please input a number:(Default 2 press Enter) " JDK_version
+                                                [ -z "$JDK_version" ] && JDK_version=2
+                                                if [ $JDK_version != 1 -a $JDK_version != 2 -a $JDK_version != 3 ];then
+                                                        echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+                                                else
+                                                        break
+                                                fi
+                                        done
+                                        fi
+                                        break
+                                        fi
+                                done
+                                break
+                                fi
+                        done
+                fi
+                break
+        fi
+done
+
+# choice database
+while :
+do
+        echo
+        read -p "Do you want to install Database? [y/n]: " DB_yn
+        if [ "$DB_yn" != 'y' -a "$DB_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                if [ "$DB_yn" == 'y' ];then
+                        [ -d "$db_install_dir/support-files" ] && { echo -e "\033[31mThe database already installed! \033[0m" ; DB_yn=Other ; break ; }
+                        while :
+                        do
+                                echo
+                                echo 'Please select a version of the Database:'
+                                echo -e "\t\033[32m1\033[0m. Install MySQL-5.6"
+                                echo -e "\t\033[32m2\033[0m. Install MySQL-5.5"
+                                echo -e "\t\033[32m3\033[0m. Install MariaDB-10.0"
+                                echo -e "\t\033[32m4\033[0m. Install MariaDB-5.5"
+                                echo -e "\t\033[32m5\033[0m. Install Percona-5.6"
+                                echo -e "\t\033[32m6\033[0m. Install Percona-5.5"
+                                read -p "Please input a number:(Default 1 press Enter) " DB_version
+                                [ -z "$DB_version" ] && DB_version=1
+                                if [ $DB_version != 1 -a $DB_version != 2 -a $DB_version != 3 -a $DB_version != 4 -a $DB_version != 5 -a $DB_version != 6 ];then
+                                        echo -e "\033[31minput error! Please only input number 1,2,3,4,5,6 \033[0m"
+                                else
+                                        while :
+                                        do
+                                                read -p "Please input the root password of database: " dbrootpwd
+						[ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo -e "\033[31minput error,not contain a plus sign (+) and & \033[0m"; continue; }
+                                                (( ${#dbrootpwd} >= 5 )) && sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf && break || echo -e "\033[31mdatabase root password least 5 characters! \033[0m"
+                                        done
+                                        break
+                                fi
+                        done
+                fi
+                break
+        fi
+done
+
+# check PHP
+while :
+do
+echo
+read -p "Do you want to install PHP? [y/n]: " PHP_yn
+if [ "$PHP_yn" != 'y' -a "$PHP_yn" != 'n' ];then
+        echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+else
+        if [ "$PHP_yn" == 'y' ];then
+                [ -d "$php_install_dir/bin" ] && { echo -e "\033[31mThe php already installed! \033[0m" ; PHP_yn=Other ; break ; }
+                while :
+                do
+                        echo
+                        echo 'Please select a version of the PHP:'
+                        echo -e "\t\033[32m1\033[0m. Install php-5.3"
+                        echo -e "\t\033[32m2\033[0m. Install php-5.4"
+                        echo -e "\t\033[32m3\033[0m. Install php-5.5"
+                        echo -e "\t\033[32m4\033[0m. Install php-5.6"
+                        echo -e "\t\033[32m5\033[0m. Install php-7/phpng(alpha)"
+                        read -p "Please input a number:(Default 1 press Enter) " PHP_version
+                        [ -z "$PHP_version" ] && PHP_version=1
+                        if [ $PHP_version != 1 -a $PHP_version != 2 -a $PHP_version != 3 -a $PHP_version != 4 -a $PHP_version != 5 ];then
+                                echo -e "\033[31minput error! Please only input number 1,2,3,4,5 \033[0m"
+                        else
+				while :
+				do
+					echo
+					read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn 
+					if [ "$PHP_cache_yn" != 'y' -a "$PHP_cache_yn" != 'n' ];then
+						echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+					else
+						if [ "$PHP_cache_yn" == 'y' ];then	
+                                                        if [ $PHP_version == 1 ];then
+                                                                while :
+                                                                do
+                                                                        echo 'Please select a opcode cache of the PHP:'
+                                                                        echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
+                                                                        echo -e "\t\033[32m2\033[0m. Install XCache"
+                                                                        echo -e "\t\033[32m3\033[0m. Install APCU"
+                                                                        echo -e "\t\033[32m4\033[0m. Install eAccelerator-0.9"
+                                                                        read -p "Please input a number:(Default 1 press Enter) " PHP_cache
+                                                                        [ -z "$PHP_cache" ] && PHP_cache=1
+                                                                        if [ $PHP_cache != 1 -a $PHP_cache != 2 -a $PHP_cache != 3 -a $PHP_cache != 4 ];then
+                                                                                echo -e "\033[31minput error! Please only input number 1,2,3,4\033[0m"
+                                                                        else
+                                                                                break
+                                                                        fi
+                                                                done
+                                                        fi
+		                                        if [ $PHP_version == 2 ];then
+		                                                while :
+		                                                do
+		                                                        echo 'Please select a opcode cache of the PHP:'
+		                                                        echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
+		                                                        echo -e "\t\033[32m2\033[0m. Install XCache"
+		                                                        echo -e "\t\033[32m3\033[0m. Install APCU"
+		                                                        echo -e "\t\033[32m4\033[0m. Install eAccelerator-1.0-dev"
+		                                                        read -p "Please input a number:(Default 1 press Enter) " PHP_cache
+		                                                        [ -z "$PHP_cache" ] && PHP_cache=1
+		                                                        if [ $PHP_cache != 1 -a $PHP_cache != 2 -a $PHP_cache != 3 -a $PHP_cache != 4 ];then
+		                                                                echo -e "\033[31minput error! Please only input number 1,2,3,4\033[0m"
+		                                                        else
+		                                                                break
+		                                                        fi
+		                                                done
+		                                        fi
+                                                        if [ $PHP_version == 3 ];then
+                                                                while :
+                                                                do
+                                                                        echo 'Please select a opcode cache of the PHP:'
+                                                                        echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
+                                                                        echo -e "\t\033[32m2\033[0m. Install XCache"
+                                                                        echo -e "\t\033[32m3\033[0m. Install APCU"
+                                                                        read -p "Please input a number:(Default 1 press Enter) " PHP_cache
+                                                                        [ -z "$PHP_cache" ] && PHP_cache=1
+                                                                        if [ $PHP_cache != 1 -a $PHP_cache != 2 -a $PHP_cache != 3 ];then
+                                                                                echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+                                                                        else
+                                                                                break
+                                                                        fi
+                                                                done
+                                                        fi
+                                                        if [ $PHP_version == 4 ];then
+                                                                while :
+                                                                do
+                                                                        echo 'Please select a opcode cache of the PHP:'
+                                                                        echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
+		                                                        echo -e "\t\033[32m2\033[0m. Install XCache"
+                                                                        read -p "Please input a number:(Default 1 press Enter) " PHP_cache
+                                                                        [ -z "$PHP_cache" ] && PHP_cache=1
+                                                                        if [ $PHP_cache != 1 -a $PHP_cache != 2 ];then
+                                                                                echo -e "\033[31minput error! Please only input number 1,2\033[0m"
+                                                                        else
+                                                                                break
+                                                                        fi
+                                                                done
+                                                        fi
+							if [ $PHP_version == 5 ];then
+								while :
+                                                                do
+                                                                        echo 'Please select a opcode cache of the PHP:'
+                                                                        echo -e "\t\033[32m1\033[0m. Install Zend OPcache"
+                                                                        read -p "Please input a number:(Default 1 press Enter) " PHP_cache
+                                                                        [ -z "$PHP_cache" ] && PHP_cache=1
+                                                                        if [ $PHP_cache != 1 ];then
+                                                                                echo -e "\033[31minput error! Please only input number 1\033[0m"
+                                                                        else
+                                                                                break
+                                                                        fi
+                                                                done
+							fi
+                                                fi
+						break
+                                        fi
+                                done
+                                if [ "$PHP_cache" == '2' ];then
+                                        while :
+                                        do
+                                                read -p "Please input xcache admin password: " xcache_admin_pass
+                                                (( ${#xcache_admin_pass} >= 5 )) && { xcache_admin_md5_pass=`echo -n "$xcache_admin_pass" | md5sum | awk '{print $1}'` ; break ; } || echo -e "\033[31mxcache admin password least 5 characters! \033[0m"
+                                        done
+                                fi
+				if [ "$PHP_version" != '5' ];then
+                                        while :
+                                        do
+                                                echo
+                                                read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
+                                                if [ "$ZendGuardLoader_yn" != 'y' -a "$ZendGuardLoader_yn" != 'n' ];then
+                                                        echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+                                                else
+                                                        break
+                                                fi
+                                        done
+                                fi
+
+				if [ "$PHP_version" != '5' ];then
+	                                while :
+	                                do
+	                                        echo
+	                                        read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
+	                                        if [ "$ionCube_yn" != 'y' -a "$ionCube_yn" != 'n' ];then
+	                                                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+	                                        else
+	                                                break
+	                                        fi
+	                                done
+				fi
+
+				if [ "$PHP_version" != '5' ];then
+                                while :
+                                do
+                                        echo
+                                        read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
+                                        if [ "$Magick_yn" != 'y' -a "$Magick_yn" != 'n' ];then
+                                                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+                                        else
+                                                break
+                                        fi
+                                done
+				fi
+                                if [ "$Magick_yn" == 'y' ];then
+                                        while :
+                                        do
+                                                echo 'Please select ImageMagick or GraphicsMagick:'
+                                                echo -e "\t\033[32m1\033[0m. Install ImageMagick"
+                                                echo -e "\t\033[32m2\033[0m. Install GraphicsMagick"
+                                                read -p "Please input a number:(Default 1 press Enter) " Magick
+                                                [ -z "$Magick" ] && Magick=1
+                                                if [ $Magick != 1 -a $Magick != 2 ];then
+                                                        echo -e "\033[31minput error! Please only input number 1,2 \033[0m"
+                                                else
+                                                        break
+                                                fi
+                                        done
+                                fi
+                                break
+                        fi
+                done
+        fi
+        break
+fi
+done
+
+# check Pureftpd
+while :
+do
+        echo
+        read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
+        if [ "$FTP_yn" != 'y' -a "$FTP_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                [ "$FTP_yn" == 'y' -a -d "$pureftpd_install_dir/bin" ] && { echo -e "\033[31mThe FTP service already installed! \033[0m" ; FTP_yn=Other ; break ; }
+                break
+        fi
+done
+
+# check phpMyAdmin
+while :
+do
+        echo
+        read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
+        if [ "$phpMyAdmin_yn" != 'y' -a "$phpMyAdmin_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+		if [ "$phpMyAdmin_yn" == 'y' ];then
+		        [ -d "$home_dir/default/phpMyAdmin" ] && echo -e "\033[31mThe phpMyAdmin already installed! \033[0m" && phpMyAdmin_yn=Other && break
+		fi
+                break
+        fi
+done
+
+# check redis
+if [ "$PHP_version" != '5' ];then
+while :
+do
+	echo
+	read -p "Do you want to install redis? [y/n]: " redis_yn
+	if [ "$redis_yn" != 'y' -a "$redis_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+	else
+		if [ "$redis_yn" == 'y' ];then
+			[ -d "$redis_install_dir" ] && { echo -e "\033[31mThe redis already installed! \033[0m" ; redis_yn=Other ; break ; }
+		fi
+		break
+	fi
+done
+
+# check memcached
+while :
+do
+	echo
+        read -p "Do you want to install memcached? [y/n]: " memcached_yn
+        if [ "$memcached_yn" != 'y' -a "$memcached_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+		if [ "$memcached_yn" == 'y' ];then
+			[ -d "$memcached_install_dir/bin" ] && { echo -e "\033[31mThe memcached already installed! \033[0m" ; memcached_yn=Other ; break ; }
+		fi
+                break
+        fi
+done
+fi
+
+# check jemalloc or tcmalloc 
+if [ "$Web_yn" == 'y' -o "$DB_yn" == 'y' ];then
+        while :
+        do
+                echo
+                read -p "Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: " je_tc_malloc_yn
+                if [ "$je_tc_malloc_yn" != 'y' -a "$je_tc_malloc_yn" != 'n' ];then
+                        echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+                else
+                        if [ "$je_tc_malloc_yn" == 'y' ];then
+                                echo 'Please select jemalloc or tcmalloc:'
+                                echo -e "\t\033[32m1\033[0m. jemalloc"
+                                echo -e "\t\033[32m2\033[0m. tcmalloc"
+                                while :
+                                do
+                                        read -p "Please input a number:(Default 1 press Enter) " je_tc_malloc
+                                        [ -z "$je_tc_malloc" ] && je_tc_malloc=1
+                                        if [ $je_tc_malloc != 1 -a $je_tc_malloc != 2 ];then
+                                                echo -e "\033[31minput error! Please only input number 1,2\033[0m"
+                                        else
+                                                break
+                                        fi
+                                done
+                        fi
+                        break
+                fi
+        done
+fi
+
+while :
+do
+        echo
+        read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
+        if [ "$HHVM_yn" != 'y' -a "$HHVM_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                if [ "$HHVM_yn" == 'y' ];then
+                        if [ -e '/etc/redhat-release' ] && [ -n "`grep -E ' 7\.| 6\.5| 6\.6| 6\.7' /etc/redhat-release`" -a -d "/lib64" ];then
+                                break
+                        else
+                                echo -e "\033[31mHHVM only support CentOS6.5+ 64bit, CentOS7 64bit! \033[0m"
+                                echo "Press Ctrl+c to cancel or Press any key to continue..."
+                                echo
+                                char=`get_char`
+                                HHVM_yn=
+                                break
+                        fi
+                elif [ "$HHVM_yn" == 'n' ];then
+                        break
+                fi
+        fi
+done
+
+chmod +x functions/*.sh init/* *.sh
+
+# init
+if [ "$OS" == 'CentOS' ];then
+	. init/init_CentOS.sh 2>&1 | tee $oneinstack_dir/install.log
+	[ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ] && export CC="gcc44" CXX="g++44"
+elif [ "$OS" == 'Debian' ];then
+	. init/init_Debian.sh 2>&1 | tee $oneinstack_dir/install.log
+elif [ "$OS" == 'Ubuntu' ];then
+	. init/init_Ubuntu.sh 2>&1 | tee $oneinstack_dir/install.log
+fi
+
+# jemalloc or tcmalloc
+if [ "$je_tc_malloc_yn" == 'y' -a "$je_tc_malloc" == '1' -a ! -e "/usr/local/lib/libjemalloc.so" ];then
+	. functions/jemalloc.sh
+	Install_jemalloc | tee -a $oneinstack_dir/install.log
+elif [ "$je_tc_malloc_yn" == 'y' -a "$je_tc_malloc" == '2' -a ! -e "/usr/local/lib/libtcmalloc.so" ];then
+	. functions/tcmalloc.sh
+	Install_tcmalloc | tee -a $oneinstack_dir/install.log
+fi
+
+# Database
+if [ "$DB_version" == '1' ];then
+	. functions/mysql-5.6.sh 
+	Install_MySQL-5-6 2>&1 | tee -a $oneinstack_dir/install.log 
+elif [ "$DB_version" == '2' ];then
+        . functions/mysql-5.5.sh
+        Install_MySQL-5-5 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$DB_version" == '3' ];then
+	. functions/mariadb-10.0.sh
+	Install_MariaDB-10-0 2>&1 | tee -a $oneinstack_dir/install.log 
+elif [ "$DB_version" == '4' ];then
+	. functions/mariadb-5.5.sh
+	Install_MariaDB-5-5 2>&1 | tee -a $oneinstack_dir/install.log 
+elif [ "$DB_version" == '5' ];then
+        . functions/percona-5.6.sh
+        Install_Percona-5-6 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$DB_version" == '6' ];then
+	. functions/percona-5.5.sh 
+	Install_Percona-5-5 2>&1 | tee -a $oneinstack_dir/install.log 
+fi
+
+# Apache
+if [ "$Apache_version" == '1' ];then
+	. functions/apache-2.4.sh 
+	Install_Apache-2-4 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$Apache_version" == '2' ];then
+	. functions/apache-2.2.sh 
+	Install_Apache-2-2 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# PHP
+if [ "$PHP_version" == '1' ];then
+	. functions/php-5.3.sh
+	Install_PHP-5-3 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_version" == '2' ];then
+        . functions/php-5.4.sh
+        Install_PHP-5-4 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_version" == '3' ];then
+        . functions/php-5.5.sh
+        Install_PHP-5-5 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_version" == '4' ];then
+        . functions/php-5.6.sh
+        Install_PHP-5-6 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_version" == '5' ];then
+        . functions/php-7.sh
+        Install_PHP-7 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# ImageMagick or GraphicsMagick
+if [ "$Magick" == '1' ];then
+	. functions/ImageMagick.sh
+	Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$Magick" == '2' ];then
+	. functions/GraphicsMagick.sh
+	Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# ionCube
+if [ "$ionCube_yn" == 'y' ];then
+        . functions/ioncube.sh
+        Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# PHP opcode cache
+if [ "$PHP_cache" == '1' ] && [ "$PHP_version" == '1' -o "$PHP_version" == '2' ];then
+        . functions/zendopcache.sh
+        Install_ZendOPcache 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_cache" == '2' ];then
+        . functions/xcache.sh 
+        Install_XCache 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_cache" == '3' ];then
+        . functions/apcu.sh
+        Install_APCU 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_cache" == '4' -a "$PHP_version" == '2' ];then
+        . functions/eaccelerator-1.0-dev.sh
+        Install_eAccelerator-1-0-dev 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$PHP_cache" == '4' -a "$PHP_version" == '1' ];then
+        . functions/eaccelerator-0.9.sh
+        Install_eAccelerator-0-9 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# ZendGuardLoader (php <= 5.6)
+if [ "$ZendGuardLoader_yn" == 'y' ];then
+	. functions/ZendGuardLoader.sh
+        Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# Web server
+if [ "$Nginx_version" == '1' ];then
+        . functions/nginx.sh
+        Install_Nginx 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$Nginx_version" == '2' ];then
+	. functions/tengine.sh
+        Install_Tengine 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# JDK
+if [ "$JDK_version" == '1' ];then
+	. functions/jdk-1.8.sh
+	Install-JDK-1-8 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$JDK_version" == '2' ];then
+        . functions/jdk-1.7.sh
+        Install-JDK-1-7 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$JDK_version" == '3' ];then
+        . functions/jdk-1.6.sh
+        Install-JDK-1-6 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+if [ "$Tomcat_version" == '1' ];then
+        . functions/tomcat-8.sh
+        Install_tomcat-8 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$Tomcat_version" == '2' ];then
+        . functions/tomcat-7.sh
+	Install_tomcat-7 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# Pure-FTPd
+if [ "$FTP_yn" == 'y' ];then
+	. functions/pureftpd.sh
+	Install_PureFTPd 2>&1 | tee -a $oneinstack_dir/install.log 
+fi
+
+# phpMyAdmin
+if [ "$phpMyAdmin_yn" == 'y' ];then
+	. functions/phpmyadmin.sh
+	Install_phpMyAdmin 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# redis
+if [ "$redis_yn" == 'y' ];then
+	. functions/redis.sh
+	Install_redis 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# memcached
+if [ "$memcached_yn" == 'y' ];then
+	. functions/memcached.sh
+	Install_memcached 2>&1 | tee -a $oneinstack_dir/install.log
+fi
+
+# get db_install_dir and web_install_dir
+. ./options.conf
+
+# index example
+if [ ! -e "$home_dir/default/index.html" -a "$Web_yn" == 'y' ];then
+	. functions/test.sh
+	TEST 2>&1 | tee -a $oneinstack_dir/install.log 
+fi
+
+if [ "$HHVM_yn" == 'y' ];then
+	. functions/hhvm_CentOS.sh 
+	Install_hhvm_CentOS 2>&1 | tee -a $oneinstack_dir/install.log 
+fi
+
+echo "####################Congratulations########################"
+[ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`\033[32m$web_install_dir\033[0m"
+[ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`\033[32m$web_install_dir\033[0m\n`printf "%-32s" "Apache install  dir":`\033[32m$apache_install_dir\033[0m" 
+[ "$Web_yn" == 'y' -a "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Apache install dir":`\033[32m$apache_install_dir\033[0m"
+[ "$Tomcat_version" == '1' -o "$Tomcat_version" == '2' ] && echo -e "\n`printf "%-32s" "Tomcat install dir":`\033[32m$tomcat_install_dir\033[0m"
+[ "$DB_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Database install dir:"`\033[32m$db_install_dir\033[0m"
+[ "$DB_yn" == 'y' ] && echo -e "`printf "%-32s" "Database data dir:"`\033[32m$db_data_dir\033[0m"
+[ "$DB_yn" == 'y' ] && echo -e "`printf "%-32s" "Database user:"`\033[32mroot\033[0m"
+[ "$DB_yn" == 'y' ] && echo -e "`printf "%-32s" "Database password:"`\033[32m${dbrootpwd}\033[0m"
+[ "$PHP_yn" == 'y' ] && echo -e "\n`printf "%-32s" "PHP install dir:"`\033[32m$php_install_dir\033[0m"
+[ "$PHP_cache" == '1' ] && echo -e "`printf "%-32s" "Opcache Control Panel url:"`\033[32mhttp://$local_IP/ocp.php\033[0m" 
+[ "$PHP_cache" == '2' ] && echo -e "`printf "%-32s" "xcache Control Panel url:"`\033[32mhttp://$local_IP/xcache\033[0m"
+[ "$PHP_cache" == '2' ] && echo -e "`printf "%-32s" "xcache user:"`\033[32madmin\033[0m"
+[ "$PHP_cache" == '2' ] && echo -e "`printf "%-32s" "xcache password:"`\033[32m$xcache_admin_pass\033[0m"
+[ "$PHP_cache" == '3' ] && echo -e "`printf "%-32s" "APC Control Panel url:"`\033[32mhttp://$local_IP/apc.php\033[0m" 
+[ "$PHP_cache" == '4' ] && echo -e "`printf "%-32s" "eAccelerator Control Panel url:"`\033[32mhttp://$local_IP/control.php\033[0m"
+[ "$PHP_cache" == '4' ] && echo -e "`printf "%-32s" "eAccelerator user:"`\033[32madmin\033[0m"
+[ "$PHP_cache" == '4' ] && echo -e "`printf "%-32s" "eAccelerator password:"`\033[32meAccelerator\033[0m"
+[ "$FTP_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Pure-FTPd install dir:"`\033[32m$pureftpd_install_dir\033[0m"
+[ "$FTP_yn" == 'y' ] && echo -e "`printf "%-32s" "Create FTP virtual script:"`\033[32m./pureftpd_vhost.sh\033[0m"
+[ "$phpMyAdmin_yn" == 'y' ] && echo -e "\n`printf "%-32s" "phpMyAdmin dir:"`\033[32m$home_dir/default/phpMyAdmin\033[0m"
+[ "$phpMyAdmin_yn" == 'y' ] && echo -e "`printf "%-32s" "phpMyAdmin Control Panel url:"`\033[32mhttp://$local_IP/phpMyAdmin\033[0m"
+[ "$redis_yn" == 'y' ] && echo -e "\n`printf "%-32s" "redis install dir:"`\033[32m$redis_install_dir\033[0m"
+[ "$memcached_yn" == 'y' ] && echo -e "\n`printf "%-32s" "memcached install dir:"`\033[32m$memcached_install_dir\033[0m"
+[ "$Web_yn" == 'y' ] && echo -e "\n`printf "%-32s" "index url:"`\033[32mhttp://$local_IP/\033[0m"
+while :
+do
+        echo
+        echo -e "\033[31mPlease restart the server and see if the services start up fine.\033[0m"
+        read -p "Do you want to restart OS ? [y/n]: " restart_yn
+        if [ "$restart_yn" != 'y' -a "$restart_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break
+        fi
+done
+[ "$restart_yn" == 'y' ] && reboot

+ 60 - 0
options.conf

@@ -0,0 +1,60 @@
+# operating environment for the current working directory
+oneinstack_dir=
+
+# Nginx Apache and PHP-FPM process is run as $run_user(Default "www"), you can freely specify
+run_user=www
+
+# set the default install path, you can freely specify
+nginx_install_dir=/usr/local/nginx
+tengine_install_dir=/usr/local/tengine
+apache_install_dir=/usr/local/apache
+tomcat_install_dir=/usr/local/tomcat
+
+mysql_install_dir=/usr/local/mysql
+mariadb_install_dir=/usr/local/mariadb
+percona_install_dir=/usr/local/percona
+
+php_install_dir=/usr/local/php
+
+pureftpd_install_dir=/usr/local/pureftpd
+
+memcached_install_dir=/usr/local/memcached
+
+redis_install_dir=/usr/local/redis
+
+#########################################################################
+# database data storage directory, you can freely specify
+mysql_data_dir=/data/mysql
+mariadb_data_dir=/data/mariadb
+percona_data_dir=/data/percona
+
+# web directory, you can customize
+home_dir=/home/wwwroot
+
+# nginx Generate a log storage directory, you can freely specify.
+wwwlogs_dir=/home/wwwlogs
+
+#########################################################################
+# automatically generated, You can't change 
+web_install_dir=
+
+db_install_dir=
+
+db_data_dir=
+
+dbrootpwd=
+
+#########################################################################
+# Backup Dest directory, change this if you have someother location
+backup_dir=/home/backup
+
+# How many days before the backup directory will be removed
+expired_days=5
+
+db_name=
+
+website_name=
+
+local_bankup_yn=y
+
+remote_bankup_yn=n

+ 169 - 0
pureftpd_vhost.sh

@@ -0,0 +1,169 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#                 FTP virtual user account management                 #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+. ./options.conf
+[ ! -d "$pureftpd_install_dir" ] && { echo -e "\033[31mThe ftp server does not exist! \033[0m"; exit 1; }
+
+FTP_conf=$pureftpd_install_dir/etc/pure-ftpd.conf
+FTP_tmp_passfile=$pureftpd_install_dir/etc/pureftpd_psss.tmp
+Puredbfile=$pureftpd_install_dir/etc/pureftpd.pdb
+Passwdfile=$pureftpd_install_dir/etc/pureftpd.passwd
+FTP_bin=$pureftpd_install_dir/bin/pure-pw 
+[ -z "`grep ^PureDB $FTP_conf`" ] && { echo -e "\033[31mpure-ftpd is not own password database\033[0m" ; exit 1; }
+
+USER() {
+while :
+do
+        echo
+        read -p "Please input a username: " User
+        if [ -z "$User" ]; then
+                echo -e "\033[31musername can't be NULL! \033[0m"
+        else
+                break
+        fi
+done
+}
+
+PASSWORD() {
+while :
+do
+        echo
+        read -p "Please input the password: " Password 
+        [ -n "`echo $Password | grep '[+|&]'`" ] && { echo -e "\033[31minput error,not contain a plus sign (+) and &\033[0m"; continue; }
+        if (( ${#Password} >= 5 ));then
+		echo -e "${Password}\n$Password" > $FTP_tmp_passfile
+                break
+        else
+                echo -e "\033[31mFtp password least 5 characters! \033[0m"
+        fi
+done
+}
+
+DIRECTORY() {
+while :
+do
+echo
+	read -p "Please input the directory(Default directory: $home_dir): " Directory 
+	if [ -z "$Directory" ]; then
+	        Directory="$home_dir"
+	fi
+	if [ ! -d "$Directory" ];then
+		echo -e "\033[31mThe directory does not exist\033[0m"
+	else
+		break
+	fi
+done
+}
+
+while :
+do
+	echo
+	echo -e "What Are You Doing? 
+\t\033[32m1\033[0m. UserAdd
+\t\033[32m2\033[0m. UserMod
+\t\033[32m3\033[0m. UserPasswd
+\t\033[32m4\033[0m. UserDel
+\t\033[32m5\033[0m. ListAllUser
+\t\033[32m6\033[0m. ShowUser
+\t\033[32mq\033[0m. Exit"
+	read -p "Please input the correct option: " Number 
+	if [ "$Number" != '1' -a "$Number" != '2' -a "$Number" != '3' -a "$Number" != '4' -a "$Number" != '5' -a "$Number" != '6' -a "$Number" != 'q' ];then
+		echo -e "\033[31minput error! Please only input 1 ~ 8 and q\033[0m"
+	else
+	case "$Number" in
+	1)
+		USER
+		[ -e "$Passwdfile" ] && [ -n "`grep ^${User}: $Passwdfile`" ] && { echo -e "\033[31m[$User] is already existed! \033[0m"; continue; } 
+		PASSWORD;DIRECTORY
+		$FTP_bin useradd $User -f $Passwdfile -u $run_user -g $run_user -d $Directory -m < $FTP_tmp_passfile
+		$FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 
+                echo "#####################################"
+		echo
+                echo "[$User] create successful! "
+		echo
+                echo "You user name is : $User"
+                echo "You Password is : $Password"
+                echo "You directory is : $Directory"
+		echo
+
+		;;
+	2)
+		USER;DIRECTORY
+		$FTP_bin usermod $User -f $Passwdfile -d $Directory -m 
+		$FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 
+                echo "#####################################"
+		echo
+		echo "[$User] modify a successful! "
+		echo
+		echo "You user name is : $User"
+		echo "You new directory is : $Directory"
+		echo
+                ;;
+        3)
+		USER
+                [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo -e "\033[31m[$User] is not existed! \033[0m"; continue; }
+		PASSWORD
+		$FTP_bin passwd $User -f $Passwdfile -m < $FTP_tmp_passfile
+		$FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 
+		echo "#####################################"
+		echo
+		echo "[$User] Password changed successfully! "
+		echo
+		echo "You user name is : $User"
+		echo "You new password is : $Password"
+		echo
+                ;;
+        4)
+		if [ ! -e "$Passwdfile" ];then
+                        echo -e "\033[31mUser is not existed\033[0m"
+                else
+                        $FTP_bin list
+                fi
+
+		USER
+		[ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo -e "\033[31m[$User] is not existed! \033[0m"; continue; } 
+		$FTP_bin userdel $User -f $Passwdfile -m
+		$FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1
+		echo
+		echo "[$User] have been deleted! "
+                ;;
+        5)
+		if [ ! -e "$Passwdfile" ];then
+			echo -e "\033[31mUser is not existed\033[0m"
+		else
+			$FTP_bin list
+		fi
+                ;;
+        6)
+		USER
+		[ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo -e "\033[31m[$User] is not existed! \033[0m"; continue; } 
+		$FTP_bin show $User
+                ;;
+	9)
+		exit
+		;;
+        q)
+                exit
+                ;;
+	esac
+	fi
+done

+ 13 - 0
tools/ckssh.py

@@ -0,0 +1,13 @@
+#!/usr/bin/python
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+import socket,sys
+sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+sk.settimeout(1)
+try:
+    sk.connect((sys.argv[1],int(sys.argv[2])))
+    print 'ok' 
+except Exception:
+    print 'no' 
+sk.close()

+ 33 - 0
tools/db_bk.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+. ../options.conf
+
+DBname=$1
+LogFile=$backup_dir/db.log
+DumpFile=$backup_dir/DB_${DBname}_$(date +%Y%m%d_%H).sql
+NewFile=$backup_dir/DB_${DBname}_$(date +%Y%m%d_%H).tgz
+OldFile=$backup_dir/DB_${DBname}_$(date +%Y%m%d --date="$expired_days days ago")*.tgz
+
+[ ! -e "$backup_dir" ] && mkdir -p $backup_dir
+
+DB_tmp=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep $DBname`
+[ -z "$DB_tmp" ] && { echo "[$DBname] not exist" >> $LogFile ;  exit 1 ; }
+
+if [ -e "$OldFile" ];then
+	rm -f $OldFile
+        echo "[$OldFile] Delete Old File Success" >> $LogFile
+else
+        echo "[$OldFile] Delete Old Backup File" >> $LogFile
+fi
+
+if [ -e "$NewFile" ];then
+        echo "[$NewFile] The Backup File is exists,Can't Backup" >> $LogFile
+else
+	$db_install_dir/bin/mysqldump -uroot -p$dbrootpwd --opt --databases $DBname > $DumpFile 
+	cd $backup_dir
+        tar czf $NewFile ${DumpFile##*/} >> $LogFile 2>&1
+        echo "[$NewFile] Backup success ">> $LogFile
+        /bin/rm -f $DumpFile
+fi

+ 172 - 0
tools/mabs.sh

@@ -0,0 +1,172 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+######################  proc defination  ########################
+# ignore rule
+ignore_init()
+{
+	# ignore password
+	array_ignore_pwd_length=0
+	if [ -f ./ignore_pwd ]; then
+		while read IGNORE_PWD
+		do
+			array_ignore_pwd[$array_ignore_pwd_length]=$IGNORE_PWD	
+			let array_ignore_pwd_length=$array_ignore_pwd_length+1
+		done < ./ignore_pwd
+	fi
+	
+	# ignore ip address
+	array_ignore_ip_length=0
+	if [ -f ./ignore_ip ]; then
+		while read IGNORE_IP
+		do
+			array_ignore_ip[$array_ignore_ip_length]=$IGNORE_IP
+			let array_ignore_ip_length=$array_ignore_ip_length+1
+		done < ./ignore_ip
+	fi
+}
+
+show_version()
+{
+	echo "version: 1.0"
+	echo "updated date: 2014-06-08"
+}
+
+show_usage()
+{
+	echo -e "`printf %-16s "Usage: $0"` [-h|--help]"
+        echo -e "`printf %-16s ` [-v|-V|--version]"
+        echo -e "`printf %-16s ` [-l|--iplist ... ]"
+        echo -e "`printf %-16s ` [-c|--config ... ]"
+        echo -e "`printf %-16s ` [-t|--sshtimeout ... ]"
+        echo -e "`printf %-16s ` [-T|--fttimeout ... ]"
+        echo -e "`printf %-16s ` [-L|--bwlimit ... ]"
+        echo -e "`printf %-16s ` [-n|--ignore]"
+}
+
+IPLIST="iplist.txt"
+CONFIG_FILE="config.txt"
+IGNRFLAG="noignr"
+SSHTIMEOUT=100
+SCPTIMEOUT=2000
+BWLIMIT=1024000
+[ ! -e 'logs' ] && mkdir logs
+
+TEMP=`getopt -o hvVl:c:t:T:L:n --long help,version,iplist:,config:,sshtimeout:,fttimeout:,bwlimit:,log:,ignore -- "$@" 2>/dev/null`
+
+[ $? != 0 ] && echo -e "\033[31mERROR: unknown argument! \033[0m\n" && show_usage && exit 1
+
+eval set -- "$TEMP"
+
+while :
+do
+	[ -z "$1" ] && break;
+	case "$1" in
+		-h|--help) 
+			show_usage; exit 0
+			;;
+		-v|-V|--version)
+			show_version; exit 0
+			;;
+		-l|--iplist)
+			IPLIST=$2; shift 2
+			;;
+		-c|--config)
+			CONFIG_FILE=$2; shift 2
+			;;
+		-t|--sshtimeout)
+			SSHTIMEOUT=$2; shift 2
+			;;
+		-T|--fttimeout)
+			SCPTIMEOUT=$2; shift 2
+			;;
+		-L|--bwlimit)
+			BWLIMIT=$2; shift 2
+			;;
+		--log)
+			LOG_FILE=$2; shift 2
+			;;	
+		-n|--ignore)
+			IGNRFLAG="ignr"; shift
+			;;
+		--)
+			shift
+			;; 
+		*)
+			echo -e "\033[31mERROR: unknown argument! \033[0m\n" && show_usage && exit 1
+			;;
+	esac
+done
+
+################  main  #######################
+BEGINDATETIME=`date "+%F %T"`
+[ ! -f $IPLIST ] && echo -e "\033[31mERROR: iplist \"$IPLIST\" not exists, please check! \033[0m\n" && exit 1
+
+[ ! -f $CONFIG_FILE ] && echo -e "\033[31mERROR: config \"$CONFIG_FILE\" not exists, please check! \033[0m\n" && exit 1
+
+IP_count=$(egrep -v '^#|^$' $IPLIST|wc -l)
+IP_init=1
+while [[ $IP_init -le $IP_count ]]
+do
+        egrep -v '^#|^$' $IPLIST | sed -n "$IP_init,$(expr $IP_init + 50)p" > $IPLIST.tmp
+
+	IPSEQ=0
+
+	while read IP PORT USER PASSWD PASSWD_2ND PASSWD_3RD PASSWD_4TH OTHERS
+       # while read Line
+        do
+		[ -z "`echo $IP | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|CNS'`" ] && continue
+	        if [ "`python ./ckssh.py $IP $PORT`" == 'no' ];then
+			[ ! -e ipnologin.txt ] && > ipnologin.txt
+			[ -z "`grep $IP ipnologin.txt | grep $(date +%F)`" ] && echo "`date +%F_%H%M` $IP" >> ipnologin.txt
+			continue
+	        fi
+		
+		#[ -e "~/.ssh/known_hosts" ] && grep $IP ~/.ssh/known_hosts | sed -i "/$IP/d" ~/.ssh/known_hosts
+
+		let IPSEQ=$IPSEQ+1
+
+	        if [ $IGNRFLAG == "ignr" ]; then
+	                ignore_init
+	                ignored_flag=0
+
+	                i=0
+	                while [ $i -lt $array_ignore_pwd_length ]
+	                do
+	                        [ ${PASSWD}x == ${array_ignore_pwd[$i]}x ] && ignored_flag=1 && break
+	                        let i=$i+1
+	                done
+
+	                [ $ignored_flag -eq 1 ] && continue
+
+	                j=0
+	                while [ $j -lt $array_ignore_ip_length ]
+	                do
+	                        [ ${IP}x == ${array_ignore_ip[$j]}x ] && ignored_flag=1 && break
+	                        let j=$j+1
+	                done
+
+	                [ $ignored_flag -eq 1 ] && continue
+	        fi
+
+		PASSWD_USE=$PASSWD
+
+                IPcode=$(echo "ibase=16;$(echo "$IP" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+                Portcode=$(echo "ibase=16;$(echo "$PORT" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+                #USER=$USER
+                PWcode=$(echo "ibase=16;$(echo "$PASSWD_USE" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+                Othercode=$(echo "ibase=16;$(echo "$OTHERS" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+                #echo $IPcode $Portcode $USER $PWcode $CONFIG_FILE $SSHTIMEOUT $SCPTIMEOUT $BWLIMIT $Othercode
+		./thread.sh $IPcode $Portcode $USER $PWcode $CONFIG_FILE $SSHTIMEOUT $SCPTIMEOUT $BWLIMIT $Othercode | tee logs/$IP.log &
+        done < $IPLIST.tmp
+        sleep 3
+        IP_init=$(expr $IP_init + 50)
+done
+
+ENDDATETIME=`date "+%F %T"`
+
+echo "$BEGINDATETIME -- $ENDDATETIME"
+echo "$0 $* --excutes over!"
+
+exit 0

+ 158 - 0
tools/mscp.exp

@@ -0,0 +1,158 @@
+#!/usr/bin/expect -- 
+
+proc Usage_Exit {self} {
+	puts ""
+	puts "Usage: $self ip user passwd port sourcefile destdir direction bwlimit timeout"
+	puts ""
+	puts "       sourcefile: a file or directory to be transferred"
+	puts "                   需要拷贝目录时目录名后不要带 /, 否则会拷贝该目录下的所有文件"
+	puts "       destdir:    the location that the sourcefile to be put into"
+	puts "       direction:  pull or push"
+	puts "                   pull: remote -> local"
+	puts "                   push: local -> remote"
+	puts "       bwlimit:    bandwidth limit, kbit/s, 0 means no limit" 
+	puts "       timeout:    timeout of expect, s, -1 means no timeout"
+	puts ""
+	exit 1
+}
+
+if { [llength $argv] < 9 } {
+	Usage_Exit $argv0
+}
+
+set ipcode [lindex $argv 0]
+set ip [exec dc -e $ipcode]
+set user [lindex $argv 1]
+set passwduncode [lindex $argv 2]
+set passwd [exec dc -e $passwduncode]
+set portcode [lindex $argv 3]
+set port [exec dc -e $portcode]
+set sourcefile [lindex $argv 4]
+set destdir [lindex $argv 5]
+set direction [lindex $argv 6]
+set bwlimit [lindex $argv 7]
+set timeoutflag [lindex $argv 8]
+
+set yesnoflag 0
+set timeout $timeoutflag
+
+for {} {1} {} {
+# for is only used to retry when "Interrupted system call" occured
+
+if { $direction == "pull" } {
+
+	if { $bwlimit > 0 } {
+		spawn rsync -crazP --delete --bwlimit=$bwlimit -e "/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port" $ip:$sourcefile $destdir
+	} elseif { $bwlimit == 0 } {
+		spawn rsync -crazP --delete -e "/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port" $ip:$sourcefile $destdir
+	} else {
+		Usage_Exit $argv0
+	}
+
+} elseif { $direction == "push" } {
+
+	if { $bwlimit > 0 } {
+		spawn rsync -crazP --delete --bwlimit=$bwlimit -e "/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port" $sourcefile $ip:$destdir
+	} elseif { $bwlimit == 0 } {
+		spawn rsync -crazP --delete -e "/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port" $sourcefile $ip:$destdir
+	} else {
+		Usage_Exit $argv0
+	}
+
+} else {
+	Usage_Exit $argv0
+}
+
+expect 	{
+
+	"assword:" {
+		send "$passwd\r" 
+		break;
+	}
+	
+	"yes/no)?" {
+		set yesnoflag 1
+		send "yes\r"
+		break;
+	}
+	
+	"FATAL" {
+		puts "\nCONNECTERROR: $ip occur FATAL ERROR!!!\n"
+		exit 1
+	}
+	
+	timeout {
+		puts "\nCONNECTERROR: $ip Logon timeout!!!\n"
+		exit 1
+	}
+	
+	"No route to host" {
+		puts "\nCONNECTERROR: $ip No route to host!!!\n"
+		exit 1
+	}
+	
+	"Connection Refused" {
+		puts "\nCONNECTERROR: $ip Connection Refused!!!\n"
+		exit 1
+	}
+
+	"Connection refused" {
+		puts "\nCONNECTERROR: $ip Connection Refused!!!\n"
+		exit 1
+	}
+
+	"Host key verification failed" {
+		puts "\nCONNECTERROR: $ip Host key verification failed!!!\n"
+		exit 1
+	}
+	
+	"Illegal host key" {
+		puts "\nCONNECTERROR: $ip Illegal host key!!!\n"
+		exit 1
+	}
+		
+	"Connection Timed Out" {
+		puts "\nCONNECTERROR: $ip Logon timeout!!!\n"
+		exit 1
+	}
+
+	"Interrupted system call" {
+		puts "\n$ip Interrupted system call!!!\n"
+	}
+}
+
+}
+
+if { $yesnoflag == 1 } {
+	expect {
+		"assword:" {
+			send "$passwd\r"
+		}
+
+		"yes/no)?" {
+			set yesnoflag 2
+			send "yes\r"
+		}
+	}
+}
+
+if { $yesnoflag == 2 } {
+	expect {
+		"assword:" {
+			send "$passwd\r"
+		}
+	}
+}
+
+expect {
+	"assword:" {
+		send "$passwd\r"
+		puts "\nPASSWORDERROR: $ip Password error!!!\n"
+		exit 1
+	}
+	
+	eof { 
+		puts "OK_SCP: $ip\n"
+		exit 0;
+	}
+}

+ 129 - 0
tools/mssh.exp

@@ -0,0 +1,129 @@
+#!/usr/bin/expect --
+
+if { [llength $argv] < 4 } {
+	puts "Usage: $argv0 ip user passwd port commands timeout"
+	exit 1
+}
+
+match_max 600000
+
+set ipcode [lindex $argv 0]
+set ip [exec dc -e $ipcode]
+set user [lindex $argv 1]
+set passwdcode [lindex $argv 2]
+set passwd [exec dc -e $passwdcode]
+set portcode [lindex $argv 3]
+set port [exec dc -e $portcode]
+set commands [lindex $argv 4]
+set timeoutflag [lindex $argv 5]
+
+set yesnoflag 0
+set timeout $timeoutflag
+
+
+for {} {1} {} {
+# for is only used to retry when "Interrupted system call" occured
+
+spawn /usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port $ip
+
+expect 	{
+
+	"assword:" {
+		send "$passwd\r"
+		break;
+	}
+
+	"yes/no)?" {
+		set yesnoflag 1
+		send "yes\r"
+		break;
+	}
+
+	"FATAL" {
+		puts "\nCONNECTERROR: $ip occur FATAL ERROR!!!\n"
+		exit 1
+	}
+
+	timeout {
+		puts "\nCONNECTERROR: $ip Logon timeout!!!\n"
+		exit 1
+	}
+
+	"No route to host" {
+		puts "\nCONNECTERROR: $ip No route to host!!!\n"
+		exit 1
+	}
+
+	"Connection Refused" {
+		puts "\nCONNECTERROR: $ip Connection Refused!!!\n"
+		exit 1
+	}
+
+	"Connection refused" {
+		puts "\nCONNECTERROR: $ip Connection Refused!!!\n"
+		exit 1
+	}
+
+	"Host key verification failed" {
+		puts "\nCONNECTERROR: $ip Host key verification failed!!!\n"
+		exit 1
+	}
+
+	"Illegal host key" {
+		puts "\nCONNECTERROR: $ip Illegal host key!!!\n"
+		exit 1
+	}
+		
+	"Connection Timed Out" {
+		puts "\nCONNECTERROR: $ip Logon timeout!!!\n"
+		exit 1
+	}
+
+	"Interrupted system call" {
+		puts "\n$ip Interrupted system call!!!\n"
+	}
+}
+}
+
+if { $yesnoflag == 1 } {
+	expect {
+		"assword:" {
+			send "$passwd\r"
+		}
+
+		"yes/no)?" {
+			set yesnoflag 2
+			send "yes\r"
+		}
+	}
+}
+
+if { $yesnoflag == 2 } {
+	expect {
+		"assword:" {
+			send "$passwd\r"
+		}
+	}
+}
+
+expect {
+	"#" {send "$commands \r"}
+	"assword:" {
+		send "$passwd\r"
+		puts "\nPASSWORDERROR: $ip Password error!!!\n"
+		exit 1
+	}
+}
+
+expect {
+	"#" {send "sleep 1 \r"}
+}
+
+expect {
+	"#" {send "exit\r"}
+}
+
+expect eof {
+	puts "OK_SSH: $ip\n"
+	exit 0;
+}

+ 46 - 0
tools/thread.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+# Default Parameters
+myIFS=":::"
+
+IP=$1P
+PORT=$2P
+USER=$3
+PASSWD=$4P
+CONFIG_FILE=$5
+SSHTIMEOUT=$6
+SCPTIMEOUT=$7
+BWLIMIT=$8
+
+while read eachline
+do
+	[ -z "`echo $eachline | grep -E '^com|^file'`" ] && continue
+
+	myKEYWORD=`echo $eachline | awk -F"$myIFS" '{ print $1 }'`
+	myCONFIGLINE=`echo $eachline | awk -F"$myIFS" '{ print $2 }'`
+
+	if [ "$myKEYWORD"x == "file"x ]; then
+		SOURCEFILE=`echo $myCONFIGLINE | awk '{ print $1 }'`
+		DESTDIR=`echo $myCONFIGLINE | awk '{ print $2 }'`
+		DIRECTION=`echo $myCONFIGLINE | awk '{ print $3 }'`
+		./mscp.exp $IP $USER $PASSWD $PORT $SOURCEFILE $DESTDIR $DIRECTION $BWLIMIT $SCPTIMEOUT
+		
+		[ $? -ne 0 ] && echo -e "\033[31mSCP Try Out All Password Failed\033[0m\n"
+
+	elif [ "$myKEYWORD"x == "com"x ]; then
+		./mssh.exp $IP $USER $PASSWD $PORT "${myCONFIGLINE}" $SSHTIMEOUT
+		[ $? -ne 0 ] && echo -e "\033[31mSSH Try Out All Password Failed\033[0m\n"
+
+	else
+		echo "ERROR: configuration wrong! [$eachline] "
+		echo "       where KEYWORD should not be [$myKEYWORD], but 'com' or 'file'"
+		echo "       if you dont want to run it, you can comment it with '#'"
+		echo ""
+		exit
+	fi
+
+done < $CONFIG_FILE
+
+exit 0

+ 13 - 0
tools/website_bk.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+. ../options.conf
+
+WebSite=$1
+LogFile=$backup_dir/website.log
+[ ! -e "$home_dir/$WebSite" ] && { echo "[$home_dir/$WebSite] not exist" >> $LogFile ;  exit 1 ; }
+
+[ ! -e "$backup_dir" ] && mkdir -p $backup_dir
+
+rsync -crazP --delete $home_dir/$WebSite $backup_dir

+ 106 - 0
uninstall.sh

@@ -0,0 +1,106 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#                         Uninstall OneinStack                        #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+. ./options.conf
+
+Uninstall()
+{
+[ -e "$db_install_dir" ] && service mysqld stop && rm -rf /etc/init.d/mysqld /etc/my.cnf
+[ -e "$apache_install_dir" ] && service httpd stop && rm -rf /etc/init.d/httpd
+[ -e "$tomcat_install_dir" ] && service tomcat stop && rm -rf /etc/init.d/tomcat
+[ -e "$php_install_dir" ] && service php-fpm stop && rm -rf /etc/init.d/php-fpm
+[ -e "$web_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx
+[ -e "$pureftpd_install_dir" ] && service pureftpd stop && rm -rf /etc/init.d/pureftpd
+[ -e "$redis_install_dir" ] && service redis-server stop && rm -rf /etc/init.d/redis-server
+[ -e "$memcached_install_dir" ] && service memcached stop && rm -rf /etc/init.d/memcached
+[ -e "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick 
+[ -e "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick 
+[ -e "/etc/init.d/supervisord" ] && service supervisord stop && { rm -rf /etc/supervisord.conf; /etc/init.d/supervisord; } 
+[ -e "/etc/systemd/system/hhvm.service" ] && service hhvm stop && { rpm -e hhvm ;rm -rf /etc/systemd/system/hhvm.service /etc/hhvm /var/log/hhvm; } 
+[ -e "/etc/init.d/hhvm" ] && service hhvm stop && { rpm -e hhvm ;rm -rf /etc/init.d/hhvm /etc/hhvm /var/log/hhvm; } 
+id -u $run_user >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel $run_user
+id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql 
+
+/bin/mv ${home_dir}{,_$(date +%F)}
+/bin/mv ${db_data_dir}{,_$(date +%F)}
+for D in `cat ./options.conf | grep dir= | grep -v oneinstack | awk -F'=' '{print $2}' | sort | uniq`
+do
+        [ -e "$D" ] && rm -rf $D
+done
+
+sed -i 's@^oneinstack_dir=.*@oneinstack_dir=@' ./options.conf
+sed -i 's@^web_install_dir=.*@web_install_dir=@' ./options.conf
+sed -i 's@^db_install_dir=.*@db_install_dir=@' ./options.conf
+sed -i 's@^db_data_dir=.*@db_data_dir=@' ./options.conf
+sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf
+sed -i 's@^ftpmanagerpwd=.*@ftpmanagerpwd=@' ./options.conf
+sed -i 's@^conn_ftpusers_dbpwd=.*@conn_ftpusers_dbpwd=@' ./options.conf
+sed -i "s@^export.*$db_install_dir.*@@g" /etc/profile && . /etc/profile
+echo -e "\033[32mUninstall completed.\033[0m"
+}
+
+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 -e "\033[31mYou will uninstall OneinStack, Please backup your configure files and DB data! \033[0m"
+echo 
+echo -e "\033[33mThe following directory or files will be remove: \033[0m"
+for D in `cat ./options.conf | grep dir= | grep -v oneinstack | awk -F'=' '{print $2}' | sort | uniq` 
+do
+	[ -e "$D" ] && echo $D
+done
+[ -e "$web_install_dir" ] && echo -e "/etc/init.d/nginx\n/etc/logrotate.d/nginx"
+[ -e "$apache_install_dir" ] && echo '/etc/init.d/httpd'
+[ -e "$tomcat_install_dir" ] && echo '/etc/init.d/tomcat'
+[ -e "$db_install_dir" ] && echo -e "/etc/init.d/mysqld\n/etc/my.cnf"
+[ -e "$php_install_dir" ] && echo '/etc/init.d/php-fpm'
+[ -e "$pureftpd_install_dir" ] && echo '/etc/init.d/pureftpd'
+[ -e "$memcached_install_dir" ] && echo '/etc/init.d/memcached' 
+[ -e "$redis_install_dir" ] && echo '/etc/init.d/redis-server' 
+[ -e "/usr/local/imagemagick" ] && echo '/usr/local/imagemagick' 
+[ -e "/usr/local/graphicsmagick" ] && echo '/usr/local/graphicsmagick' 
+echo 
+echo "Press Ctrl+c to cancel or Press any key to continue..."
+char=`get_char`
+
+while :
+do
+        echo
+        read -p "Do you want to uninstall OneinStack? [y/n]: " uninstall_yn
+        if [ "$uninstall_yn" != 'y' -a "$uninstall_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break
+        fi
+done
+
+[ "$uninstall_yn" == 'y' ] && Uninstall

+ 79 - 0
upgrade_php.sh

@@ -0,0 +1,79 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#                    Upgrade PHP for OneinStack                       #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+cd src
+. ../options.conf
+[ ! -e "$php_install_dir" ] && echo -e "\033[31mThe PHP is not installed on your system!\033[0m " && exit 1
+
+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
+Old_php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
+echo -e "Current PHP Version: \033[32m$Old_php_version\033[0m"
+while :
+do
+        echo
+        read -p "Please input upgrade PHP Version: " php_version
+        if [ "${php_version%.*}" == "${Old_php_version%.*}" ]; then
+                if [ "${php_version##*.}" -ge "${Old_php_version##*.}" ]; then
+                        [ ! -e "php-$php_version.tar.gz" ] && wget -c http://www.php.net/distributions/php-$php_version.tar.gz > /dev/null 2>&1
+                        if [ -e "php-$php_version.tar.gz" ];then
+                                echo -e "Download \033[32mphp-$php_version.tar.gz\033[0m successfully! "
+                        else
+				echo -e "\033[31mIt does not exist!\033[0m"
+                        fi
+			break
+                else
+                        echo -e "Error: You must input PHP version not less than \033[32m$Old_php_version\033[0m!! "
+                fi
+        else
+                echo -e "\033[31minput error!\033[0m Please only input '\033[32m${Old_php_version%.*}.xx' \033[0m"
+        fi
+done
+
+if [ -e "php-$php_version.tar.gz" ];then
+        echo -e "\033[32mphp-$php_version.tar.gz\033[0m [found]"
+        echo "Press Ctrl+c to cancel or Press any key to continue..."
+        char=`get_char`
+        tar xzf php-$php_version.tar.gz
+	[ ! -e "fpm-race-condition.patch" ] && wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
+	patch -d php-$php_version -p0 < fpm-race-condition.patch
+        cd php-$php_version
+	make clean
+        $php_install_dir/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash
+        make ZEND_EXTRA_LIBS='-liconv'
+        make install
+	cd ..
+        echo "Restarting php-fpm..."
+        /etc/init.d/php-fpm restart
+        echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_php_version\033[0m to \033[32m$php_version\033[0m"
+fi

+ 78 - 0
upgrade_phpmyadmin.sh

@@ -0,0 +1,78 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#                  Upgrade phpMyAdmin for OneinStack                  #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+cd src
+. ../options.conf
+
+[ ! -e "$home_dir/default/phpMyAdmin" ] && echo -e "\033[31mThe phpMyAdmin is not installed on your system!\033[0m " && exit 1
+
+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
+
+Upgrade_phpMyAdmin()
+{
+Old_phpMyAdmin_version=`grep Version $home_dir/default/phpMyAdmin/README | awk '{print $2}'`
+echo -e "Current phpMyAdmin Version: \033[32m$Old_phpMyAdmin_version\033[0m"
+while :
+do
+        echo
+        read -p "Please input upgrade phpMyAdmin Version(example: 4.1.5): " phpMyAdmin_version
+	if [ "$phpMyAdmin_version" != "$Old_phpMyAdmin_version" ];then
+	        [ ! -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ] && wget -c http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/$phpMyAdmin_version/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1
+	        if [ -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ];then
+	                echo -e "Download \033[32mphpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz\033[0m successfully! "
+	                break
+	        else
+	                echo -e "\033[31mphpMyAdmin version does not exist!\033[0m"
+	        fi
+	else
+		echo -e "\033[31minput error! The upgrade phpMyAdmin version is the same as the old version\033[0m"
+	fi
+done
+
+if [ -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ];then
+        echo -e "\033[32mphpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz\033[0m [found]"
+        echo "Press Ctrl+c to cancel or Press any key to continue..."
+        char=`get_char`
+	tar xzf phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz 
+	rm -rf $home_dir/default/phpMyAdmin
+	/bin/mv phpMyAdmin-${phpMyAdmin_version}-all-languages $home_dir/default/phpMyAdmin
+	/bin/cp $home_dir/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
+	mkdir $home_dir/default/phpMyAdmin/{upload,save}
+	sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" $home_dir/default/phpMyAdmin/config.inc.php
+	sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" $home_dir/default/phpMyAdmin/config.inc.php
+	chown -R ${run_user}.$run_user $home_dir/default/phpMyAdmin
+	cd ..
+	echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_phpMyAdmin_version\033[0m to \033[32m$phpMyAdmin_version\033[0m"
+fi
+}
+Upgrade_phpMyAdmin

+ 89 - 0
upgrade_redis.sh

@@ -0,0 +1,89 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#                    Upgrade Redis for OneinStack                     #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+cd src
+. ../options.conf
+
+[ ! -d "$redis_install_dir" ] && echo -e "\033[31mThe Redis is not installed on your system!\033[0m " && exit 1
+
+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
+
+Upgrade_Redis()
+{
+Old_redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
+echo -e "Current Redis Version: \033[32m$Old_redis_version\033[0m"
+while :
+do
+        echo
+        read -p "Please input upgrade Redis Version(example: 2.8.4): " redis_version
+	if [ "$redis_version" != "$Old_redis_version" ];then
+		[ ! -e "redis-$redis_version.tar.gz" ] && wget -c http://download.redis.io/releases/redis-$redis_version.tar.gz > /dev/null 2>&1
+		if [ -e "redis-$redis_version.tar.gz" ];then
+			echo -e "Download \033[32mredis-$redis_version.tar.gz\033[0m successfully! "
+			break
+		else
+			echo -e "\033[31mRedis version does not exist!\033[0m"
+		fi
+	else
+		echo -e "\033[31minput error! The upgrade Redis version is the same as the old version\033[0m"
+	fi
+done
+
+if [ -e "redis-$redis_version.tar.gz" ];then
+        echo -e "\033[32mredis-$redis_version.tar.gz\033[0m [found]"
+        echo "Press Ctrl+c to cancel or Press any key to continue..."
+        char=`get_char`
+        tar xzf redis-$redis_version.tar.gz
+        cd redis-$redis_version
+	make clean
+	if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 32 ];then
+	        sed -i '1i\CFLAGS= -march=i686' src/Makefile
+	        sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
+	fi
+
+	make
+
+	if [ -f "src/redis-server" ];then
+		echo -e "\nRestarting Redis..."
+		service redis-server stop
+	        /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/
+		service redis-server start
+	        echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_redis_version\033[0m to \033[32m$redis_version\033[0m"
+        else
+                echo -e "\033[31mUpgrade Redis failed! \033[0m"
+        fi
+        cd ..
+fi
+}
+
+Upgrade_Redis

+ 152 - 0
upgrade_web.sh

@@ -0,0 +1,152 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#              Upgrade Nginx/Tengine for OneinStack                   #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+cd src
+. ../options.conf
+. ../functions/download.sh
+
+[ ! -e "$web_install_dir/sbin/nginx" ] && echo -e "\033[31mThe Nginx/Tengine is not installed on your system!\033[0m " && exit 1
+
+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
+
+Upgrade_Nginx()
+{
+Old_nginx_version_tmp=`$web_install_dir/sbin/nginx -v 2>&1`
+Old_nginx_version=${Old_nginx_version_tmp##*/}
+echo -e "Current Nginx Version: \033[32m$Old_nginx_version\033[0m"
+while :
+do
+        echo
+        read -p "Please input upgrade Nginx Version(example: 1.4.3): " nginx_version
+	if [ "$nginx_version" != "$Old_nginx_version" ];then
+		[ ! -e "nginx-$nginx_version.tar.gz" ] && wget -c http://nginx.org/download/nginx-$nginx_version.tar.gz > /dev/null 2>&1
+		if [ -e "nginx-$nginx_version.tar.gz" ];then
+			echo -e "Download \033[32mnginx-$nginx_version.tar.gz\033[0m successfully! "
+			break
+		else
+			echo -e "\033[31mNginx version does not exist!\033[0m"
+		fi
+	else
+		echo -e "\033[31minput error! The upgrade Nginx version is the same as the old version\033[0m"
+	fi
+done
+
+if [ -e "nginx-$nginx_version.tar.gz" ];then
+        echo -e "\033[32mnginx-$nginx_version.tar.gz\033[0m [found]"
+        echo "Press Ctrl+c to cancel or Press any key to continue..."
+        char=`get_char`
+        tar xzf nginx-$nginx_version.tar.gz
+        cd nginx-$nginx_version
+	make clean
+        $web_install_dir/sbin/nginx -V &> $$
+        nginx_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
+        rm -rf $$
+	./configure $nginx_configure_arguments
+	make
+        if [ -f "objs/nginx" ];then
+                /bin/mv $web_install_dir/sbin/nginx $web_install_dir/sbin/nginx$(date +%m%d)
+                /bin/cp objs/nginx $web_install_dir/sbin/nginx
+                kill -USR2 `cat /var/run/nginx.pid`
+                kill -QUIT `cat /var/run/nginx.pid.oldbin`
+	        echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_nginx_version\033[0m to \033[32m$nginx_version\033[0m"
+        	#echo "Restarting Nginx..."
+	        #/etc/init.d/nginx restart
+        else
+                echo -e "\033[31mUpgrade Nginx failed! \033[0m"
+        fi
+        cd ..
+fi
+}
+
+Upgrade_Tengine()
+{
+Old_tengine_version_tmp=`$web_install_dir/sbin/nginx -v 2>&1`
+Old_tengine_version="`echo ${Old_tengine_version_tmp#*/} | awk '{print $1}'`"
+echo -e "Current Tengine Version: \033[32m$Old_tengine_version\033[0m"
+while :
+do
+        echo
+        read -p "Please input upgrade Tengine Version(example: 1.5.1): " tengine_version
+        if [ "$tengine_version" != "$Old_tengine_version" ];then
+                [ ! -e "tengine-$tengine_version.tar.gz" ] && wget -c http://tengine.taobao.org/download/tengine-$tengine_version.tar.gz > /dev/null 2>&1
+                if [ -e "tengine-$tengine_version.tar.gz" ];then
+                        echo -e "Download \033[32mtengine-$tengine_version.tar.gz\033[0m successfully! "
+                        break
+                else
+                        echo -e "\033[31mTengine version does not exist!\033[0m"
+                fi
+        else
+                echo -e "\033[31minput error! The upgrade Tengine version is the same as the old version\033[0m"
+        fi
+done
+
+if [ -e "tengine-$tengine_version.tar.gz" ];then
+        echo -e "\033[32mtengine-$tengine_version.tar.gz\033[0m [found]"
+        echo "Press Ctrl+c to cancel or Press any key to continue..."
+        char=`get_char`
+        tar xzf tengine-$tengine_version.tar.gz
+        cd tengine-$tengine_version
+        make clean
+	# make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
+	sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c
+	sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c
+        $web_install_dir/sbin/nginx -V &> $$
+        tengine_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
+        rm -rf $$
+        ./configure $tengine_configure_arguments
+        make
+        if [ -f "objs/nginx" ];then
+                /bin/mv $web_install_dir/sbin/nginx $web_install_dir/sbin/nginx$(date +%m%d)
+                /bin/mv $web_install_dir/sbin/dso_tool $web_install_dir/sbin/dso_tool$(date +%m%d)
+                /bin/mv $web_install_dir/modules $web_install_dir/modules$(date +%m%d)
+                /bin/cp objs/nginx $web_install_dir/sbin/nginx
+                /bin/cp objs/dso_tool $web_install_dir/sbin/dso_tool
+		chmod +x $web_install_dir/sbin/*
+		make install
+                kill -USR2 `cat /var/run/nginx.pid`
+                kill -QUIT `cat /var/run/nginx.pid.oldbin`
+                echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_tengine_version\033[0m to \033[32m$tengine_version\033[0m"
+                #echo "Restarting Tengine..."
+                #/etc/init.d/nginx restart
+        else
+                echo -e "\033[31mUpgrade Tengine failed! \033[0m"
+        fi
+        cd ..
+fi
+}
+
+if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
+	Upgrade_Nginx
+elif [ -e "$web_install_dir/sbin/dso_tool" ];then 
+	Upgrade_Tengine
+fi

+ 565 - 0
vhost.sh

@@ -0,0 +1,565 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+. ./options.conf
+
+Choose_env()
+{
+if [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+	Number=111
+        while :
+        do
+                echo
+                echo 'Please choose to use environment:'
+                echo -e "\t\033[32m1\033[0m. Use php"
+                echo -e "\t\033[32m2\033[0m. Use java"
+                echo -e "\t\033[32m3\033[0m. Use hhvm"
+                read -p "Please input a number:(Default 1 press Enter) " Choose_number
+                [ -z "$Choose_number" ] && Choose_number=1
+                if [ $Choose_number != 1 -a $Choose_number != 2 -a $Choose_number != 3 ];then
+                        echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
+                else
+                        break
+                fi
+        done
+	[ "$Choose_number" == '1' ] && NGX_FLAG=php
+	[ "$Choose_number" == '2' ] && NGX_FLAG=java
+	[ "$Choose_number" == '3' ] && NGX_FLAG=hhvm
+elif [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
+	Number=110
+        while :
+        do
+                echo
+                echo 'Please choose to use environment:'
+                echo -e "\t\033[32m1\033[0m. Use php"
+                echo -e "\t\033[32m2\033[0m. Use java"
+                read -p "Please input a number:(Default 1 press Enter) " Choose_number
+                [ -z "$Choose_number" ] && Choose_number=1
+                if [ $Choose_number != 1 -a $Choose_number != 2 ];then
+                        echo -e "\033[31minput error! Please only input number 1,2\033[0m"
+                else
+                        break
+                fi
+        done
+	[ "$Choose_number" == '1' ] && NGX_FLAG=php
+	[ "$Choose_number" == '2' ] && NGX_FLAG=java
+elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
+	Number=100
+	NGX_FLAG=php
+	echo -e "\t\033[32m1\033[0m. Use php"
+elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+	Number=101
+	while :
+        do
+                echo
+                echo 'Please choose to use environment:'
+                echo -e "\t\033[32m1\033[0m. Use php"
+                echo -e "\t\033[32m2\033[0m. Use hhvm"
+                read -p "Please input a number:(Default 1 press Enter) " Choose_number
+                [ -z "$Choose_number" ] && Choose_number=1
+                if [ $Choose_number != 1 -a $Choose_number != 2 ];then
+                        echo -e "\033[31minput error! Please only input number 1,2\033[0m"
+                else
+                        break
+                fi
+        done
+	[ "$Choose_number" == '1' ] && NGX_FLAG=php
+	[ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
+elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+	Number=011
+        while :
+        do
+                echo
+                echo 'Please choose to use environment:'
+                echo -e "\t\033[32m1\033[0m. Use java"
+                echo -e "\t\033[32m2\033[0m. Use hhvm"
+                read -p "Please input a number:(Default 1 press Enter) " Choose_number
+                [ -z "$Choose_number" ] && Choose_number=1
+                if [ $Choose_number != 1 -a $Choose_number != 2 ];then
+                        echo -e "\033[31minput error! Please only input number 1,2\033[0m"
+                else
+                        break
+                fi
+        done
+	[ "$Choose_number" == '1' ] && NGX_FLAG=java
+	[ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
+elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
+	Number=010
+	NGX_FLAG=java
+elif [ ! -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+	Number=001
+	NGX_FLAG=hhvm
+else
+	Number=000
+	exit
+fi
+
+if [ "$NGX_FLAG" == 'php' ];then
+	NGX_CONF="location ~ .*\.(php|php5)?$ {\n\t#fastcgi_pass remote_php_ip:9000;\n\tfastcgi_pass unix:/dev/shm/php-cgi.sock;\n\tfastcgi_index index.php;\n\tinclude fastcgi.conf;\n\t}"
+elif [ "$NGX_FLAG" == 'java' ];then
+	NGX_CONF="location ~ {\n\tproxy_set_header Host \$host;\n\tproxy_set_header X-Real-IP \$remote_addr;\n\tproxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\n\tproxy_pass http://127.0.0.1:8080;\n\t}"
+elif [ "$NGX_FLAG" == 'hhvm' ];then
+	NGX_CONF="location ~ .*\.(php|php5)?$ {\n\tfastcgi_pass unix:/var/log/hhvm/sock;\n\tfastcgi_index index.php;\n\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n\tinclude fastcgi_params;\n\t}"
+fi
+}
+
+Input_domain()
+{
+while :
+do
+	echo
+	read -p "Please input domain(example: www.linuxeye.com): " domain
+	if [ -z "`echo $domain | grep '.*\..*'`" ]; then
+		echo -e "\033[31minput error! \033[0m"
+	else
+		break
+	fi
+done
+
+if [ -e "$web_install_dir/conf/vhost/$domain.conf" -o -e "$apache_install_dir/conf/vhost/$domain.conf" ]; then
+	[ -e "$web_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Nginx/Tengine already exist! \nYou can delete \033[32m$web_install_dir/conf/vhost/$domain.conf\033[0m and re-create"
+	[ -e "$apache_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Apache already exist! \nYou can delete \033[32m$apache_install_dir/conf/vhost/$domain.conf\033[0m and re-create"
+	exit
+else
+	echo "domain=$domain"
+fi
+
+while :
+do
+	echo ''
+        read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn 
+        if [ "$moredomainame_yn" != 'y' ] && [ "$moredomainame_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break 
+        fi
+done
+
+if [ "$moredomainame_yn" == 'y' ]; then
+        while :
+        do
+                echo
+                read -p "Type domainname,example(linuxeye.com www.example.com): " moredomain
+                if [ -z "`echo $moredomain | grep '.*\..*'`" ]; then
+                        echo -e "\033[31minput error\033[0m"
+                else
+			[ "$moredomain" == "$domain" ] && echo -e "\033[31mDomain name already exists! \033[0m" && continue
+                        echo domain list="$moredomain"
+                        moredomainame=" $moredomain"
+                        break
+                fi
+        done
+        Domain_alias=ServerAlias$moredomainame
+fi
+
+echo
+echo "Please input the directory for the domain:$domain :"
+read -p "(Default directory: $home_dir/$domain): " vhostdir
+if [ -z "$vhostdir" ]; then
+        vhostdir="$home_dir/$domain"
+        echo -e "Virtual Host Directory=\033[32m$vhostdir\033[0m"
+fi
+echo
+echo "Create Virtul Host directory......"
+mkdir -p $vhostdir
+echo "set permissions of Virtual Host directory......"
+chown -R ${run_user}.$run_user $vhostdir
+}
+
+Nginx_anti_hotlinking()
+{
+while :
+do
+	echo ''
+        read -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_yn 
+        if [ "$anti_hotlinking_yn" != 'y' ] && [ "$anti_hotlinking_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break
+        fi
+done
+
+if [ -n "`echo $domain | grep '.*\..*\..*'`" ];then
+        domain_allow="*.${domain#*.} $domain"
+else
+        domain_allow="*.$domain $domain"
+fi
+
+if [ "$anti_hotlinking_yn" == 'y' ];then 
+	if [ "$moredomainame_yn" == 'y' ]; then
+		domain_allow_all=$domain_allow$moredomainame
+	else
+		domain_allow_all=$domain_allow
+	fi
+	anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {\n\tvalid_referers none blocked $domain_allow_all;\n\tif (\$invalid_referer) {\n\t\t#rewrite ^/ http://www.linuxeye.com/403.html;\n\t\treturn 403;\n\t\t}\n\t}")
+else
+	anti_hotlinking=
+fi
+}
+
+Nginx_rewrite()
+{
+while :
+do
+	echo ''
+        read -p "Allow Rewrite rule? [y/n]: " rewrite_yn
+        if [ "$rewrite_yn" != 'y' ] && [ "$rewrite_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break 
+        fi
+done
+if [ "$rewrite_yn" == 'n' ];then
+	rewrite="none"
+	touch "$web_install_dir/conf/$rewrite.conf"
+else
+	echo ''
+	echo "Please input the rewrite of programme :"
+	echo -e "\033[32mwordpress\033[0m,\033[32mdiscuz\033[0m,\033[32mphpwind\033[0m,\033[32mtypecho\033[0m,\033[32mecshop\033[0m,\033[32mdrupal\033[0m,\033[32mjoomla\033[0m rewrite was exist."
+	read -p "(Default rewrite: other):" rewrite
+	if [ "$rewrite" == "" ]; then
+		rewrite="other"
+	fi
+	echo -e "You choose rewrite=\033[32m$rewrite\033[0m" 
+	if [ -s "conf/$rewrite.conf" ];then
+		/bin/cp conf/$rewrite.conf $web_install_dir/conf/$rewrite.conf
+	else
+		touch "$web_install_dir/conf/$rewrite.conf"
+	fi
+fi
+}
+
+Nginx_log()
+{
+while :
+do
+	echo ''
+        read -p "Allow Nginx/Tengine access_log? [y/n]: " access_yn 
+        if [ "$access_yn" != 'y' ] && [ "$access_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break 
+        fi
+done
+if [ "$access_yn" == 'n' ]; then
+	N_log="access_log off;"
+else
+	N_log="access_log $wwwlogs_dir/${domain}_nginx.log combined;"
+	echo -e "You access log file=\033[32m$wwwlogs_dir/${domain}_nginx.log\033[0m"
+fi
+}
+
+Create_nginx_tomcat_conf()
+{
+[ -n "`grep $vhostdir $tomcat_install_dir/conf/server.xml`" ] && { echo -e "\n$vhostdir in the tomcat already exist! \nYou must manually modify the file=\033[32m$tomcat_install_dir/conf/server.xml\033[0m"; exit; }
+
+[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
+cat > $web_install_dir/conf/vhost/$domain.conf << EOF
+server {
+listen 80;
+server_name $domain$moredomainame;
+$N_log
+index index.html index.htm index.jsp index.php;
+root $vhostdir;
+#error_page 404 /404.html;
+#if ( \$query_string ~* ".*[\;'\<\>].*" ){
+#        return 404;
+#        }
+$anti_hotlinking
+location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+        expires 30d;
+        }
+
+location ~ .*\.(js|css)?$ {
+        expires 7d;
+        }
+
+`echo -e $NGX_CONF`
+}
+EOF
+
+sed -i "s@autoDeploy=\"true\">@autoDeploy=\"true\">\n\t<Context path=\"\" docBase=\"$vhostdir\" debug=\"0\" reloadable=\"true\" crossContext=\"true\"/>@" $tomcat_install_dir/conf/server.xml
+
+echo
+$web_install_dir/sbin/nginx -t
+if [ $? == 0 ];then
+        echo "Restart Nginx......"
+        $web_install_dir/sbin/nginx -s reload
+else
+        rm -rf $web_install_dir/conf/vhost/$domain.conf
+        echo -e "Create virtualhost ... \033[31m[FAILED]\033[0m"
+        exit 1
+fi
+
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+echo -e "`printf "%-32s" "Your domain:"`\033[32m$domain\033[0m"
+echo -e "`printf "%-32s" "Virtualhost conf:"`\033[32m$web_install_dir/conf/vhost/$domain.conf\033[0m"
+echo -e "`printf "%-32s" "Directory of:"`\033[32m$vhostdir\033[0m"
+
+}
+
+Create_nginx_php-fpm_conf()
+{
+[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
+cat > $web_install_dir/conf/vhost/$domain.conf << EOF
+server {
+listen 80;
+server_name $domain$moredomainame;
+$N_log
+index index.html index.htm index.jsp index.php;
+include $rewrite.conf;
+root $vhostdir;
+#error_page 404 /404.html;
+if ( \$query_string ~* ".*[\;'\<\>].*" ){
+	return 404;
+	}
+$anti_hotlinking
+`echo -e $NGX_CONF`
+
+location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+	expires 30d;
+	}
+
+location ~ .*\.(js|css)?$ {
+	expires 7d;
+	}
+}
+EOF
+
+echo
+$web_install_dir/sbin/nginx -t
+if [ $? == 0 ];then
+	echo "Restart Nginx......"
+	$web_install_dir/sbin/nginx -s reload
+else
+	rm -rf $web_install_dir/conf/vhost/$domain.conf
+	echo -e "Create virtualhost ... \033[31m[FAILED]\033[0m"
+	exit 1
+fi
+
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+echo -e "`printf "%-32s" "Your domain:"`\033[32m$domain\033[0m"
+echo -e "`printf "%-32s" "Virtualhost conf:"`\033[32m$web_install_dir/conf/vhost/$domain.conf\033[0m"
+echo -e "`printf "%-32s" "Directory of:"`\033[32m$vhostdir\033[0m"
+[ "$rewrite_yn" == 'y' ] && echo -e "`printf "%-32s" "Rewrite rule:"`\033[32m$rewrite\033[0m" 
+}
+
+Apache_log()
+{
+while :
+do
+        echo ''
+        read -p "Allow Apache access_log? [y/n]: " access_yn
+        if [ "$access_yn" != 'y' ] && [ "$access_yn" != 'n' ];then
+                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
+        else
+                break
+        fi
+done
+
+if [ "$access_yn" == 'n' ]; then
+        A_log='CustomLog "/dev/null" common'
+else
+        A_log="CustomLog \"/home/wwwlogs/${domain}_apache.log\" common"
+        echo "You access log file=/home/wwwlogs/${domain}_apache.log"
+fi
+}
+
+Create_apache_conf()
+{
+[ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
+[ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
+cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
+<VirtualHost *:80>
+    ServerAdmin admin@linuxeye.com 
+    DocumentRoot "$vhostdir"
+    ServerName $domain
+    $Domain_alias
+    ErrorLog "/home/wwwlogs/${domain}_error_apache.log"
+    $A_log
+<Directory "$vhostdir">
+    SetOutputFilter DEFLATE
+    Options FollowSymLinks
+    $R_TMP
+    AllowOverride All
+    Order allow,deny
+    Allow from all
+    DirectoryIndex index.html index.php
+</Directory>
+</VirtualHost>
+EOF
+
+echo
+$apache_install_dir/bin/apachectl -t
+if [ $? == 0 ];then
+	echo "Restart Apache......"
+	/etc/init.d/httpd restart
+else
+	rm -rf $apache_install_dir/conf/vhost/$domain.conf
+	echo -e "Create virtualhost ... \033[31m[FAILED]\033[0m"
+	exit 1
+fi
+
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+echo -e "`printf "%-32s" "Your domain:"`\033[32m$domain\033[0m"
+echo -e "`printf "%-32s" "Virtualhost conf:"`\033[32m$apache_install_dir/conf/vhost/$domain.conf\033[0m"
+echo -e "`printf "%-32s" "Directory of $domain:"`\033[32m$vhostdir\033[0m"
+}
+
+Create_nginx_apache_mod-php_conf()
+{
+# Nginx/Tengine
+[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
+cat > $web_install_dir/conf/vhost/$domain.conf << EOF
+server {
+listen 80;
+server_name $domain$moredomainame;
+$N_log
+index index.html index.htm index.jsp index.php;
+root $vhostdir;
+#error_page 404 /404.html;
+if ( \$query_string ~* ".*[\;'\<\>].*" ){
+        return 404;
+        }
+$anti_hotlinking
+location / {
+        try_files \$uri @apache;
+        }
+
+location @apache {
+        internal;
+        proxy_pass http://127.0.0.1:9090;
+	}
+
+location ~ .*\.(php|php5)?$ {
+        proxy_pass http://127.0.0.1:9090;
+        }
+location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+        expires 30d;
+        }
+
+location ~ .*\.(js|css)?$ {
+        expires 7d;
+        }
+}
+EOF
+
+echo
+$web_install_dir/sbin/nginx -t
+if [ $? == 0 ];then
+        echo "Restart Nginx......"
+        $web_install_dir/sbin/nginx -s reload
+else
+        rm -rf $web_install_dir/conf/vhost/$domain.conf
+	echo -e "Create virtualhost ... \033[31m[FAILED]\033[0m"
+fi
+
+# Apache
+[ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
+[ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
+cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
+<VirtualHost *:9090>
+    ServerAdmin admin@linuxeye.com
+    DocumentRoot "$vhostdir"
+    ServerName $domain
+    $Domain_alias
+    ErrorLog "/home/wwwlogs/${domain}_error_apache.log"
+    $A_log
+<Directory "$vhostdir">
+    SetOutputFilter DEFLATE
+    Options FollowSymLinks
+    $R_TMP
+    AllowOverride All
+    Order allow,deny
+    Allow from all
+    DirectoryIndex index.html index.php
+</Directory>
+</VirtualHost>
+EOF
+
+echo
+$apache_install_dir/bin/apachectl -t
+if [ $? == 0 ];then
+        echo "Restart Apache......"
+        /etc/init.d/httpd restart
+else
+        rm -rf $apache_install_dir/conf/vhost/$domain.conf
+	exit 1
+fi
+
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+echo -e "`printf "%-32s" "Your domain:"`\033[32m$domain\033[0m"
+echo -e "`printf "%-32s" "Nginx Virtualhost conf:"`\033[32m$web_install_dir/conf/vhost/$domain.conf\033[0m"
+echo -e "`printf "%-32s" "Apache Virtualhost conf:"`\033[32m$apache_install_dir/conf/vhost/$domain.conf\033[0m"
+echo -e "`printf "%-32s" "Directory of:"`\033[32m$vhostdir\033[0m"
+[ "$rewrite_yn" == 'y' ] && echo -e "`printf "%-32s" "Rewrite rule:"`\033[32m$rewrite\033[0m" 
+}
+
+if [ -d "$web_install_dir" -a ! -d "$apache_install_dir" -a "$web_install_dir" != "$apache_install_dir" ];then
+	Choose_env
+	Input_domain
+	Nginx_anti_hotlinking
+	if [ "$Number" == '111' -o "$Number" == '110' -o "$Number" == '011' -o "$Number" == '010' ];then
+		Nginx_log
+		Create_nginx_tomcat_conf
+	else
+		Nginx_rewrite
+		Nginx_log
+		Create_nginx_php-fpm_conf
+	fi
+elif [ -d "$web_install_dir" -a -d "$apache_install_dir" -a "$web_install_dir" == "$apache_install_dir" ];then
+	Choose_env
+	Input_domain
+	Apache_log
+	Create_apache_conf
+elif [ -d "$web_install_dir" -a -d "$apache_install_dir" -a "$web_install_dir" != "$apache_install_dir" ];then
+	Choose_env
+	Input_domain
+	Nginx_anti_hotlinking
+	if [ "$Number" == '111' -o "$Number" == '110' -o "$Number" == '011' -o "$Number" == '010' ];then
+		Nginx_log
+		Create_nginx_tomcat_conf
+	else
+		#Nginx_rewrite
+		Nginx_log
+		Apache_log
+		Create_nginx_apache_mod-php_conf
+	fi
+fi 

+ 112 - 0
vpn_centos.sh

@@ -0,0 +1,112 @@
+#!/bin/bash
+#
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+#
+# Installs a PPTP VPN-only system for CentOS
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#            Installs a PPTP VPN-only system for CentOS               #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+[ ! -e '/usr/bin/curl' ] && yum -y install curl
+
+VPN_IP=`curl ipv4.icanhazip.com`
+
+VPN_USER="linuxeye"
+VPN_PASS="linuxeye"
+
+VPN_LOCAL="192.168.0.150"
+VPN_REMOTE="192.168.0.151-200"
+
+while :
+do
+        echo
+        read -p "Please input username: " VPN_USER 
+        [ -n "$VPN_USER" ] && break
+done
+
+while :
+do
+        echo
+        read -p "Please input password: " VPN_PASS
+        [ -n "$VPN_PASS" ] && break
+done
+clear
+
+
+if [ -f /etc/redhat-release -a -n "`grep ' 7\.' /etc/redhat-release`" ];then
+        #CentOS_REL=7
+	if [ ! -e /etc/yum.repos.d/epel.repo ];then
+		cat > /etc/yum.repos.d/epel.repo << EOF
+[epel]
+name=Extra Packages for Enterprise Linux 7 - \$basearch
+#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
+mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
+failovermethod=priority
+enabled=1
+gpgcheck=0
+EOF
+fi
+        for Package in wget make openssl gcc-c++ ppp pptpd iptables iptables-services 
+        do
+                yum -y install $Package
+        done
+        echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
+elif [ -f /etc/redhat-release -a -n "`grep ' 6\.' /etc/redhat-release`" ];then
+        #CentOS_REL=6
+        for Package in wget make openssl gcc-c++ iptables ppp 
+        do
+                yum -y install $Package
+        done
+	sed -i 's@net.ipv4.ip_forward.*@net.ipv4.ip_forward = 1@g' /etc/sysctl.conf
+	rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
+	yum -y install pptpd
+else
+        echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m"
+        exit 1
+fi
+
+
+echo "1" > /proc/sys/net/ipv4/ip_forward
+
+sysctl -p /etc/sysctl.conf
+
+[ -z "`grep '^localip' /etc/pptpd.conf`" ] && echo "localip $VPN_LOCAL" >> /etc/pptpd.conf # Local IP address of your VPN server
+[ -z "`grep '^remoteip' /etc/pptpd.conf`" ] && echo "remoteip $VPN_REMOTE" >> /etc/pptpd.conf # Scope for your home network
+
+if [ -z "`grep '^ms-dns' /etc/ppp/options.pptpd`" ];then
+	echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd # Google DNS Primary
+	echo "ms-dns 209.244.0.3" >> /etc/ppp/options.pptpd # Level3 Primary
+	echo "ms-dns 208.67.222.222" >> /etc/ppp/options.pptpd # OpenDNS Primary
+fi
+
+echo "$VPN_USER pptpd $VPN_PASS *" >> /etc/ppp/chap-secrets
+
+ETH=`route | grep default | awk '{print $NF}'`
+[ -z "`grep '1723 -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 1723 -j ACCEPT
+[ -z "`grep 'gre -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 5 -p gre -j ACCEPT 
+iptables -t nat -A POSTROUTING -o $ETH -j MASQUERADE
+iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356
+service iptables save
+sed -i 's@^-A INPUT -j REJECT --reject-with icmp-host-prohibited@#-A INPUT -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables 
+sed -i 's@^-A FORWARD -j REJECT --reject-with icmp-host-prohibited@#-A FORWARD -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables 
+service iptables restart
+
+service pptpd restart
+chkconfig pptpd on
+clear
+
+echo -e "You can now connect to your VPN via your external IP \033[32m${VPN_IP}\033[0m"
+
+echo -e "Username: \033[32m${VPN_USER}\033[0m"
+echo -e "Password: \033[32m${VPN_PASS}\033[0m"