1
0

install.sh 47 KB

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