install.sh 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # For more information please visit https://oneinstack.com #
  16. #######################################################################
  17. "
  18. # Check if user is root
  19. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  20. oneinstack_dir=$(dirname "`readlink -f $0`")
  21. pushd ${oneinstack_dir} > /dev/null
  22. . ./versions.txt
  23. . ./options.conf
  24. . ./include/color.sh
  25. . ./include/check_os.sh
  26. . ./include/check_dir.sh
  27. . ./include/download.sh
  28. . ./include/get_char.sh
  29. dbrootpwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  30. dbpostgrespwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  31. dbmongopwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  32. xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
  33. dbinstallmethod=1
  34. version() {
  35. echo "version: 2.0"
  36. echo "updated date: 2019-01-17"
  37. }
  38. Show_Help() {
  39. version
  40. echo "Usage: $0 command ...[parameters]....
  41. --help, -h Show this help message, More: https://oneinstack.com/auto
  42. --version, -v Show version info
  43. --nginx_option [1-3] Install Nginx server version
  44. --apache_option [1-2] Install Apache server version
  45. --apache_mode_option [1-2] Apache2.4 mode, 1(default): php-fpm, 2: mod_php
  46. --apache_mpm_option [1-3] Apache2.4 MPM, 1(default): event, 2: prefork, 3: worker
  47. --php_option [1-8] Install PHP version
  48. --php_vn [53~73] Install another version of php in OneinStack
  49. --phpcache_option [1-4] Install PHP opcode cache, default: 1 opcache
  50. --php_extensions [ext name] Install PHP extensions, include zendguardloader,ioncube,
  51. sourceguardian,imagick,gmagick,fileinfo,imap,phalcon,
  52. redis,memcached,memcache,mongodb,swoole,xdebug
  53. --tomcat_option [1-4] Install Tomcat version
  54. --jdk_option [1-4] Install JDK version
  55. --db_option [1-15] Install DB version
  56. --dbinstallmethod [1-2] DB install method, default: 1 binary install
  57. --dbrootpwd [password] DB super password
  58. --pureftpd Install Pure-Ftpd
  59. --redis Install Redis
  60. --memcached Install Memcached
  61. --phpmyadmin Install phpMyAdmin
  62. --hhvm Install HHVM
  63. --python Install Python (PATH: ${python_install_dir})
  64. --ssh_port [No.] SSH port
  65. --iptables Enable iptables
  66. --reboot Restart the server after installation
  67. "
  68. }
  69. ARG_NUM=$#
  70. TEMP=`getopt -o hvV --long help,version,nginx_option:,apache_option:,apache_mode_option:,apache_mpm_option:,php_option:,php_vn:,phpcache_option:,php_extensions:,tomcat_option:,jdk_option:,db_option:,dbrootpwd:,dbinstallmethod:,pureftpd,redis,memcached,phpmyadmin,hhvm,python,ssh_port:,iptables,reboot -- "$@" 2>/dev/null`
  71. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  72. eval set -- "${TEMP}"
  73. while :; do
  74. [ -z "$1" ] && break;
  75. case "$1" in
  76. -h|--help)
  77. Show_Help; exit 0
  78. ;;
  79. -v|-V|--version)
  80. version; exit 0
  81. ;;
  82. --nginx_option)
  83. nginx_option=$2; shift 2
  84. [[ ! ${nginx_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}nginx_option input error! Please only input number 1~3${CEND}"; exit 1; }
  85. [ -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; unset nginx_option; }
  86. [ -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; unset nginx_option; }
  87. [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; unset nginx_option; }
  88. ;;
  89. --apache_option)
  90. apache_option=$2; shift 2
  91. [[ ! ${apache_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}apache_option input error! Please only input number 1~2${CEND}"; exit 1; }
  92. [ -e "${apache_install_dir}/bin/httpd" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; unset apache_option; }
  93. ;;
  94. --apache_mode_option)
  95. apache_mode_option=$2; shift 2
  96. [[ ! ${apache_mode_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}apache_mode_option input error! Please only input number 1~2${CEND}"; exit 1; }
  97. ;;
  98. --apache_mpm_option)
  99. apache_mpm_option=$2; shift 2
  100. [[ ! ${apache_mpm_option} =~ ^[1-3]$ ]] && { echo "${CWARNING}apache_mpm_option input error! Please only input number 1~3${CEND}"; exit 1; }
  101. ;;
  102. --php_option)
  103. php_option=$2; shift 2
  104. [[ ! ${php_option} =~ ^[1-8]$ ]] && { echo "${CWARNING}php_option input error! Please only input number 1~8${CEND}"; exit 1; }
  105. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; unset php_option; }
  106. ;;
  107. --php_vn)
  108. php_vn=$2; mphp_flag=y; shift 2
  109. [[ "${php_vn}" =~ ^5[3-6]$|^7[0-3]$ ]] && { echo "${CWARNING}php_vn input error! Please only input number 53~73${CEND}"; exit 1; }
  110. [ -e "${php_install_dir}${php_vn}/bin/phpize" ] && { echo "${CWARNING}PHP${php_vn} already installed! ${CEND}"; unset php_vn mphp_flag; }
  111. ;;
  112. --phpcache_option)
  113. phpcache_option=$2; shift 2
  114. ;;
  115. --php_extensions)
  116. php_extensions=$2; shift 2
  117. [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && pecl_zendguardloader=1
  118. [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && pecl_ioncube=1
  119. [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && pecl_sourceguardian=1
  120. [ -n "`echo ${php_extensions} | grep -w imagick`" ] && pecl_imagick=1
  121. [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && pecl_gmagick=1
  122. [ -n "`echo ${php_extensions} | grep -w fileinfo`" ] && pecl_fileinfo=1
  123. [ -n "`echo ${php_extensions} | grep -w imap`" ] && pecl_imap=1
  124. [ -n "`echo ${php_extensions} | grep -w phalcon`" ] && pecl_phalcon=1
  125. [ -n "`echo ${php_extensions} | grep -w redis`" ] && pecl_redis=1
  126. [ -n "`echo ${php_extensions} | grep -w memcached`" ] && pecl_memcached=1
  127. [ -n "`echo ${php_extensions} | grep -w memcache`" ] && pecl_memcache=1
  128. [ -n "`echo ${php_extensions} | grep -w mongodb`" ] && pecl_mongodb=1
  129. [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1
  130. [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1
  131. ;;
  132. --tomcat_option)
  133. tomcat_option=$2; shift 2
  134. [[ ! ${tomcat_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}tomcat_option input error! Please only input number 1~4${CEND}"; exit 1; }
  135. [ -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; unset tomcat_option; }
  136. ;;
  137. --jdk_option)
  138. jdk_option=$2; shift 2
  139. [[ ! ${jdk_option} =~ ^[1-4]$ ]] && { echo "${CWARNING}jdk_option input error! Please only input number 1~4${CEND}"; exit 1; }
  140. ;;
  141. --db_option)
  142. db_option=$2; shift 2
  143. if [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]]; then
  144. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; unset db_option; }
  145. elif [ "${db_option}" == '14' ]; then
  146. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; unset db_option; }
  147. elif [ "${db_option}" == '15' ]; then
  148. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; unset db_option; }
  149. else
  150. echo "${CWARNING}db_option input error! Please only input number 1~15${CEND}"
  151. exit 1
  152. fi
  153. ;;
  154. --dbrootpwd)
  155. dbrootpwd=$2; shift 2
  156. dbpostgrespwd="${dbrootpwd}"
  157. dbmongopwd="${dbrootpwd}"
  158. ;;
  159. --dbinstallmethod)
  160. dbinstallmethod=$2; shift 2
  161. [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]] && { echo "${CWARNING}dbinstallmethod input error! Please only input number 1~2${CEND}"; exit 1; }
  162. ;;
  163. --pureftpd)
  164. pureftpd_flag=y; shift 1
  165. [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; unset pureftpd_flag; }
  166. ;;
  167. --redis)
  168. redis_flag=y; shift 1
  169. [ -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; unset redis_flag; }
  170. ;;
  171. --memcached)
  172. memcached_flag=y; shift 1
  173. [ -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; unset memcached_flag; }
  174. ;;
  175. --phpmyadmin)
  176. phpmyadmin_flag=y; shift 1
  177. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; unset phpmyadmin_flag; }
  178. ;;
  179. --hhvm)
  180. hhvm_flag=y; shift 1
  181. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; unset hhvm_flag; }
  182. ;;
  183. --python)
  184. python_flag=y; shift 1
  185. ;;
  186. --ssh_port)
  187. ssh_port=$2; shift 2
  188. ;;
  189. --iptables)
  190. iptables_flag=y; shift 1
  191. ;;
  192. --reboot)
  193. reboot_flag=y; shift 1
  194. ;;
  195. --)
  196. shift
  197. ;;
  198. *)
  199. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  200. ;;
  201. esac
  202. done
  203. [ ! -e "${wwwroot_dir}/default" ] && mkdir -p ${wwwroot_dir}/default
  204. [ ! -e "${wwwlogs_dir}" ] && mkdir -p ${wwwlogs_dir}
  205. [ -d /data ] && chmod 755 /data
  206. # Use default SSH port 22. If you use another SSH port on your server
  207. if [ -e "/etc/ssh/sshd_config" ]; then
  208. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1`
  209. while :; do echo
  210. [ ${ARG_NUM} == 0 ] && read -e -p "Please input SSH port(Default: ${now_ssh_port}): " ssh_port
  211. ssh_port=${ssh_port:-${now_ssh_port}}
  212. 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
  213. break
  214. else
  215. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  216. exit 1
  217. fi
  218. done
  219. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "${ssh_port}" != '22' ]; then
  220. sed -i "s@^#Port.*@&\nPort ${ssh_port}@" /etc/ssh/sshd_config
  221. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  222. sed -i "s@^Port.*@Port ${ssh_port}@" /etc/ssh/sshd_config
  223. fi
  224. fi
  225. if [ ${ARG_NUM} == 0 ]; then
  226. if [ ! -e ~/.oneinstack ]; then
  227. # check iptables
  228. while :; do echo
  229. read -e -p "Do you want to enable iptables? [y/n]: " iptables_flag
  230. if [[ ! ${iptables_flag} =~ ^[y,n]$ ]]; then
  231. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  232. else
  233. break
  234. fi
  235. done
  236. fi
  237. # check Web server
  238. while :; do echo
  239. read -e -p "Do you want to install Web server? [y/n]: " web_flag
  240. if [[ ! ${web_flag} =~ ^[y,n]$ ]]; then
  241. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  242. else
  243. if [ "${web_flag}" == 'y' ]; then
  244. # Nginx/Tegine/OpenResty
  245. while :; do echo
  246. echo 'Please select Nginx server:'
  247. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  248. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  249. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  250. echo -e "\t${CMSG}4${CEND}. Do not install"
  251. read -e -p "Please input a number:(Default 1 press Enter) " nginx_option
  252. nginx_option=${nginx_option:-1}
  253. if [[ ! ${nginx_option} =~ ^[1-4]$ ]]; then
  254. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  255. else
  256. [ "${nginx_option}" != '4' -a -e "${nginx_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; unset nginx_option; }
  257. [ "${nginx_option}" != '4' -a -e "${tengine_install_dir}/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; unset nginx_option; }
  258. [ "${nginx_option}" != '4' -a -e "${openresty_install_dir}/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; unset nginx_option; }
  259. break
  260. fi
  261. done
  262. # Apache
  263. while :; do echo
  264. echo 'Please select Apache server:'
  265. echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
  266. echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
  267. echo -e "\t${CMSG}3${CEND}. Do not install"
  268. read -e -p "Please input a number:(Default 3 press Enter) " apache_option
  269. apache_option=${apache_option:-3}
  270. if [[ ! ${apache_option} =~ ^[1-3]$ ]]; then
  271. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  272. else
  273. [ "${apache_option}" != '3' -a -e "${apache_install_dir}/bin/httpd" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; unset apache_option; }
  274. break
  275. fi
  276. done
  277. # Apache2.4 mode and Apache2.4 MPM
  278. if [ "${apache_option}" == '1' ]; then
  279. while :; do echo
  280. echo 'Please select Apache2.4 mode:'
  281. echo -e "\t${CMSG}1${CEND}. php-fpm"
  282. echo -e "\t${CMSG}2${CEND}. mod_php"
  283. read -e -p "Please input a number:(Default 1 press Enter) " apache_mode_option
  284. apache_mode_option=${apache_mode_option:-1}
  285. if [[ ! ${apache_mode_option} =~ ^[1-2]$ ]]; then
  286. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  287. else
  288. break
  289. fi
  290. done
  291. while :; do echo
  292. echo 'Please select Apache2.4 MPM:'
  293. echo -e "\t${CMSG}1${CEND}. event"
  294. echo -e "\t${CMSG}2${CEND}. prefork"
  295. echo -e "\t${CMSG}3${CEND}. worker"
  296. read -e -p "Please input a number:(Default 1 press Enter) " apache_mpm_option
  297. apache_mpm_option=${apache_mpm_option:-1}
  298. if [[ ! ${apache_mpm_option} =~ ^[1-3]$ ]]; then
  299. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  300. else
  301. break
  302. fi
  303. done
  304. fi
  305. # Tomcat
  306. while :; do echo
  307. echo 'Please select tomcat server:'
  308. echo -e "\t${CMSG}1${CEND}. Install Tomcat-9"
  309. echo -e "\t${CMSG}2${CEND}. Install Tomcat-8"
  310. echo -e "\t${CMSG}3${CEND}. Install Tomcat-7"
  311. echo -e "\t${CMSG}4${CEND}. Install Tomcat-6"
  312. echo -e "\t${CMSG}5${CEND}. Do not install"
  313. read -e -p "Please input a number:(Default 5 press Enter) " tomcat_option
  314. tomcat_option=${tomcat_option:-5}
  315. if [[ ! ${tomcat_option} =~ ^[1-5]$ ]]; then
  316. echo "${CWARNING}input error! Please only input number 1~5${CEND}"
  317. else
  318. [ "${tomcat_option}" != '5' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; unset tomcat_option; }
  319. if [ "${tomcat_option}" == '1' ]; then
  320. while :; do echo
  321. echo 'Please select JDK version:'
  322. echo -e "\t${CMSG}1${CEND}. Install JDK-11.0"
  323. echo -e "\t${CMSG}2${CEND}. Install JDK-1.8"
  324. read -e -p "Please input a number:(Default 1 press Enter) " jdk_option
  325. jdk_option=${jdk_option:-1}
  326. if [[ ! ${jdk_option} =~ ^[1-2]$ ]]; then
  327. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  328. else
  329. break
  330. fi
  331. done
  332. elif [ "${tomcat_option}" == '2' ]; then
  333. while :; do echo
  334. echo 'Please select JDK version:'
  335. echo -e "\t${CMSG}1${CEND}. Install JDK-11.0"
  336. echo -e "\t${CMSG}2${CEND}. Install JDK-1.8"
  337. echo -e "\t${CMSG}3${CEND}. Install JDK-1.7"
  338. read -e -p "Please input a number:(Default 2 press Enter) " jdk_option
  339. jdk_option=${jdk_option:-2}
  340. if [[ ! ${jdk_option} =~ ^[1-3]$ ]]; then
  341. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  342. else
  343. break
  344. fi
  345. done
  346. elif [ "${tomcat_option}" == '3' ]; then
  347. while :; do echo
  348. echo 'Please select JDK version:'
  349. echo -e "\t${CMSG}2${CEND}. Install JDK-1.8"
  350. echo -e "\t${CMSG}3${CEND}. Install JDK-1.7"
  351. echo -e "\t${CMSG}4${CEND}. Install JDK-1.6"
  352. read -e -p "Please input a number:(Default 3 press Enter) " jdk_option
  353. jdk_option=${jdk_option:-3}
  354. if [[ ! ${jdk_option} =~ ^[2-4]$ ]]; then
  355. echo "${CWARNING}input error! Please only input number 2~4${CEND}"
  356. else
  357. break
  358. fi
  359. done
  360. elif [ "${tomcat_option}" == '4' ]; then
  361. while :; do echo
  362. echo 'Please select JDK version:'
  363. echo -e "\t${CMSG}3${CEND}. Install JDK-1.7"
  364. echo -e "\t${CMSG}4${CEND}. Install JDK-1.6"
  365. read -e -p "Please input a number:(Default 4 press Enter) " jdk_option
  366. jdk_option=${jdk_option:-4}
  367. if [[ ! ${jdk_option} =~ ^[3-4]$ ]]; then
  368. echo "${CWARNING}input error! Please only input number 3~4${CEND}"
  369. else
  370. break
  371. fi
  372. done
  373. fi
  374. break
  375. fi
  376. done
  377. fi
  378. break
  379. fi
  380. done
  381. # choice database
  382. while :; do echo
  383. read -e -p "Do you want to install Database? [y/n]: " db_flag
  384. if [[ ! ${db_flag} =~ ^[y,n]$ ]]; then
  385. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  386. else
  387. if [ "${db_flag}" == 'y' ]; then
  388. while :; do echo
  389. echo 'Please select a version of the Database:'
  390. echo -e "\t${CMSG} 1${CEND}. Install MySQL-8.0"
  391. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.7"
  392. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.6"
  393. echo -e "\t${CMSG} 4${CEND}. Install MySQL-5.5"
  394. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.3"
  395. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.2"
  396. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-10.1"
  397. echo -e "\t${CMSG} 8${CEND}. Install MariaDB-10.0"
  398. echo -e "\t${CMSG} 9${CEND}. Install MariaDB-5.5"
  399. echo -e "\t${CMSG}10${CEND}. Install Percona-5.7"
  400. echo -e "\t${CMSG}11${CEND}. Install Percona-5.6"
  401. echo -e "\t${CMSG}12${CEND}. Install Percona-5.5"
  402. echo -e "\t${CMSG}13${CEND}. Install AliSQL-5.6"
  403. echo -e "\t${CMSG}14${CEND}. Install PostgreSQL"
  404. echo -e "\t${CMSG}15${CEND}. Install MongoDB"
  405. read -e -p "Please input a number:(Default 2 press Enter) " db_option
  406. db_option=${db_option:-2}
  407. [[ "${db_option}" =~ ^5$|^15$ ]] && [ "${OS_BIT}" == '32' ] && { echo "${CWARNING}By not supporting 32-bit! ${CEND}"; continue; }
  408. if [[ "${db_option}" =~ ^[1-9]$|^1[0-5]$ ]]; then
  409. if [ "${db_option}" == '14' ]; then
  410. [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; unset db_option; break; }
  411. elif [ "${db_option}" == '15' ]; then
  412. [ -e "${mongo_install_dir}/bin/mongo" ] && { echo "${CWARNING}MongoDB already installed! ${CEND}"; unset db_option; break; }
  413. else
  414. [ -d "${db_install_dir}/support-files" ] && { echo "${CWARNING}MySQL already installed! ${CEND}"; unset db_option; break; }
  415. fi
  416. while :; do
  417. if [ "${db_option}" == '14' ]; then
  418. read -e -p "Please input the postgres password of PostgreSQL(default: ${dbpostgrespwd}): " dbpwd
  419. dbpwd=${dbpwd:-${dbpostgrespwd}}
  420. elif [ "${db_option}" == '15' ]; then
  421. read -e -p "Please input the root password of MongoDB(default: ${dbmongopwd}): " dbpwd
  422. dbpwd=${dbpwd:-${dbmongopwd}}
  423. else
  424. read -e -p "Please input the root password of MySQL(default: ${dbrootpwd}): " dbpwd
  425. dbpwd=${dbpwd:-${dbrootpwd}}
  426. fi
  427. [ -n "`echo ${dbpwd} | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  428. if (( ${#dbpwd} >= 5 )); then
  429. if [ "${db_option}" == '14' ]; then
  430. dbpostgrespwd=${dbpwd}
  431. elif [ "${db_option}" == '15' ]; then
  432. dbmongopwd=${dbpwd}
  433. else
  434. dbrootpwd=${dbpwd}
  435. fi
  436. break
  437. else
  438. echo "${CWARNING}password least 5 characters! ${CEND}"
  439. fi
  440. done
  441. # choose install methods
  442. if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  443. while :; do echo
  444. echo "Please choose installation of the database:"
  445. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  446. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  447. read -e -p "Please input a number:(Default 1 press Enter) " dbinstallmethod
  448. dbinstallmethod=${dbinstallmethod:-1}
  449. if [[ ! ${dbinstallmethod} =~ ^[1-2]$ ]]; then
  450. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  451. else
  452. [ "${db_option}" == '5' -a "${LIBC_YN}" != '0' -a "$dbinstallmethod" == '1' ] && { echo "${CWARNING}MariaDB-10.3 binaries require GLIBC 2.14 or higher! ${CEND}"; continue; }
  453. break
  454. fi
  455. done
  456. fi
  457. break
  458. else
  459. echo "${CWARNING}input error! Please only input number 1~15${CEND}"
  460. fi
  461. done
  462. fi
  463. break
  464. fi
  465. done
  466. # choice php
  467. while :; do echo
  468. read -e -p "Do you want to install PHP? [y/n]: " php_flag
  469. if [[ ! ${php_flag} =~ ^[y,n]$ ]]; then
  470. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  471. else
  472. if [ "${php_flag}" == 'y' ]; then
  473. [ -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; unset php_option; break; }
  474. while :; do echo
  475. echo 'Please select a version of the PHP:'
  476. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  477. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  478. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  479. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  480. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  481. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  482. echo -e "\t${CMSG}7${CEND}. Install php-7.2"
  483. echo -e "\t${CMSG}8${CEND}. Install php-7.3"
  484. read -e -p "Please input a number:(Default 5 press Enter) " php_option
  485. php_option=${php_option:-5}
  486. if [[ ! ${php_option} =~ ^[1-8]$ ]]; then
  487. echo "${CWARNING}input error! Please only input number 1~8${CEND}"
  488. else
  489. break
  490. fi
  491. done
  492. fi
  493. break
  494. fi
  495. done
  496. # check php ver
  497. if [ -e "${php_install_dir}/bin/phpize" ]; then
  498. PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
  499. PHP_main_ver=${PHP_detail_ver%.*}
  500. fi
  501. # PHP opcode cache and extensions
  502. if [[ ${php_option} =~ ^[1-8]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  503. while :; do echo
  504. read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_flag
  505. if [[ ! ${phpcache_flag} =~ ^[y,n]$ ]]; then
  506. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  507. else
  508. if [ "${phpcache_flag}" == 'y' ]; then
  509. if [ "${php_option}" == '1' -o "${PHP_main_ver}" == '5.3' ]; then
  510. while :; do
  511. echo 'Please select a opcode cache of the PHP:'
  512. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  513. echo -e "\t${CMSG}2${CEND}. Install XCache"
  514. echo -e "\t${CMSG}3${CEND}. Install APCU"
  515. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  516. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  517. phpcache_option=${phpcache_option:-1}
  518. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  519. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  520. else
  521. break
  522. fi
  523. done
  524. fi
  525. if [ "${php_option}" == '2' -o "${PHP_main_ver}" == '5.4' ]; then
  526. while :; do
  527. echo 'Please select a opcode cache of the PHP:'
  528. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  529. echo -e "\t${CMSG}2${CEND}. Install XCache"
  530. echo -e "\t${CMSG}3${CEND}. Install APCU"
  531. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  532. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  533. phpcache_option=${phpcache_option:-1}
  534. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  535. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  536. else
  537. break
  538. fi
  539. done
  540. fi
  541. if [ "${php_option}" == '3' -o "${PHP_main_ver}" == '5.5' ]; then
  542. while :; do
  543. echo 'Please select a opcode cache of the PHP:'
  544. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  545. echo -e "\t${CMSG}2${CEND}. Install XCache"
  546. echo -e "\t${CMSG}3${CEND}. Install APCU"
  547. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  548. phpcache_option=${phpcache_option:-1}
  549. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  550. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  551. else
  552. break
  553. fi
  554. done
  555. fi
  556. if [ "${php_option}" == '4' -o "${PHP_main_ver}" == '5.6' ]; then
  557. while :; do
  558. echo 'Please select a opcode cache of the PHP:'
  559. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  560. echo -e "\t${CMSG}2${CEND}. Install XCache"
  561. echo -e "\t${CMSG}3${CEND}. Install APCU"
  562. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  563. phpcache_option=${phpcache_option:-1}
  564. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  565. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  566. else
  567. break
  568. fi
  569. done
  570. fi
  571. if [[ ${php_option} =~ ^[5-8]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-3]$ ]]; then
  572. while :; do
  573. echo 'Please select a opcode cache of the PHP:'
  574. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  575. echo -e "\t${CMSG}3${CEND}. Install APCU"
  576. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  577. phpcache_option=${phpcache_option:-1}
  578. if [[ ! ${phpcache_option} =~ ^[1,3]$ ]]; then
  579. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  580. else
  581. break
  582. fi
  583. done
  584. fi
  585. fi
  586. break
  587. fi
  588. done
  589. # set xcache passwd
  590. if [ "${phpcache_option}" == '2' ]; then
  591. while :; do
  592. read -e -p "Please input xcache admin password: " xcachepwd
  593. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  594. done
  595. fi
  596. # PHP extension
  597. while :; do
  598. echo
  599. echo 'Please select PHP extensions:'
  600. echo -e "\t${CMSG} 0${CEND}. Do not install"
  601. echo -e "\t${CMSG} 1${CEND}. Install zendguardloader(PHP<=5.6)"
  602. echo -e "\t${CMSG} 2${CEND}. Install ioncube"
  603. echo -e "\t${CMSG} 3${CEND}. Install sourceguardian(PHP<=7.2)"
  604. echo -e "\t${CMSG} 4${CEND}. Install imagick"
  605. echo -e "\t${CMSG} 5${CEND}. Install gmagick"
  606. echo -e "\t${CMSG} 6${CEND}. Install fileinfo"
  607. echo -e "\t${CMSG} 7${CEND}. Install imap"
  608. echo -e "\t${CMSG} 8${CEND}. Install phalcon(PHP>=5.5)"
  609. echo -e "\t${CMSG} 9${CEND}. Install redis"
  610. echo -e "\t${CMSG}10${CEND}. Install memcached"
  611. echo -e "\t${CMSG}11${CEND}. Install memcache(PHP<=7.2)"
  612. echo -e "\t${CMSG}12${CEND}. Install mongodb"
  613. echo -e "\t${CMSG}13${CEND}. Install swoole"
  614. echo -e "\t${CMSG}14${CEND}. Install xdebug(PHP>=5.5)"
  615. read -e -p "Please input numbers:(Default '4 9 10 11' press Enter) " phpext_option
  616. phpext_option=${phpext_option:-'4 9 10 11'}
  617. [ "${phpext_option}" == '0' ] && break
  618. array_phpext=(${phpext_option})
  619. array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
  620. for v in ${array_phpext[@]}
  621. do
  622. [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
  623. done
  624. if [ "${phpext_flag}" == '1' ]; then
  625. unset phpext_flag
  626. echo; echo "${CWARNING}input error! Please only input number 4 9 10 11 and so on${CEND}"; echo
  627. continue
  628. else
  629. [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
  630. [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
  631. [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
  632. [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
  633. [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
  634. [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
  635. [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
  636. [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_phalcon=1
  637. [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_redis=1
  638. [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_memcached=1
  639. [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_memcache=1
  640. [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_mongodb=1
  641. [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_swoole=1
  642. [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_xdebug=1
  643. break
  644. fi
  645. done
  646. fi
  647. # check Pureftpd
  648. while :; do echo
  649. read -e -p "Do you want to install Pure-FTPd? [y/n]: " pureftpd_flag
  650. if [[ ! ${pureftpd_flag} =~ ^[y,n]$ ]]; then
  651. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  652. else
  653. [ "${pureftpd_flag}" == 'y' -a -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; unset pureftpd_flag; }
  654. break
  655. fi
  656. done
  657. # check phpMyAdmin
  658. if [[ ${php_option} =~ ^[1-8]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  659. while :; do echo
  660. read -e -p "Do you want to install phpMyAdmin? [y/n]: " phpmyadmin_flag
  661. if [[ ! ${phpmyadmin_flag} =~ ^[y,n]$ ]]; then
  662. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  663. else
  664. [ "${phpmyadmin_flag}" == 'y' -a -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; unset phpmyadmin_flag; }
  665. break
  666. fi
  667. done
  668. fi
  669. # check redis
  670. while :; do echo
  671. read -e -p "Do you want to install redis-server? [y/n]: " redis_flag
  672. if [[ ! ${redis_flag} =~ ^[y,n]$ ]]; then
  673. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  674. else
  675. [ "${redis_flag}" == 'y' -a -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; unset redis_flag; }
  676. break
  677. fi
  678. done
  679. # check memcached
  680. while :; do echo
  681. read -e -p "Do you want to install memcached-server? [y/n]: " memcached_flag
  682. if [[ ! ${memcached_flag} =~ ^[y,n]$ ]]; then
  683. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  684. else
  685. [ "${memcached_flag}" == 'y' -a -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; unset memcached_flag; }
  686. break
  687. fi
  688. done
  689. while :; do echo
  690. read -e -p "Do you want to install HHVM? [y/n]: " hhvm_flag
  691. if [[ ! ${hhvm_flag} =~ ^[y,n]$ ]]; then
  692. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  693. else
  694. if [ "${hhvm_flag}" == 'y' ]; then
  695. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; unset hhvm_flag; break; }
  696. if [ "${PM}" == 'yum' -a "${OS_BIT}" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  697. break
  698. else
  699. echo
  700. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  701. echo "Press Ctrl+c to cancel or Press any key to continue..."
  702. char=`get_char`
  703. unset hhvm_flag
  704. fi
  705. fi
  706. break
  707. fi
  708. done
  709. fi
  710. # install wget gcc curl python
  711. if [ ! -e ~/.oneinstack ]; then
  712. [ "${PM}" == 'apt-get' ] && apt-get -y update
  713. [ "${PM}" == 'yum' ] && yum clean all
  714. ${PM} -y -q install wget gcc curl python
  715. fi
  716. # get the IP information
  717. IPADDR=$(./include/get_ipaddr.py)
  718. PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
  719. IPADDR_COUNTRY=$(./include/get_ipaddr_state.py ${PUBLIC_IPADDR})
  720. # Check download source packages
  721. . ./include/check_download.sh
  722. downloadDepsSrc=1
  723. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  724. # del openssl for jcloud
  725. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  726. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  727. # get OS Memory
  728. . ./include/memory.sh
  729. if [ ! -e ~/.oneinstack ]; then
  730. # Check binary dependencies packages
  731. . ./include/check_sw.sh
  732. case "${OS}" in
  733. "CentOS")
  734. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  735. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  736. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  737. ;;
  738. "Debian")
  739. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  740. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  741. ;;
  742. "Ubuntu")
  743. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  744. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  745. ;;
  746. esac
  747. # Install dependencies from source package
  748. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  749. fi
  750. # start Time
  751. startTime=`date +%s`
  752. # Jemalloc
  753. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]]; then
  754. . include/jemalloc.sh
  755. Install_Jemalloc | tee -a ${oneinstack_dir}/install.log
  756. fi
  757. # openSSL
  758. if [[ ${tomcat_option} =~ ^[1-4]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${php_option} =~ ^[1-8]$ ]]; then
  759. . include/openssl.sh
  760. Install_openSSL | tee -a ${oneinstack_dir}/install.log
  761. fi
  762. # Database
  763. case "${db_option}" in
  764. 1)
  765. [ "${OS}" == 'CentOS' -a "${CentOS_ver}" != '7' ] && dbinstallmethod=1
  766. . include/mysql-8.0.sh
  767. Install_MySQL80 2>&1 | tee -a ${oneinstack_dir}/install.log
  768. ;;
  769. 2)
  770. . include/mysql-5.7.sh
  771. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  772. ;;
  773. 3)
  774. . include/mysql-5.6.sh
  775. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  776. ;;
  777. 4)
  778. . include/mysql-5.5.sh
  779. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  780. ;;
  781. 5)
  782. . include/mariadb-10.3.sh
  783. Install_MariaDB103 2>&1 | tee -a ${oneinstack_dir}/install.log
  784. ;;
  785. 6)
  786. . include/mariadb-10.2.sh
  787. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  788. ;;
  789. 7)
  790. . include/mariadb-10.1.sh
  791. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  792. ;;
  793. 8)
  794. . include/mariadb-10.0.sh
  795. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  796. ;;
  797. 9)
  798. . include/mariadb-5.5.sh
  799. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  800. ;;
  801. 10)
  802. . include/percona-5.7.sh
  803. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  804. ;;
  805. 11)
  806. . include/percona-5.6.sh
  807. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  808. ;;
  809. 12)
  810. . include/percona-5.5.sh
  811. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  812. ;;
  813. 13)
  814. . include/alisql-5.6.sh
  815. Install_AliSQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  816. ;;
  817. 14)
  818. . include/postgresql.sh
  819. Install_PostgreSQL 2>&1 | tee -a ${oneinstack_dir}/install.log
  820. ;;
  821. 15)
  822. . include/mongodb.sh
  823. Install_MongoDB 2>&1 | tee -a ${oneinstack_dir}/install.log
  824. ;;
  825. esac
  826. # Nginx server
  827. case "${nginx_option}" in
  828. 1)
  829. . include/nginx.sh
  830. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  831. ;;
  832. 2)
  833. . include/tengine.sh
  834. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  835. ;;
  836. 3)
  837. . include/openresty.sh
  838. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  839. ;;
  840. esac
  841. # Apache
  842. if [ "${apache_option}" == '1' ]; then
  843. . include/apache-2.4.sh
  844. Install_Apache24 2>&1 | tee -a ${oneinstack_dir}/install.log
  845. elif [ "${apache_option}" == '2' ]; then
  846. . include/apache-2.2.sh
  847. Install_Apache22 2>&1 | tee -a ${oneinstack_dir}/install.log
  848. fi
  849. # PHP
  850. case "${php_option}" in
  851. 1)
  852. . include/php-5.3.sh
  853. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  854. ;;
  855. 2)
  856. . include/php-5.4.sh
  857. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  858. ;;
  859. 3)
  860. . include/php-5.5.sh
  861. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  862. ;;
  863. 4)
  864. . include/php-5.6.sh
  865. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  866. ;;
  867. 5)
  868. . include/php-7.0.sh
  869. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  870. ;;
  871. 6)
  872. . include/php-7.1.sh
  873. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  874. ;;
  875. 7)
  876. . include/php-7.2.sh
  877. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  878. ;;
  879. 8)
  880. . include/php-7.3.sh
  881. Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
  882. ;;
  883. esac
  884. # PHP opcode cache
  885. case "${phpcache_option}" in
  886. 1)
  887. . include/zendopcache.sh
  888. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  889. ;;
  890. 2)
  891. . include/xcache.sh
  892. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  893. ;;
  894. 3)
  895. . include/apcu.sh
  896. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  897. ;;
  898. 4)
  899. . include/eaccelerator.sh
  900. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  901. ;;
  902. esac
  903. # ZendGuardLoader
  904. if [ "${pecl_zendguardloader}" == '1' ]; then
  905. . include/ZendGuardLoader.sh
  906. Install_ZendGuardLoader 2>&1 | tee -a ${oneinstack_dir}/install.log
  907. fi
  908. # ioncube
  909. if [ "${pecl_ioncube}" == '1' ]; then
  910. . include/ioncube.sh
  911. Install_ionCube 2>&1 | tee -a ${oneinstack_dir}/install.log
  912. fi
  913. # SourceGuardian
  914. if [ "${pecl_sourceguardian}" == '1' ]; then
  915. . include/sourceguardian.sh
  916. Install_SourceGuardian 2>&1 | tee -a ${oneinstack_dir}/install.log
  917. fi
  918. # imagick
  919. if [ "${pecl_imagick}" == '1' ]; then
  920. . include/ImageMagick.sh
  921. Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  922. Install_pecl_imagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  923. fi
  924. # gmagick
  925. if [ "${pecl_gmagick}" == '1' ]; then
  926. . include/GraphicsMagick.sh
  927. Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  928. Install_pecl_gmagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  929. fi
  930. # fileinfo
  931. if [ "${pecl_fileinfo}" == '1' ]; then
  932. . include/pecl_fileinfo.sh
  933. Install_pecl_fileinfo 2>&1 | tee -a ${oneinstack_dir}/install.log
  934. fi
  935. # imap
  936. if [ "${pecl_imap}" == '1' ]; then
  937. . include/pecl_imap.sh
  938. Install_pecl_imap 2>&1 | tee -a ${oneinstack_dir}/install.log
  939. fi
  940. # phalcon
  941. if [ "${pecl_phalcon}" == '1' ]; then
  942. . include/pecl_phalcon.sh
  943. Install_pecl_phalcon 2>&1 | tee -a ${oneinstack_dir}/install.log
  944. fi
  945. # pecl_memcached
  946. if [ "${pecl_memcached}" == '1' ]; then
  947. . include/memcached.sh
  948. Install_pecl_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  949. fi
  950. # pecl_memcache
  951. if [ "${pecl_memcache}" == '1' ]; then
  952. . include/memcached.sh
  953. Install_pecl_memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  954. fi
  955. # pecl_redis
  956. if [ "${pecl_redis}" == '1' ]; then
  957. . include/redis.sh
  958. Install_pecl_redis 2>&1 | tee -a ${oneinstack_dir}/install.log
  959. fi
  960. # pecl_mongodb
  961. if [ "${pecl_mongodb}" == '1' ]; then
  962. . include/pecl_mongodb.sh
  963. Install_pecl_mongodb 2>&1 | tee -a ${oneinstack_dir}/install.log
  964. fi
  965. # swoole
  966. if [ "${pecl_swoole}" == '1' ]; then
  967. . include/pecl_swoole.sh
  968. Install_pecl_swoole 2>&1 | tee -a ${oneinstack_dir}/install.log
  969. fi
  970. # xdebug
  971. if [ "${pecl_xdebug}" == '1' ]; then
  972. . include/pecl_xdebug.sh
  973. Install_pecl_xdebug 2>&1 | tee -a ${oneinstack_dir}/install.log
  974. fi
  975. # pecl_pgsql
  976. if [ -e "${pgsql_install_dir}/bin/psql" ]; then
  977. . include/pecl_pgsql.sh
  978. Install_pecl_pgsql 2>&1 | tee -a ${oneinstack_dir}/install.log
  979. fi
  980. # JDK
  981. case "${jdk_option}" in
  982. 1)
  983. . include/jdk-11.0.sh
  984. Install_JDK110 2>&1 | tee -a ${oneinstack_dir}/install.log
  985. ;;
  986. 2)
  987. . include/jdk-1.8.sh
  988. Install_JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  989. ;;
  990. 3)
  991. . include/jdk-1.7.sh
  992. Install_JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  993. ;;
  994. 4)
  995. . include/jdk-1.6.sh
  996. Install_JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  997. ;;
  998. esac
  999. case "${tomcat_option}" in
  1000. 1)
  1001. . include/tomcat-9.sh
  1002. Install_Tomcat9 2>&1 | tee -a ${oneinstack_dir}/install.log
  1003. ;;
  1004. 2)
  1005. . include/tomcat-8.sh
  1006. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  1007. ;;
  1008. 3)
  1009. . include/tomcat-7.sh
  1010. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  1011. ;;
  1012. 4)
  1013. . include/tomcat-6.sh
  1014. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  1015. ;;
  1016. esac
  1017. # Pure-FTPd
  1018. if [ "${pureftpd_flag}" == 'y' ]; then
  1019. . include/pureftpd.sh
  1020. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  1021. fi
  1022. # phpMyAdmin
  1023. if [ "${phpmyadmin_flag}" == 'y' ]; then
  1024. . include/phpmyadmin.sh
  1025. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  1026. fi
  1027. # redis
  1028. if [ "${redis_flag}" == 'y' ]; then
  1029. . include/redis.sh
  1030. Install_redis_server 2>&1 | tee -a ${oneinstack_dir}/install.log
  1031. fi
  1032. # memcached
  1033. if [ "${memcached_flag}" == 'y' ]; then
  1034. . include/memcached.sh
  1035. Install_memcached_server 2>&1 | tee -a ${oneinstack_dir}/install.log
  1036. fi
  1037. # index example
  1038. if [ ! -e "${wwwroot_dir}/default/index.html" ]; then
  1039. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${tomcat_option} =~ ^[1-4]$ ]]; then
  1040. . include/demo.sh
  1041. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  1042. fi
  1043. fi
  1044. # get web_install_dir and db_install_dir
  1045. . include/check_dir.sh
  1046. # HHVM
  1047. if [ "${hhvm_flag}" == 'y' ] && [ "${PM}" == 'yum' -a "${OS_BIT}" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  1048. . include/hhvm_CentOS.sh
  1049. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  1050. fi
  1051. # Python
  1052. if [ "${python_flag}" == 'y' ]; then
  1053. . include/python.sh
  1054. Install_Python 2>&1 | tee -a ${oneinstack_dir}/install.log
  1055. fi
  1056. # Starting DB
  1057. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  1058. [ -d "${db_install_dir}/support-files" ] && service mysqld start
  1059. # reload php
  1060. [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
  1061. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  1062. endTime=`date +%s`
  1063. ((installTime=($endTime-$startTime)/60))
  1064. echo "####################Congratulations########################"
  1065. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  1066. [[ "${nginx_option}" =~ ^[1-3]$ ]] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  1067. [[ "${apache_option}" =~ ^[1-2]$ ]] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  1068. [[ "${tomcat_option}" =~ ^[1-4]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  1069. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  1070. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  1071. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  1072. [[ "${db_option}" =~ ^[1-9]$|^1[0-3]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  1073. [ "${db_option}" == '14' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  1074. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  1075. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  1076. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  1077. [ "${db_option}" == '15' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  1078. [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  1079. [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  1080. [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  1081. [[ "${php_option}" =~ ^[1-8]$ ]] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  1082. [ "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  1083. [ "${phpcache_option}" == '2' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  1084. [ "${phpcache_option}" == '2' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  1085. [ "${phpcache_option}" == '2' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
  1086. [ "${phpcache_option}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  1087. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  1088. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  1089. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  1090. [ "${pureftpd_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  1091. [ "${pureftpd_flag}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  1092. [ "${phpmyadmin_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  1093. [ "${phpmyadmin_flag}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  1094. [ "${redis_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  1095. [ "${memcached_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  1096. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${tomcat_option} =~ ^[1-4]$ ]]; then
  1097. echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  1098. fi
  1099. if [ ${ARG_NUM} == 0 ]; then
  1100. while :; do echo
  1101. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  1102. read -e -p "Do you want to restart OS ? [y/n]: " reboot_flag
  1103. if [[ ! "${reboot_flag}" =~ ^[y,n]$ ]]; then
  1104. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  1105. else
  1106. break
  1107. fi
  1108. done
  1109. fi
  1110. [ "${reboot_flag}" == 'y' ] && reboot