install.sh 51 KB

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