install.sh 33 KB

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