install.sh 49 KB

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