1
0

install.sh 32 KB

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