install.sh 45 KB

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