1
0

install.sh 45 KB

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