install.sh 32 KB

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