install.sh 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # For more information please visit https://oneinstack.com #
  16. #######################################################################
  17. "
  18. # get pwd
  19. sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
  20. . ./versions.txt
  21. . ./options.conf
  22. . ./include/color.sh
  23. . ./include/check_os.sh
  24. . ./include/check_dir.sh
  25. . ./include/download.sh
  26. . ./include/get_char.sh
  27. # Check if user is root
  28. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  29. mkdir -p $wwwroot_dir/default $wwwlogs_dir
  30. [ -d /data ] && chmod 755 /data
  31. # Use default SSH port 22. If you use another SSH port on your server
  32. if [ -e "/etc/ssh/sshd_config" ]; then
  33. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  34. while :; do echo
  35. read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT
  36. [ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port
  37. 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
  38. break
  39. else
  40. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  41. fi
  42. done
  43. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "$SSH_PORT" != '22' ]; then
  44. sed -i "s@^#Port.*@&\nPort $SSH_PORT@" /etc/ssh/sshd_config
  45. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  46. sed -i "s@^Port.*@Port $SSH_PORT@" /etc/ssh/sshd_config
  47. fi
  48. fi
  49. # check iptables
  50. while :; do echo
  51. read -p "Do you want to enable iptables? [y/n]: " iptables_yn
  52. if [[ ! $iptables_yn =~ ^[y,n]$ ]]; then
  53. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  54. else
  55. break
  56. fi
  57. done
  58. # check Web server
  59. while :; do echo
  60. read -p "Do you want to install Web server? [y/n]: " Web_yn
  61. if [[ ! $Web_yn =~ ^[y,n]$ ]]; then
  62. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  63. else
  64. if [ "$Web_yn" == 'y' ]; then
  65. # Nginx/Tegine/OpenResty
  66. while :; do echo
  67. echo 'Please select Nginx server:'
  68. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  69. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  70. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  71. echo -e "\t${CMSG}4${CEND}. Do not install"
  72. read -p "Please input a number:(Default 1 press Enter) " Nginx_version
  73. [ -z "$Nginx_version" ] && Nginx_version=1
  74. if [[ ! $Nginx_version =~ ^[1-4]$ ]]; then
  75. echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
  76. else
  77. [ "$Nginx_version" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
  78. [ "$Nginx_version" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
  79. [ "$Nginx_version" != '4' -a -e "$openresty_install_dir/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; Nginx_version=Other; }
  80. break
  81. fi
  82. done
  83. # Apache
  84. while :; do echo
  85. echo 'Please select Apache server:'
  86. echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
  87. echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
  88. echo -e "\t${CMSG}3${CEND}. Do not install"
  89. read -p "Please input a number:(Default 3 press Enter) " Apache_version
  90. [ -z "$Apache_version" ] && Apache_version=3
  91. if [[ ! $Apache_version =~ ^[1-3]$ ]]; then
  92. echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
  93. else
  94. [ "$Apache_version" != '3' -a -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; Apache_version=Other; }
  95. break
  96. fi
  97. done
  98. # Tomcat
  99. while :; do echo
  100. echo 'Please select tomcat server:'
  101. echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
  102. echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
  103. echo -e "\t${CMSG}3${CEND}. Install Tomcat-6"
  104. echo -e "\t${CMSG}4${CEND}. Do not install"
  105. read -p "Please input a number:(Default 4 press Enter) " Tomcat_version
  106. [ -z "$Tomcat_version" ] && Tomcat_version=4
  107. if [[ ! $Tomcat_version =~ ^[1-4]$ ]]; then
  108. echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
  109. else
  110. [ "$Tomcat_version" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; }
  111. if [ "$Tomcat_version" == '1' ]; then
  112. while :; do echo
  113. echo 'Please select JDK version:'
  114. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  115. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  116. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  117. [ -z "$JDK_version" ] && JDK_version=2
  118. if [[ ! $JDK_version =~ ^[1-2]$ ]]; then
  119. echo "${CWARNING}input error! Please only input number 1,2${CEND}"
  120. else
  121. break
  122. fi
  123. done
  124. elif [ "$Tomcat_version" == '2' ]; then
  125. while :; do echo
  126. echo 'Please select JDK version:'
  127. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  128. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  129. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  130. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  131. [ -z "$JDK_version" ] && JDK_version=2
  132. if [[ ! $JDK_version =~ ^[1-3]$ ]]; then
  133. echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
  134. else
  135. break
  136. fi
  137. done
  138. elif [ "$Tomcat_version" == '3' ]; then
  139. while :; do echo
  140. echo 'Please select JDK version:'
  141. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  142. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  143. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  144. [ -z "$JDK_version" ] && JDK_version=2
  145. if [[ ! $JDK_version =~ ^[2-3]$ ]]; then
  146. echo "${CWARNING}input error! Please only input number 2,3${CEND}"
  147. else
  148. break
  149. fi
  150. done
  151. fi
  152. break
  153. fi
  154. done
  155. fi
  156. break
  157. fi
  158. done
  159. # choice database
  160. while :; do echo
  161. read -p "Do you want to install Database? [y/n]: " DB_yn
  162. if [[ ! $DB_yn =~ ^[y,n]$ ]]; then
  163. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  164. else
  165. if [ "$DB_yn" == 'y' ]; then
  166. [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; }
  167. while :; do echo
  168. echo 'Please select a version of the Database:'
  169. echo -e "\t${CMSG} 1${CEND}. Install MySQL-5.7"
  170. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.6"
  171. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.5"
  172. echo -e "\t${CMSG} 4${CEND}. Install MariaDB-10.2"
  173. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.1"
  174. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.0"
  175. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-5.5"
  176. echo -e "\t${CMSG} 8${CEND}. Install Percona-5.7"
  177. echo -e "\t${CMSG} 9${CEND}. Install Percona-5.6"
  178. echo -e "\t${CMSG}10${CEND}. Install Percona-5.5"
  179. echo -e "\t${CMSG}11${CEND}. Install AliSQL-5.6"
  180. read -p "Please input a number:(Default 2 press Enter) " DB_version
  181. [ -z "$DB_version" ] && DB_version=2
  182. if [ ${DB_version} -ge 1 >/dev/null 2>&1 -a ${DB_version} -le 11 >/dev/null 2>&1 ]; then
  183. while :; do
  184. read -p "Please input the root password of database: " dbrootpwd
  185. [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  186. (( ${#dbrootpwd} >= 5 )) && sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf && break || echo "${CWARNING}database root password least 5 characters! ${CEND}"
  187. done
  188. # choose install methods
  189. if [ ${DB_version} -ge 1 >/dev/null 2>&1 -a ${DB_version} -le 10 >/dev/null 2>&1 ]; then
  190. while :; do echo
  191. echo "Please choose installation of the database:"
  192. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  193. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  194. read -p "Please input a number:(Default 1 press Enter) " dbInstallMethods
  195. [ -z "$dbInstallMethods" ] && dbInstallMethods=1
  196. if [[ ! $dbInstallMethods =~ ^[1-2]$ ]]; then
  197. echo "${CWARNING}input error! Please only input number 1,2${CEND}"
  198. else
  199. break
  200. fi
  201. done
  202. fi
  203. break
  204. else
  205. echo "${CWARNING}input error! Please only input number 1~11${CEND}"
  206. fi
  207. done
  208. fi
  209. break
  210. fi
  211. done
  212. # check PHP
  213. while :; do echo
  214. read -p "Do you want to install PHP? [y/n]: " PHP_yn
  215. if [[ ! $PHP_yn =~ ^[y,n]$ ]]; then
  216. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  217. else
  218. if [ "$PHP_yn" == 'y' ]; then
  219. [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; }
  220. while :; do echo
  221. echo 'Please select a version of the PHP:'
  222. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  223. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  224. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  225. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  226. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  227. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  228. read -p "Please input a number:(Default 4 press Enter) " PHP_version
  229. [ -z "$PHP_version" ] && PHP_version=4
  230. if [[ ! $PHP_version =~ ^[1-6]$ ]]; then
  231. echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}"
  232. else
  233. while :; do echo
  234. read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
  235. if [[ ! $PHP_cache_yn =~ ^[y,n]$ ]]; then
  236. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  237. else
  238. if [ "$PHP_cache_yn" == 'y' ]; then
  239. if [ $PHP_version == 1 ]; then
  240. while :; do
  241. echo 'Please select a opcode cache of the PHP:'
  242. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  243. echo -e "\t${CMSG}2${CEND}. Install XCache"
  244. echo -e "\t${CMSG}3${CEND}. Install APCU"
  245. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  246. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  247. [ -z "$PHP_cache" ] && PHP_cache=1
  248. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  249. echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
  250. else
  251. break
  252. fi
  253. done
  254. fi
  255. if [ $PHP_version == 2 ]; then
  256. while :; do
  257. echo 'Please select a opcode cache of the PHP:'
  258. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  259. echo -e "\t${CMSG}2${CEND}. Install XCache"
  260. echo -e "\t${CMSG}3${CEND}. Install APCU"
  261. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  262. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  263. [ -z "$PHP_cache" ] && PHP_cache=1
  264. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  265. echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
  266. else
  267. break
  268. fi
  269. done
  270. fi
  271. if [ $PHP_version == 3 ]; then
  272. while :; do
  273. echo 'Please select a opcode cache of the PHP:'
  274. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  275. echo -e "\t${CMSG}2${CEND}. Install XCache"
  276. echo -e "\t${CMSG}3${CEND}. Install APCU"
  277. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  278. [ -z "$PHP_cache" ] && PHP_cache=1
  279. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  280. echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
  281. else
  282. break
  283. fi
  284. done
  285. fi
  286. if [ $PHP_version == 4 ]; then
  287. while :; do
  288. echo 'Please select a opcode cache of the PHP:'
  289. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  290. echo -e "\t${CMSG}2${CEND}. Install XCache"
  291. echo -e "\t${CMSG}3${CEND}. Install APCU"
  292. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  293. [ -z "$PHP_cache" ] && PHP_cache=1
  294. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  295. echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
  296. else
  297. break
  298. fi
  299. done
  300. fi
  301. if [[ $PHP_version =~ ^[5-6]$ ]]; then
  302. while :; do
  303. echo 'Please select a opcode cache of the PHP:'
  304. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  305. echo -e "\t${CMSG}3${CEND}. Install APCU"
  306. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  307. [ -z "$PHP_cache" ] && PHP_cache=1
  308. if [[ ! $PHP_cache =~ ^[1,3]$ ]]; then
  309. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  310. else
  311. break
  312. fi
  313. done
  314. fi
  315. fi
  316. break
  317. fi
  318. done
  319. if [ "$PHP_cache" == '2' ]; then
  320. while :; do
  321. read -p "Please input xcache admin password: " xcache_admin_pass
  322. (( ${#xcache_admin_pass} >= 5 )) && { xcache_admin_md5_pass=`echo -n "$xcache_admin_pass" | md5sum | awk '{print $1}'` ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  323. done
  324. fi
  325. if [[ $PHP_version =~ ^[1-4]$ ]] && [ "$PHP_cache" != '1' -a "${armPlatform}" != "y" ]; then
  326. while :; do echo
  327. read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
  328. if [[ ! $ZendGuardLoader_yn =~ ^[y,n]$ ]]; then
  329. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  330. else
  331. break
  332. fi
  333. done
  334. fi
  335. # ionCube
  336. if [ "${TARGET_ARCH}" != "arm64" ]; then
  337. while :; do echo
  338. read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
  339. if [[ ! $ionCube_yn =~ ^[y,n]$ ]]; then
  340. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  341. else
  342. break
  343. fi
  344. done
  345. fi
  346. # ImageMagick or GraphicsMagick
  347. while :; do echo
  348. read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
  349. if [[ ! $Magick_yn =~ ^[y,n]$ ]]; then
  350. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  351. else
  352. break
  353. fi
  354. done
  355. if [ "$Magick_yn" == 'y' ]; then
  356. while :; do
  357. echo 'Please select ImageMagick or GraphicsMagick:'
  358. echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
  359. echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
  360. read -p "Please input a number:(Default 1 press Enter) " Magick
  361. [ -z "$Magick" ] && Magick=1
  362. if [[ ! $Magick =~ ^[1-2]$ ]]; then
  363. echo "${CWARNING}input error! Please only input number 1,2${CEND}"
  364. else
  365. break
  366. fi
  367. done
  368. fi
  369. break
  370. fi
  371. done
  372. fi
  373. break
  374. fi
  375. done
  376. # check Pureftpd
  377. while :; do echo
  378. read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
  379. if [[ ! $FTP_yn =~ ^[y,n]$ ]]; then
  380. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  381. else
  382. [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; FTP_yn=Other; }
  383. break
  384. fi
  385. done
  386. # check phpMyAdmin
  387. if [[ $PHP_version =~ ^[1-6]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then
  388. while :; do echo
  389. read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
  390. if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]]; then
  391. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  392. else
  393. [ "$phpMyAdmin_yn" == 'y' -a -d "$wwwroot_dir/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpMyAdmin_yn=Other; }
  394. break
  395. fi
  396. done
  397. fi
  398. # check redis
  399. while :; do echo
  400. read -p "Do you want to install redis? [y/n]: " redis_yn
  401. if [[ ! $redis_yn =~ ^[y,n]$ ]]; then
  402. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  403. else
  404. break
  405. fi
  406. done
  407. # check memcached
  408. while :; do echo
  409. read -p "Do you want to install memcached? [y/n]: " memcached_yn
  410. if [[ ! $memcached_yn =~ ^[y,n]$ ]]; then
  411. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  412. else
  413. break
  414. fi
  415. done
  416. while :; do echo
  417. read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
  418. if [[ ! $HHVM_yn =~ ^[y,n]$ ]]; then
  419. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  420. else
  421. if [ "$HHVM_yn" == 'y' ]; then
  422. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; HHVM_yn=Other; break; }
  423. if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  424. break
  425. else
  426. echo
  427. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  428. echo "Press Ctrl+c to cancel or Press any key to continue..."
  429. char=`get_char`
  430. HHVM_yn=Other
  431. fi
  432. fi
  433. break
  434. fi
  435. done
  436. # get the IP information
  437. IPADDR=`./include/get_ipaddr.py`
  438. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  439. IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
  440. IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
  441. [ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun
  442. # del openssl for jcloud
  443. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  444. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  445. # Check binary dependencies packages
  446. . ./include/check_sw.sh
  447. case "${OS}" in
  448. "CentOS")
  449. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  450. ;;
  451. "Debian")
  452. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  453. ;;
  454. "Ubuntu")
  455. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  456. ;;
  457. esac
  458. # init
  459. startTime=`date +%s`
  460. . ./include/memory.sh
  461. case "${OS}" in
  462. "CentOS")
  463. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  464. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  465. ;;
  466. "Debian")
  467. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  468. ;;
  469. "Ubuntu")
  470. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  471. ;;
  472. esac
  473. # Check download source packages
  474. . ./include/check_download.sh
  475. downloadDepsSrc=1
  476. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  477. # Install dependencies from source package
  478. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  479. # Jemalloc
  480. if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' ]; then
  481. . include/jemalloc.sh
  482. Install_Jemalloc | tee -a $oneinstack_dir/install.log
  483. fi
  484. # openSSL
  485. . ./include/openssl.sh
  486. if [[ $Tomcat_version =~ ^[1-3]$ ]] || [[ $Apache_version =~ ^[1-2]$ ]] || [[ $PHP_version =~ ^[1-6]$ ]]; then
  487. Install_openSSL102 | tee -a $oneinstack_dir/install.log
  488. fi
  489. # Database
  490. case "${DB_version}" in
  491. 1)
  492. if [ "${dbInstallMethods}" == "2" ]; then
  493. . include/boost.sh
  494. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  495. fi
  496. . include/mysql-5.7.sh
  497. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  498. ;;
  499. 2)
  500. . include/mysql-5.6.sh
  501. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  502. ;;
  503. 3)
  504. . include/mysql-5.5.sh
  505. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  506. ;;
  507. 4)
  508. if [ "${dbInstallMethods}" == "2" ]; then
  509. . include/boost.sh
  510. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  511. fi
  512. . include/mariadb-10.2.sh
  513. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  514. ;;
  515. 5)
  516. if [ "${dbInstallMethods}" == "2" ]; then
  517. . include/boost.sh
  518. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  519. fi
  520. . include/mariadb-10.1.sh
  521. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  522. ;;
  523. 6)
  524. . include/mariadb-10.0.sh
  525. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  526. ;;
  527. 7)
  528. . include/mariadb-5.5.sh
  529. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  530. ;;
  531. 8)
  532. if [ "${dbInstallMethods}" == "2" ]; then
  533. . include/boost.sh
  534. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  535. fi
  536. . include/percona-5.7.sh
  537. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  538. ;;
  539. 9)
  540. . include/percona-5.6.sh
  541. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  542. ;;
  543. 10)
  544. . include/percona-5.5.sh
  545. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  546. ;;
  547. 11)
  548. . include/alisql-5.6.sh
  549. Install_AliSQL56 2>&1 | tee -a $oneinstack_dir/install.log
  550. ;;
  551. esac
  552. # Apache
  553. if [ "$Apache_version" == '1' ]; then
  554. . include/apache-2.4.sh
  555. Install_Apache24 2>&1 | tee -a $oneinstack_dir/install.log
  556. elif [ "$Apache_version" == '2' ]; then
  557. . include/apache-2.2.sh
  558. Install_Apache22 2>&1 | tee -a $oneinstack_dir/install.log
  559. fi
  560. # PHP
  561. case "${PHP_version}" in
  562. 1)
  563. . include/php-5.3.sh
  564. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  565. ;;
  566. 2)
  567. . include/php-5.4.sh
  568. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  569. ;;
  570. 3)
  571. . include/php-5.5.sh
  572. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  573. ;;
  574. 4)
  575. . include/php-5.6.sh
  576. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  577. ;;
  578. 5)
  579. . include/php-7.0.sh
  580. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  581. ;;
  582. 6)
  583. . include/php-7.1.sh
  584. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  585. ;;
  586. esac
  587. # ImageMagick or GraphicsMagick
  588. if [ "$Magick" == '1' ]; then
  589. . include/ImageMagick.sh
  590. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
  591. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a $oneinstack_dir/install.log
  592. elif [ "$Magick" == '2' ]; then
  593. . include/GraphicsMagick.sh
  594. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
  595. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a $oneinstack_dir/install.log
  596. fi
  597. # ionCube
  598. if [ "$ionCube_yn" == 'y' ]; then
  599. . include/ioncube.sh
  600. Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
  601. fi
  602. # PHP opcode cache
  603. case "${PHP_cache}" in
  604. 1)
  605. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  606. . include/zendopcache.sh
  607. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  608. fi
  609. ;;
  610. 2)
  611. . include/xcache.sh
  612. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  613. ;;
  614. 3)
  615. . include/apcu.sh
  616. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  617. ;;
  618. 4)
  619. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  620. . include/eaccelerator.sh
  621. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  622. fi
  623. ;;
  624. esac
  625. # ZendGuardLoader (php <= 5.6)
  626. if [ "$ZendGuardLoader_yn" == 'y' ]; then
  627. . include/ZendGuardLoader.sh
  628. Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
  629. fi
  630. # Web server
  631. case "${Nginx_version}" in
  632. 1)
  633. . include/nginx.sh
  634. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  635. ;;
  636. 2)
  637. . include/tengine.sh
  638. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  639. ;;
  640. 3)
  641. . include/openresty.sh
  642. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  643. ;;
  644. esac
  645. # JDK
  646. case "${JDK_version}" in
  647. 1)
  648. . include/jdk-1.8.sh
  649. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  650. ;;
  651. 2)
  652. . include/jdk-1.7.sh
  653. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  654. ;;
  655. 3)
  656. . include/jdk-1.6.sh
  657. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  658. ;;
  659. esac
  660. case "${Tomcat_version}" in
  661. 1)
  662. . include/tomcat-8.sh
  663. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  664. ;;
  665. 2)
  666. . include/tomcat-7.sh
  667. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  668. ;;
  669. 3)
  670. . include/tomcat-6.sh
  671. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  672. ;;
  673. esac
  674. # Pure-FTPd
  675. if [ "${FTP_yn}" == 'y' ]; then
  676. . include/pureftpd.sh
  677. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  678. fi
  679. # phpMyAdmin
  680. if [ "${phpMyAdmin_yn}" == 'y' ]; then
  681. . include/phpmyadmin.sh
  682. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  683. fi
  684. # redis
  685. if [ "${redis_yn}" == 'y' ]; then
  686. . include/redis.sh
  687. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  688. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/redis.so" ] && Install_php-redis 2>&1 | tee -a ${oneinstack_dir}/install.log
  689. fi
  690. # memcached
  691. if [ "${memcached_yn}" == 'y' ]; then
  692. . include/memcached.sh
  693. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  694. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcache.so" ] && Install_php-memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  695. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcached.so" ] && Install_php-memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  696. fi
  697. # index example
  698. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${Web_yn}" == 'y' ]; then
  699. . include/demo.sh
  700. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  701. fi
  702. # get web_install_dir and db_install_dir
  703. . include/check_dir.sh
  704. # HHVM
  705. if [ "${HHVM_yn}" == 'y' ]; then
  706. . include/hhvm_CentOS.sh
  707. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  708. fi
  709. # Starting DB
  710. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  711. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  712. endTime=`date +%s`
  713. ((installTime=($endTime-$startTime)/60))
  714. echo "####################Congratulations########################"
  715. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  716. [ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  717. [ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  718. [ "${Web_yn}" == 'y' -a "${Nginx_version}" == '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  719. [[ "${Tomcat_version}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  720. [ "${DB_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  721. [ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  722. [ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  723. [ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  724. [ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  725. [ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel url:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  726. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel url:")${CMSG}http://${IPADDR}/xcache${CEND}"
  727. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  728. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}"
  729. [ "${PHP_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel url:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  730. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel url:")${CMSG}http://${IPADDR}/control.php${CEND}"
  731. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  732. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  733. [ "${FTP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  734. [ "${FTP_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  735. [ "${phpMyAdmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  736. [ "${phpMyAdmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel url:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  737. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  738. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  739. [ "${Web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "index url:")${CMSG}http://${IPADDR}/${CEND}"
  740. while :; do echo
  741. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  742. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  743. if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
  744. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  745. else
  746. break
  747. fi
  748. done
  749. [ "${restart_yn}" == 'y' ] && reboot