install.sh 45 KB

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