1
0

install.sh 50 KB

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