install.sh 49 KB

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