install.sh 48 KB

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