install.sh 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  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-3]$ ]] && {
  137. echo "${CWARNING}php_option input error! Please only input number 1~12${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}/nginx/sbin/nginx" ] && {
  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. read -e -p "Please input a number:(Default 7 press Enter) " php_option
  640. php_option=${php_option:-7}
  641. if [[ ! ${php_option} =~ ^[1-9]$|^1[0-3]$ ]]; then
  642. echo "${CWARNING}input error! Please only input number 1~13${CEND}"
  643. else
  644. break
  645. fi
  646. done
  647. fi
  648. break
  649. fi
  650. done
  651. # check php ver
  652. if [ -e "${php_install_dir}/bin/phpize" ]; then
  653. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  654. PHP_main_ver=${PHP_detail_ver%.*}
  655. fi
  656. # PHP opcode cache and extensions
  657. if [[ ${php_option} =~ ^[1-9]$|^1[0-3]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  658. while :; do echo
  659. read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_flag
  660. if [[ ! ${phpcache_flag} =~ ^[y,n]$ ]]; then
  661. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  662. else
  663. if [ "${phpcache_flag}" == 'y' ]; then
  664. if [ "${php_option}" == '1' -o "${PHP_main_ver}" == '5.3' ]; then
  665. while :; do
  666. echo 'Please select a opcode cache of the PHP:'
  667. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  668. echo -e "\t${CMSG}2${CEND}. Install APCU"
  669. echo -e "\t${CMSG}3${CEND}. Install XCache"
  670. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  671. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  672. phpcache_option=${phpcache_option:-1}
  673. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  674. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  675. else
  676. break
  677. fi
  678. done
  679. fi
  680. if [ "${php_option}" == '2' -o "${PHP_main_ver}" == '5.4' ]; then
  681. while :; do
  682. echo 'Please select a opcode cache of the PHP:'
  683. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  684. echo -e "\t${CMSG}2${CEND}. Install APCU"
  685. echo -e "\t${CMSG}3${CEND}. Install XCache"
  686. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  687. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  688. phpcache_option=${phpcache_option:-1}
  689. if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
  690. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  691. else
  692. break
  693. fi
  694. done
  695. fi
  696. if [ "${php_option}" == '3' -o "${PHP_main_ver}" == '5.5' ]; then
  697. while :; do
  698. echo 'Please select a opcode cache of the PHP:'
  699. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  700. echo -e "\t${CMSG}2${CEND}. Install APCU"
  701. echo -e "\t${CMSG}3${CEND}. Install XCache"
  702. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  703. phpcache_option=${phpcache_option:-1}
  704. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  705. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  706. else
  707. break
  708. fi
  709. done
  710. fi
  711. if [ "${php_option}" == '4' -o "${PHP_main_ver}" == '5.6' ]; then
  712. while :; do
  713. echo 'Please select a opcode cache of the PHP:'
  714. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  715. echo -e "\t${CMSG}2${CEND}. Install APCU"
  716. echo -e "\t${CMSG}3${CEND}. Install XCache"
  717. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  718. phpcache_option=${phpcache_option:-1}
  719. if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
  720. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  721. else
  722. break
  723. fi
  724. done
  725. fi
  726. if [[ ${php_option} =~ ^[5-9]$|^1[0-3]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-3]$ ]]; then
  727. while :; do
  728. echo 'Please select a opcode cache of the PHP:'
  729. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  730. echo -e "\t${CMSG}2${CEND}. Install APCU"
  731. read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
  732. phpcache_option=${phpcache_option:-1}
  733. if [[ ! ${phpcache_option} =~ ^[1-2]$ ]]; then
  734. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  735. else
  736. break
  737. fi
  738. done
  739. fi
  740. fi
  741. break
  742. fi
  743. done
  744. # set xcache passwd
  745. if [ "${phpcache_option}" == '3' ]; then
  746. while :; do
  747. read -e -p "Please input xcache admin password: " xcachepwd
  748. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  749. done
  750. fi
  751. # PHP extension
  752. while :; do
  753. echo
  754. echo 'Please select PHP extensions:'
  755. echo -e "\t${CMSG} 0${CEND}. Do not install"
  756. echo -e "\t${CMSG} 1${CEND}. Install zendguardloader(PHP<=5.6)"
  757. echo -e "\t${CMSG} 2${CEND}. Install ioncube"
  758. echo -e "\t${CMSG} 3${CEND}. Install sourceguardian(PHP<=7.2)"
  759. echo -e "\t${CMSG} 4${CEND}. Install imagick"
  760. echo -e "\t${CMSG} 5${CEND}. Install gmagick"
  761. echo -e "\t${CMSG} 6${CEND}. Install fileinfo"
  762. echo -e "\t${CMSG} 7${CEND}. Install imap"
  763. echo -e "\t${CMSG} 8${CEND}. Install ldap"
  764. echo -e "\t${CMSG} 9${CEND}. Install phalcon(PHP>=5.5)"
  765. echo -e "\t${CMSG}10${CEND}. Install yaf(PHP>=7.0)"
  766. echo -e "\t${CMSG}11${CEND}. Install redis"
  767. echo -e "\t${CMSG}12${CEND}. Install memcached"
  768. echo -e "\t${CMSG}13${CEND}. Install memcache"
  769. echo -e "\t${CMSG}14${CEND}. Install mongodb"
  770. echo -e "\t${CMSG}15${CEND}. Install swoole"
  771. echo -e "\t${CMSG}16${CEND}. Install xdebug(PHP>=5.5)"
  772. read -e -p "Please input numbers:(Default '4 11 12' press Enter) " phpext_option
  773. phpext_option=${phpext_option:-'4 11 12'}
  774. [ "${phpext_option}" == '0' ] && break
  775. array_phpext=(${phpext_option})
  776. array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
  777. for v in ${array_phpext[@]}
  778. do
  779. [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
  780. done
  781. if [ "${phpext_flag}" == '1' ]; then
  782. unset phpext_flag
  783. echo; echo "${CWARNING}input error! Please only input number 4 11 12 and so on${CEND}"; echo
  784. continue
  785. else
  786. [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
  787. [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
  788. [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
  789. [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
  790. [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
  791. [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
  792. [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
  793. [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_ldap=1
  794. [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_phalcon=1
  795. [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_yaf=1
  796. [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_redis=1
  797. [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_memcached=1
  798. [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_memcache=1
  799. [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_mongodb=1
  800. [ -n "`echo ${array_phpext[@]} | grep -w 15`" ] && pecl_swoole=1
  801. [ -n "`echo ${array_phpext[@]} | grep -w 16`" ] && pecl_xdebug=1
  802. break
  803. fi
  804. done
  805. fi
  806. # check Nodejs
  807. while :; do echo
  808. read -e -p "Do you want to install Nodejs? [y/n]: " nodejs_flag
  809. if [[ ! ${nodejs_flag} =~ ^[y,n]$ ]]; then
  810. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  811. else
  812. [ "${nodejs_flag}" == 'y' -a -e "${nodejs_install_dir}/bin/node" ] && { echo "${CWARNING}Nodejs already installed! ${CEND}"; unset nodejs_flag; }
  813. break
  814. fi
  815. done
  816. # check Pureftpd
  817. while :; do echo
  818. read -e -p "Do you want to install Pure-FTPd? [y/n]: " pureftpd_flag
  819. if [[ ! ${pureftpd_flag} =~ ^[y,n]$ ]]; then
  820. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  821. else
  822. [ "${pureftpd_flag}" == 'y' -a -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; unset pureftpd_flag; }
  823. break
  824. fi
  825. done
  826. # check phpMyAdmin
  827. if [[ ${php_option} =~ ^[1-9]$|^1[0-3]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
  828. while :; do echo
  829. read -e -p "Do you want to install phpMyAdmin? [y/n]: " phpmyadmin_flag
  830. if [[ ! ${phpmyadmin_flag} =~ ^[y,n]$ ]]; then
  831. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  832. else
  833. [ "${phpmyadmin_flag}" == 'y' -a -d "${wwwroot_dir}/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; unset phpmyadmin_flag; }
  834. break
  835. fi
  836. done
  837. fi
  838. # check redis
  839. while :; do echo
  840. read -e -p "Do you want to install redis-server? [y/n]: " redis_flag
  841. if [[ ! ${redis_flag} =~ ^[y,n]$ ]]; then
  842. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  843. else
  844. [ "${redis_flag}" == 'y' -a -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; unset redis_flag; }
  845. break
  846. fi
  847. done
  848. # check memcached
  849. while :; do echo
  850. read -e -p "Do you want to install memcached-server? [y/n]: " memcached_flag
  851. if [[ ! ${memcached_flag} =~ ^[y,n]$ ]]; then
  852. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  853. else
  854. [ "${memcached_flag}" == 'y' -a -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; unset memcached_flag; }
  855. break
  856. fi
  857. done
  858. fi
  859. if [[ ${nginx_option} =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [ "${caddy_flag}" == 'y' ] || [[ ${tomcat_option} =~ ^[1-4]$ ]]; then
  860. [ ! -d ${wwwroot_dir}/default ] && mkdir -p ${wwwroot_dir}/default
  861. [ ! -d ${wwwlogs_dir} ] && mkdir -p ${wwwlogs_dir}
  862. fi
  863. [ -d /data ] && chmod 755 /data
  864. # install wget gcc curl
  865. if [ ! -e ~/.oneinstack ]; then
  866. downloadDepsSrc=1
  867. [ "${PM}" == 'apt-get' ] && apt-get -y update > /dev/null
  868. [ "${PM}" == 'yum' ] && yum clean all > /dev/null
  869. ${PM} -y install wget gcc curl > /dev/null
  870. fi
  871. # get the IP information
  872. IPADDR=$(./include/ois.${ARCH} ip_local)
  873. OUTIP_STATE=$(./include/ois.${ARCH} ip_state)
  874. # openSSL
  875. . ./include/openssl.sh
  876. # Check download source packages
  877. . ./include/check_download.sh
  878. [ "${armplatform}" == "y" ] && dbinstallmethod=2
  879. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  880. # get OS Memory
  881. . ./include/memory.sh
  882. if [ ! -e ~/.oneinstack ]; then
  883. # Check binary dependencies packages
  884. . ./include/check_sw.sh
  885. case "${Family}" in
  886. "rhel")
  887. installDepsRHEL 2>&1 | tee ${oneinstack_dir}/install.log
  888. . include/init_RHEL.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  889. ;;
  890. "debian")
  891. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  892. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  893. ;;
  894. "ubuntu")
  895. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  896. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  897. ;;
  898. esac
  899. # Install dependencies from source package
  900. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  901. fi
  902. # start Time
  903. startTime=`date +%s`
  904. # openSSL
  905. Install_openSSL | tee -a ${oneinstack_dir}/install.log
  906. # Jemalloc
  907. if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
  908. . include/jemalloc.sh
  909. Install_Jemalloc | tee -a ${oneinstack_dir}/install.log
  910. fi
  911. # Database
  912. case "${db_option}" in
  913. 1)
  914. . include/mysql-8.0.sh
  915. Install_MySQL80 2>&1 | tee -a ${oneinstack_dir}/install.log
  916. ;;
  917. 2)
  918. . include/mysql-5.7.sh
  919. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  920. ;;
  921. 3)
  922. . include/mysql-5.6.sh
  923. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  924. ;;
  925. 4)
  926. . include/mysql-5.5.sh
  927. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  928. ;;
  929. 5)
  930. . include/mariadb-10.11.sh
  931. Install_MariaDB1011 2>&1 | tee -a ${oneinstack_dir}/install.log
  932. ;;
  933. 6)
  934. . include/mariadb-10.5.sh
  935. Install_MariaDB105 2>&1 | tee -a ${oneinstack_dir}/install.log
  936. ;;
  937. 7)
  938. . include/mariadb-10.4.sh
  939. Install_MariaDB104 2>&1 | tee -a ${oneinstack_dir}/install.log
  940. ;;
  941. 8)
  942. . include/mariadb-5.5.sh
  943. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  944. ;;
  945. 9)
  946. [ "${Family}" == 'rhel' ] && [ "${RHEL_ver}" == '8' ] && dbinstallmethod=2 && checkDownload
  947. . include/percona-8.0.sh
  948. Install_Percona80 2>&1 | tee -a ${oneinstack_dir}/install.log
  949. ;;
  950. 10)
  951. . include/percona-5.7.sh
  952. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  953. ;;
  954. 11)
  955. . include/percona-5.6.sh
  956. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  957. ;;
  958. 12)
  959. . include/percona-5.5.sh
  960. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  961. ;;
  962. 13)
  963. . include/postgresql.sh
  964. Install_PostgreSQL 2>&1 | tee -a ${oneinstack_dir}/install.log
  965. ;;
  966. 14)
  967. . include/mongodb.sh
  968. Install_MongoDB 2>&1 | tee -a ${oneinstack_dir}/install.log
  969. ;;
  970. esac
  971. # Nginx server
  972. case "${nginx_option}" in
  973. 1)
  974. . include/nginx.sh
  975. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  976. ;;
  977. 2)
  978. . include/tengine.sh
  979. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  980. ;;
  981. 3)
  982. . include/openresty.sh
  983. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  984. ;;
  985. 4)
  986. . include/caddy.sh
  987. Install_Caddy 2>&1 | tee -a ${oneinstack_dir}/install.log
  988. caddy_flag='y'
  989. ;;
  990. esac
  991. # Apache
  992. if [ "${apache_flag}" == 'y' ]; then
  993. apache_mode_option=${apache_mode_option:-1}
  994. apache_mpm_option=${apache_mpm_option:-1}
  995. . include/apache.sh
  996. Install_Apache 2>&1 | tee -a ${oneinstack_dir}/install.log
  997. fi
  998. # PHP
  999. case "${php_option}" in
  1000. 1)
  1001. . include/php-5.3.sh
  1002. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  1003. ;;
  1004. 2)
  1005. . include/php-5.4.sh
  1006. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  1007. ;;
  1008. 3)
  1009. . include/php-5.5.sh
  1010. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  1011. ;;
  1012. 4)
  1013. . include/php-5.6.sh
  1014. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  1015. ;;
  1016. 5)
  1017. . include/php-7.0.sh
  1018. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  1019. ;;
  1020. 6)
  1021. . include/php-7.1.sh
  1022. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  1023. ;;
  1024. 7)
  1025. . include/php-7.2.sh
  1026. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  1027. ;;
  1028. 8)
  1029. . include/php-7.3.sh
  1030. Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
  1031. ;;
  1032. 9)
  1033. . include/php-7.4.sh
  1034. Install_PHP74 2>&1 | tee -a ${oneinstack_dir}/install.log
  1035. ;;
  1036. 10)
  1037. . include/php-8.0.sh
  1038. Install_PHP80 2>&1 | tee -a ${oneinstack_dir}/install.log
  1039. ;;
  1040. 11)
  1041. . include/php-8.1.sh
  1042. Install_PHP81 2>&1 | tee -a ${oneinstack_dir}/install.log
  1043. ;;
  1044. 12)
  1045. . include/php-8.2.sh
  1046. Install_PHP82 2>&1 | tee -a ${oneinstack_dir}/install.log
  1047. ;;
  1048. 13)
  1049. . include/php-8.3.sh
  1050. Install_PHP83 2>&1 | tee -a ${oneinstack_dir}/install.log
  1051. ;;
  1052. esac
  1053. PHP_addons() {
  1054. # PHP opcode cache
  1055. case "${phpcache_option}" in
  1056. 1)
  1057. . include/zendopcache.sh
  1058. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1059. ;;
  1060. 2)
  1061. . include/apcu.sh
  1062. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  1063. ;;
  1064. 3)
  1065. . include/xcache.sh
  1066. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1067. ;;
  1068. 4)
  1069. . include/eaccelerator.sh
  1070. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  1071. ;;
  1072. esac
  1073. # ZendGuardLoader
  1074. if [ "${pecl_zendguardloader}" == '1' ]; then
  1075. . include/ZendGuardLoader.sh
  1076. Install_ZendGuardLoader 2>&1 | tee -a ${oneinstack_dir}/install.log
  1077. fi
  1078. # ioncube
  1079. if [ "${pecl_ioncube}" == '1' ]; then
  1080. . include/ioncube.sh
  1081. Install_ionCube 2>&1 | tee -a ${oneinstack_dir}/install.log
  1082. fi
  1083. # SourceGuardian
  1084. if [ "${pecl_sourceguardian}" == '1' ]; then
  1085. . include/sourceguardian.sh
  1086. Install_SourceGuardian 2>&1 | tee -a ${oneinstack_dir}/install.log
  1087. fi
  1088. # imagick
  1089. if [ "${pecl_imagick}" == '1' ]; then
  1090. . include/ImageMagick.sh
  1091. Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1092. Install_pecl_imagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1093. fi
  1094. # gmagick
  1095. if [ "${pecl_gmagick}" == '1' ]; then
  1096. . include/GraphicsMagick.sh
  1097. Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1098. Install_pecl_gmagick 2>&1 | tee -a ${oneinstack_dir}/install.log
  1099. fi
  1100. # fileinfo
  1101. if [ "${pecl_fileinfo}" == '1' ]; then
  1102. . include/pecl_fileinfo.sh
  1103. Install_pecl_fileinfo 2>&1 | tee -a ${oneinstack_dir}/install.log
  1104. fi
  1105. # imap
  1106. if [ "${pecl_imap}" == '1' ]; then
  1107. . include/pecl_imap.sh
  1108. Install_pecl_imap 2>&1 | tee -a ${oneinstack_dir}/install.log
  1109. fi
  1110. # ldap
  1111. if [ "${pecl_ldap}" == '1' ]; then
  1112. . include/pecl_ldap.sh
  1113. Install_pecl_ldap 2>&1 | tee -a ${oneinstack_dir}/install.log
  1114. fi
  1115. # calendar
  1116. if [ "${pecl_calendar}" == '1' ]; then
  1117. . include/pecl_calendar.sh
  1118. Install_pecl_calendar 2>&1 | tee -a ${oneinstack_dir}/install.log
  1119. fi
  1120. # phalcon
  1121. if [ "${pecl_phalcon}" == '1' ]; then
  1122. . include/pecl_phalcon.sh
  1123. Install_pecl_phalcon 2>&1 | tee -a ${oneinstack_dir}/install.log
  1124. fi
  1125. # yaf
  1126. if [ "${pecl_yaf}" == '1' ]; then
  1127. . include/pecl_yaf.sh
  1128. Install_pecl_yaf 2>&1 | tee -a ${oneinstack_dir}/install.log
  1129. fi
  1130. # yar
  1131. if [ "${pecl_yar}" == '1' ]; then
  1132. . include/pecl_yar.sh
  1133. Install_pecl_yar 2>&1 | tee -a ${oneinstack_dir}/install.log
  1134. fi
  1135. # pecl_memcached
  1136. if [ "${pecl_memcached}" == '1' ]; then
  1137. . include/memcached.sh
  1138. Install_pecl_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  1139. fi
  1140. # pecl_memcache
  1141. if [ "${pecl_memcache}" == '1' ]; then
  1142. . include/memcached.sh
  1143. Install_pecl_memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  1144. fi
  1145. # pecl_redis
  1146. if [ "${pecl_redis}" == '1' ]; then
  1147. . include/redis.sh
  1148. Install_pecl_redis 2>&1 | tee -a ${oneinstack_dir}/install.log
  1149. fi
  1150. # pecl_mongodb
  1151. if [ "${pecl_mongodb}" == '1' ]; then
  1152. . include/pecl_mongodb.sh
  1153. Install_pecl_mongodb 2>&1 | tee -a ${oneinstack_dir}/install.log
  1154. fi
  1155. # swoole
  1156. if [ "${pecl_swoole}" == '1' ]; then
  1157. . include/pecl_swoole.sh
  1158. Install_pecl_swoole 2>&1 | tee -a ${oneinstack_dir}/install.log
  1159. fi
  1160. # xdebug
  1161. if [ "${pecl_xdebug}" == '1' ]; then
  1162. . include/pecl_xdebug.sh
  1163. Install_pecl_xdebug 2>&1 | tee -a ${oneinstack_dir}/install.log
  1164. fi
  1165. # pecl_pgsql
  1166. if [ -e "${pgsql_install_dir}/bin/psql" ]; then
  1167. . include/pecl_pgsql.sh
  1168. Install_pecl_pgsql 2>&1 | tee -a ${oneinstack_dir}/install.log
  1169. fi
  1170. }
  1171. [ "${mphp_addons_flag}" != 'y' ] && PHP_addons
  1172. if [ "${mphp_flag}" == 'y' ]; then
  1173. . include/mphp.sh
  1174. Install_MPHP 2>&1 | tee -a ${oneinstack_dir}/install.log
  1175. php_install_dir=${php_install_dir}${mphp_ver}
  1176. PHP_addons
  1177. fi
  1178. # JDK
  1179. case "${jdk_option}" in
  1180. 1)
  1181. . include/openjdk-8.sh
  1182. Install_OpenJDK8 2>&1 | tee -a ${oneinstack_dir}/install.log
  1183. ;;
  1184. 2)
  1185. . include/openjdk-11.sh
  1186. Install_OpenJDK11 2>&1 | tee -a ${oneinstack_dir}/install.log
  1187. ;;
  1188. 3)
  1189. . include/openjdk-17.sh
  1190. Install_OpenJDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  1191. ;;
  1192. esac
  1193. case "${tomcat_option}" in
  1194. 1)
  1195. . include/tomcat-10.sh
  1196. Install_Tomcat10 2>&1 | tee -a ${oneinstack_dir}/install.log
  1197. ;;
  1198. 2)
  1199. . include/tomcat-9.sh
  1200. Install_Tomcat9 2>&1 | tee -a ${oneinstack_dir}/install.log
  1201. ;;
  1202. 3)
  1203. . include/tomcat-8.sh
  1204. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  1205. ;;
  1206. 4)
  1207. . include/tomcat-7.sh
  1208. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  1209. ;;
  1210. esac
  1211. # Nodejs
  1212. if [ "${nodejs_flag}" == 'y' ]; then
  1213. . include/nodejs.sh
  1214. Install_Nodejs 2>&1 | tee -a ${oneinstack_dir}/install.log
  1215. fi
  1216. # Pure-FTPd
  1217. if [ "${pureftpd_flag}" == 'y' ]; then
  1218. . include/pureftpd.sh
  1219. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  1220. fi
  1221. # phpMyAdmin
  1222. if [ "${phpmyadmin_flag}" == 'y' ]; then
  1223. . include/phpmyadmin.sh
  1224. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  1225. fi
  1226. # redis
  1227. if [ "${redis_flag}" == 'y' ]; then
  1228. . include/redis.sh
  1229. Install_redis_server 2>&1 | tee -a ${oneinstack_dir}/install.log
  1230. fi
  1231. # memcached
  1232. if [ "${memcached_flag}" == 'y' ]; then
  1233. . include/memcached.sh
  1234. Install_memcached_server 2>&1 | tee -a ${oneinstack_dir}/install.log
  1235. fi
  1236. # index example
  1237. if [ -d "${wwwroot_dir}/default" ]; then
  1238. . include/demo.sh
  1239. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  1240. fi
  1241. # get web_install_dir and db_install_dir
  1242. . include/check_dir.sh
  1243. # Starting DB
  1244. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  1245. [ -d "${db_install_dir}/support-files" ] && [ -z "`ps -ef | grep mysqld_safe | grep -v grep`" ] && service mysqld start
  1246. # reload php
  1247. [ -e "${php_install_dir}/sbin/php-fpm" ] && { [ -e "/bin/systemctl" ] && systemctl reload php-fpm || service php-fpm reload; }
  1248. [ -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; }
  1249. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  1250. endTime=`date +%s`
  1251. ((installTime=($endTime-$startTime)/60))
  1252. echo "####################Congratulations########################"
  1253. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  1254. [[ "${nginx_option}" =~ ^[1-3]$ ]] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  1255. [ "${apache_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  1256. [ "${caddy_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Caddy install dir":)${CMSG}${caddy_install_dir}${CEND}"
  1257. [[ "${tomcat_option}" =~ ^[1-4]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  1258. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  1259. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  1260. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  1261. [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  1262. [ "${db_option}" == '13' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  1263. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  1264. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  1265. [ "${db_option}" == '13' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  1266. [ "${db_option}" == '14' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  1267. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  1268. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  1269. [ "${db_option}" == '14' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  1270. [[ "${php_option}" =~ ^[1-9]$|^1[0-2]$ ]] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  1271. [ "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  1272. [ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  1273. [ "${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}"
  1274. [ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  1275. [ "${phpcache_option}" == '3' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
  1276. [ "${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}"
  1277. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  1278. [ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  1279. [ "${pureftpd_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  1280. [ "${pureftpd_flag}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  1281. [ "${phpmyadmin_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  1282. [ "${phpmyadmin_flag}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  1283. [ "${redis_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  1284. [ "${memcached_flag}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  1285. if [[ ${nginx_option} =~ ^[1-4]$ ]] || [ "${apache_flag}" == 'y' ] || [[ ${tomcat_option} =~ ^[1-4]$ ]]; then
  1286. echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  1287. fi
  1288. if [ ${ARG_NUM} == 0 ]; then
  1289. while :; do echo
  1290. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  1291. read -e -p "Do you want to restart OS ? [y/n]: " reboot_flag
  1292. if [[ ! "${reboot_flag}" =~ ^[y,n]$ ]]; then
  1293. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  1294. else
  1295. break
  1296. fi
  1297. done
  1298. fi
  1299. [ "${reboot_flag}" == 'y' ] && reboot