install.sh 45 KB

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