install.sh 45 KB

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