1
0

install.sh 48 KB

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