install.sh 31 KB

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