install.sh 32 KB

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