install.sh 32 KB

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