install.sh 32 KB

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