1
0

install.sh 47 KB

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