install.sh 47 KB

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