1
0

install.sh 48 KB

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