install.sh 48 KB

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