install.sh 46 KB

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