install.sh 49 KB

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