install.sh 32 KB

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