install.sh 47 KB

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