install.sh 48 KB

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