install.sh 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 7+ 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 6+ Debian 7+ 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. mkdir -p $wwwroot_dir/default $wwwlogs_dir
  30. [ -d /data ] && chmod 755 /data
  31. # Use default SSH port 22. If you use another SSH port on your server
  32. if [ -e "/etc/ssh/sshd_config" ]; then
  33. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  34. while :; do echo
  35. read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT
  36. [ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port
  37. 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
  38. break
  39. else
  40. echo "${CWARNING}input error! Input range: 22,1025~65534${CEND}"
  41. fi
  42. done
  43. if [ -z "`grep ^Port /etc/ssh/sshd_config`" -a "$SSH_PORT" != '22' ]; then
  44. sed -i "s@^#Port.*@&\nPort $SSH_PORT@" /etc/ssh/sshd_config
  45. elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
  46. sed -i "s@^Port.*@Port $SSH_PORT@" /etc/ssh/sshd_config
  47. fi
  48. fi
  49. # check iptables
  50. while :; do echo
  51. read -p "Do you want to enable iptables? [y/n]: " iptables_yn
  52. if [[ ! $iptables_yn =~ ^[y,n]$ ]]; then
  53. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  54. else
  55. break
  56. fi
  57. done
  58. # check Web server
  59. while :; do 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/OpenResty
  66. while :; do echo
  67. echo 'Please select Nginx server:'
  68. echo -e "\t${CMSG}1${CEND}. Install Nginx"
  69. echo -e "\t${CMSG}2${CEND}. Install Tengine"
  70. echo -e "\t${CMSG}3${CEND}. Install OpenResty"
  71. echo -e "\t${CMSG}4${CEND}. Do not install"
  72. read -p "Please input a number:(Default 1 press Enter) " Nginx_version
  73. [ -z "$Nginx_version" ] && Nginx_version=1
  74. if [[ ! $Nginx_version =~ ^[1-4]$ ]]; then
  75. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  76. else
  77. [ "$Nginx_version" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
  78. [ "$Nginx_version" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
  79. [ "$Nginx_version" != '4' -a -e "$openresty_install_dir/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; Nginx_version=Other; }
  80. break
  81. fi
  82. done
  83. # Apache
  84. while :; do echo
  85. echo 'Please select Apache server:'
  86. echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
  87. echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
  88. echo -e "\t${CMSG}3${CEND}. Do not install"
  89. read -p "Please input a number:(Default 3 press Enter) " Apache_version
  90. [ -z "$Apache_version" ] && Apache_version=3
  91. if [[ ! $Apache_version =~ ^[1-3]$ ]]; then
  92. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  93. else
  94. [ "$Apache_version" != '3' -a -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; Apache_version=Other; }
  95. break
  96. fi
  97. done
  98. # Tomcat
  99. while :; do echo
  100. echo 'Please select tomcat server:'
  101. echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
  102. echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
  103. echo -e "\t${CMSG}3${CEND}. Install Tomcat-6"
  104. echo -e "\t${CMSG}4${CEND}. Do not install"
  105. read -p "Please input a number:(Default 4 press Enter) " Tomcat_version
  106. [ -z "$Tomcat_version" ] && Tomcat_version=4
  107. if [[ ! $Tomcat_version =~ ^[1-4]$ ]]; then
  108. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  109. else
  110. [ "$Tomcat_version" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; }
  111. if [ "$Tomcat_version" == '1' ]; then
  112. while :; do echo
  113. echo 'Please select JDK version:'
  114. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  115. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  116. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  117. [ -z "$JDK_version" ] && JDK_version=2
  118. if [[ ! $JDK_version =~ ^[1-2]$ ]]; then
  119. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  120. else
  121. break
  122. fi
  123. done
  124. elif [ "$Tomcat_version" == '2' ]; then
  125. while :; do echo
  126. echo 'Please select JDK version:'
  127. echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
  128. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  129. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  130. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  131. [ -z "$JDK_version" ] && JDK_version=2
  132. if [[ ! $JDK_version =~ ^[1-3]$ ]]; then
  133. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  134. else
  135. break
  136. fi
  137. done
  138. elif [ "$Tomcat_version" == '3' ]; then
  139. while :; do echo
  140. echo 'Please select JDK version:'
  141. echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
  142. echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
  143. read -p "Please input a number:(Default 2 press Enter) " JDK_version
  144. [ -z "$JDK_version" ] && JDK_version=2
  145. if [[ ! $JDK_version =~ ^[2-3]$ ]]; then
  146. echo "${CWARNING}input error! Please only input number 2~3${CEND}"
  147. else
  148. break
  149. fi
  150. done
  151. fi
  152. break
  153. fi
  154. done
  155. fi
  156. break
  157. fi
  158. done
  159. # choice database
  160. while :; do echo
  161. read -p "Do you want to install Database? [y/n]: " DB_yn
  162. if [[ ! $DB_yn =~ ^[y,n]$ ]]; then
  163. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  164. else
  165. if [ "$DB_yn" == 'y' ]; then
  166. [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; }
  167. while :; do echo
  168. echo 'Please select a version of the Database:'
  169. echo -e "\t${CMSG} 1${CEND}. Install MySQL-5.7"
  170. echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.6"
  171. echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.5"
  172. echo -e "\t${CMSG} 4${CEND}. Install MariaDB-10.2"
  173. echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.1"
  174. echo -e "\t${CMSG} 6${CEND}. Install MariaDB-10.0"
  175. echo -e "\t${CMSG} 7${CEND}. Install MariaDB-5.5"
  176. echo -e "\t${CMSG} 8${CEND}. Install Percona-5.7"
  177. echo -e "\t${CMSG} 9${CEND}. Install Percona-5.6"
  178. echo -e "\t${CMSG}10${CEND}. Install Percona-5.5"
  179. echo -e "\t${CMSG}11${CEND}. Install AliSQL-5.6"
  180. read -p "Please input a number:(Default 2 press Enter) " DB_version
  181. [ -z "$DB_version" ] && DB_version=2
  182. if [ ${DB_version} -ge 1 >/dev/null 2>&1 -a ${DB_version} -le 11 >/dev/null 2>&1 ]; then
  183. while :; do
  184. read -p "Please input the root password of database: " dbrootpwd
  185. [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  186. (( ${#dbrootpwd} >= 5 )) && sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf && break || echo "${CWARNING}database root password least 5 characters! ${CEND}"
  187. done
  188. # choose install methods
  189. if [ ${DB_version} -ge 1 >/dev/null 2>&1 -a ${DB_version} -le 10 >/dev/null 2>&1 ]; then
  190. while :; do echo
  191. echo "Please choose installation of the database:"
  192. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  193. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  194. read -p "Please input a number:(Default 1 press Enter) " dbInstallMethods
  195. [ -z "$dbInstallMethods" ] && dbInstallMethods=1
  196. if [[ ! $dbInstallMethods =~ ^[1-2]$ ]]; then
  197. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  198. else
  199. break
  200. fi
  201. done
  202. fi
  203. break
  204. else
  205. echo "${CWARNING}input error! Please only input number 1~11${CEND}"
  206. fi
  207. done
  208. fi
  209. break
  210. fi
  211. done
  212. # check PHP
  213. while :; do echo
  214. read -p "Do you want to install PHP? [y/n]: " PHP_yn
  215. if [[ ! $PHP_yn =~ ^[y,n]$ ]]; then
  216. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  217. else
  218. if [ "$PHP_yn" == 'y' ]; then
  219. [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; }
  220. while :; do echo
  221. echo 'Please select a version of the PHP:'
  222. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  223. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  224. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  225. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  226. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  227. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  228. echo -e "\t${CMSG}7${CEND}. Install php-7.2"
  229. read -p "Please input a number:(Default 5 press Enter) " PHP_version
  230. [ -z "$PHP_version" ] && PHP_version=5
  231. if [[ ! $PHP_version =~ ^[1-7]$ ]]; then
  232. echo "${CWARNING}input error! Please only input number 1~7${CEND}"
  233. else
  234. while :; do echo
  235. read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
  236. if [[ ! $PHP_cache_yn =~ ^[y,n]$ ]]; then
  237. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  238. else
  239. if [ "$PHP_cache_yn" == 'y' ]; then
  240. if [ $PHP_version == 1 ]; then
  241. while :; do
  242. echo 'Please select a opcode cache of the PHP:'
  243. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  244. echo -e "\t${CMSG}2${CEND}. Install XCache"
  245. echo -e "\t${CMSG}3${CEND}. Install APCU"
  246. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  247. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  248. [ -z "$PHP_cache" ] && PHP_cache=1
  249. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  250. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  251. else
  252. break
  253. fi
  254. done
  255. fi
  256. if [ $PHP_version == 2 ]; then
  257. while :; do
  258. echo 'Please select a opcode cache of the PHP:'
  259. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  260. echo -e "\t${CMSG}2${CEND}. Install XCache"
  261. echo -e "\t${CMSG}3${CEND}. Install APCU"
  262. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  263. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  264. [ -z "$PHP_cache" ] && PHP_cache=1
  265. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  266. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  267. else
  268. break
  269. fi
  270. done
  271. fi
  272. if [ $PHP_version == 3 ]; then
  273. while :; do
  274. echo 'Please select a opcode cache of the PHP:'
  275. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  276. echo -e "\t${CMSG}2${CEND}. Install XCache"
  277. echo -e "\t${CMSG}3${CEND}. Install APCU"
  278. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  279. [ -z "$PHP_cache" ] && PHP_cache=1
  280. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  281. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  282. else
  283. break
  284. fi
  285. done
  286. fi
  287. if [ $PHP_version == 4 ]; then
  288. while :; do
  289. echo 'Please select a opcode cache of the PHP:'
  290. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  291. echo -e "\t${CMSG}2${CEND}. Install XCache"
  292. echo -e "\t${CMSG}3${CEND}. Install APCU"
  293. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  294. [ -z "$PHP_cache" ] && PHP_cache=1
  295. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  296. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  297. else
  298. break
  299. fi
  300. done
  301. fi
  302. if [[ $PHP_version =~ ^[5-6]$ ]]; then
  303. while :; do
  304. echo 'Please select a opcode cache of the PHP:'
  305. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  306. echo -e "\t${CMSG}3${CEND}. Install APCU"
  307. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  308. [ -z "$PHP_cache" ] && PHP_cache=1
  309. if [[ ! $PHP_cache =~ ^[1,3]$ ]]; then
  310. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  311. else
  312. break
  313. fi
  314. done
  315. fi
  316. [ $PHP_version == 7 ] && PHP_cache=1
  317. fi
  318. break
  319. fi
  320. done
  321. if [ "$PHP_cache" == '2' ]; then
  322. while :; do
  323. read -p "Please input xcache admin password: " xcache_admin_pass
  324. (( ${#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}"
  325. done
  326. fi
  327. if [[ $PHP_version =~ ^[1-4]$ ]] && [ "$PHP_cache" != '1' -a "${armPlatform}" != "y" ]; then
  328. while :; do echo
  329. read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
  330. if [[ ! $ZendGuardLoader_yn =~ ^[y,n]$ ]]; then
  331. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  332. else
  333. break
  334. fi
  335. done
  336. fi
  337. # ionCube
  338. if [ "${TARGET_ARCH}" != "arm64" ] && [[ $PHP_version =~ ^[1-6]$ ]]; then
  339. while :; do echo
  340. read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
  341. if [[ ! $ionCube_yn =~ ^[y,n]$ ]]; then
  342. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  343. else
  344. break
  345. fi
  346. done
  347. fi
  348. # ImageMagick or GraphicsMagick
  349. while :; do echo
  350. read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
  351. if [[ ! $Magick_yn =~ ^[y,n]$ ]]; then
  352. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  353. else
  354. break
  355. fi
  356. done
  357. if [ "$Magick_yn" == 'y' ]; then
  358. while :; do
  359. echo 'Please select ImageMagick or GraphicsMagick:'
  360. echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
  361. echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
  362. read -p "Please input a number:(Default 1 press Enter) " Magick
  363. [ -z "$Magick" ] && Magick=1
  364. if [[ ! $Magick =~ ^[1-2]$ ]]; then
  365. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  366. else
  367. break
  368. fi
  369. done
  370. fi
  371. break
  372. fi
  373. done
  374. fi
  375. break
  376. fi
  377. done
  378. # check Pureftpd
  379. while :; do echo
  380. read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
  381. if [[ ! $FTP_yn =~ ^[y,n]$ ]]; then
  382. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  383. else
  384. [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; FTP_yn=Other; }
  385. break
  386. fi
  387. done
  388. # check phpMyAdmin
  389. if [[ $PHP_version =~ ^[1-7]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then
  390. while :; do echo
  391. read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
  392. if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]]; then
  393. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  394. else
  395. [ "$phpMyAdmin_yn" == 'y' -a -d "$wwwroot_dir/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpMyAdmin_yn=Other; }
  396. break
  397. fi
  398. done
  399. fi
  400. # check redis
  401. while :; do echo
  402. read -p "Do you want to install redis? [y/n]: " redis_yn
  403. if [[ ! $redis_yn =~ ^[y,n]$ ]]; then
  404. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  405. else
  406. break
  407. fi
  408. done
  409. # check memcached
  410. while :; do echo
  411. read -p "Do you want to install memcached? [y/n]: " memcached_yn
  412. if [[ ! $memcached_yn =~ ^[y,n]$ ]]; then
  413. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  414. else
  415. break
  416. fi
  417. done
  418. while :; do echo
  419. read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
  420. if [[ ! $HHVM_yn =~ ^[y,n]$ ]]; then
  421. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  422. else
  423. if [ "$HHVM_yn" == 'y' ]; then
  424. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; HHVM_yn=Other; break; }
  425. if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  426. break
  427. else
  428. echo
  429. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  430. echo "Press Ctrl+c to cancel or Press any key to continue..."
  431. char=`get_char`
  432. HHVM_yn=Other
  433. fi
  434. fi
  435. break
  436. fi
  437. done
  438. # get the IP information
  439. IPADDR=`./include/get_ipaddr.py`
  440. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  441. IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
  442. IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
  443. [ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun
  444. # del openssl for jcloud
  445. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  446. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  447. # Check binary dependencies packages
  448. . ./include/check_sw.sh
  449. case "${OS}" in
  450. "CentOS")
  451. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  452. ;;
  453. "Debian")
  454. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  455. ;;
  456. "Ubuntu")
  457. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  458. ;;
  459. esac
  460. # init
  461. startTime=`date +%s`
  462. . ./include/memory.sh
  463. case "${OS}" in
  464. "CentOS")
  465. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  466. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  467. ;;
  468. "Debian")
  469. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  470. ;;
  471. "Ubuntu")
  472. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  473. ;;
  474. esac
  475. # Check download source packages
  476. . ./include/check_download.sh
  477. downloadDepsSrc=1
  478. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  479. # Install dependencies from source package
  480. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  481. # Jemalloc
  482. if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' ]; then
  483. . include/jemalloc.sh
  484. Install_Jemalloc | tee -a $oneinstack_dir/install.log
  485. fi
  486. # openSSL
  487. . ./include/openssl.sh
  488. if [[ $Tomcat_version =~ ^[1-3]$ ]] || [[ $Apache_version =~ ^[1-2]$ ]] || [[ $PHP_version =~ ^[1-7]$ ]]; then
  489. Install_openSSL102 | tee -a $oneinstack_dir/install.log
  490. fi
  491. # Database
  492. case "${DB_version}" in
  493. 1)
  494. if [ "${dbInstallMethods}" == "2" ]; then
  495. . include/boost.sh
  496. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  497. fi
  498. . include/mysql-5.7.sh
  499. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  500. ;;
  501. 2)
  502. . include/mysql-5.6.sh
  503. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  504. ;;
  505. 3)
  506. . include/mysql-5.5.sh
  507. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  508. ;;
  509. 4)
  510. if [ "${dbInstallMethods}" == "2" ]; then
  511. . include/boost.sh
  512. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  513. fi
  514. . include/mariadb-10.2.sh
  515. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  516. ;;
  517. 5)
  518. if [ "${dbInstallMethods}" == "2" ]; then
  519. . include/boost.sh
  520. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  521. fi
  522. . include/mariadb-10.1.sh
  523. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  524. ;;
  525. 6)
  526. . include/mariadb-10.0.sh
  527. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  528. ;;
  529. 7)
  530. . include/mariadb-5.5.sh
  531. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  532. ;;
  533. 8)
  534. if [ "${dbInstallMethods}" == "2" ]; then
  535. . include/boost.sh
  536. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  537. fi
  538. . include/percona-5.7.sh
  539. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  540. ;;
  541. 9)
  542. . include/percona-5.6.sh
  543. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  544. ;;
  545. 10)
  546. . include/percona-5.5.sh
  547. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  548. ;;
  549. 11)
  550. . include/alisql-5.6.sh
  551. Install_AliSQL56 2>&1 | tee -a $oneinstack_dir/install.log
  552. ;;
  553. esac
  554. # Apache
  555. if [ "$Apache_version" == '1' ]; then
  556. . include/apache-2.4.sh
  557. Install_Apache24 2>&1 | tee -a $oneinstack_dir/install.log
  558. elif [ "$Apache_version" == '2' ]; then
  559. . include/apache-2.2.sh
  560. Install_Apache22 2>&1 | tee -a $oneinstack_dir/install.log
  561. fi
  562. # PHP
  563. case "${PHP_version}" in
  564. 1)
  565. . include/php-5.3.sh
  566. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  567. ;;
  568. 2)
  569. . include/php-5.4.sh
  570. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  571. ;;
  572. 3)
  573. . include/php-5.5.sh
  574. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  575. ;;
  576. 4)
  577. . include/php-5.6.sh
  578. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  579. ;;
  580. 5)
  581. . include/php-7.0.sh
  582. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  583. ;;
  584. 6)
  585. . include/php-7.1.sh
  586. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  587. ;;
  588. 7)
  589. . include/php-7.2.sh
  590. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  591. ;;
  592. esac
  593. # ImageMagick or GraphicsMagick
  594. if [ "$Magick" == '1' ]; then
  595. . include/ImageMagick.sh
  596. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
  597. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a $oneinstack_dir/install.log
  598. elif [ "$Magick" == '2' ]; then
  599. . include/GraphicsMagick.sh
  600. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
  601. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a $oneinstack_dir/install.log
  602. fi
  603. # ionCube
  604. if [ "$ionCube_yn" == 'y' ]; then
  605. . include/ioncube.sh
  606. Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
  607. fi
  608. # PHP opcode cache
  609. case "${PHP_cache}" in
  610. 1)
  611. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  612. . include/zendopcache.sh
  613. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  614. fi
  615. ;;
  616. 2)
  617. . include/xcache.sh
  618. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  619. ;;
  620. 3)
  621. . include/apcu.sh
  622. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  623. ;;
  624. 4)
  625. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  626. . include/eaccelerator.sh
  627. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  628. fi
  629. ;;
  630. esac
  631. # ZendGuardLoader (php <= 5.6)
  632. if [ "$ZendGuardLoader_yn" == 'y' ]; then
  633. . include/ZendGuardLoader.sh
  634. Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
  635. fi
  636. # Web server
  637. case "${Nginx_version}" in
  638. 1)
  639. . include/nginx.sh
  640. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  641. ;;
  642. 2)
  643. . include/tengine.sh
  644. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  645. ;;
  646. 3)
  647. . include/openresty.sh
  648. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  649. ;;
  650. esac
  651. # JDK
  652. case "${JDK_version}" in
  653. 1)
  654. . include/jdk-1.8.sh
  655. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  656. ;;
  657. 2)
  658. . include/jdk-1.7.sh
  659. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  660. ;;
  661. 3)
  662. . include/jdk-1.6.sh
  663. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  664. ;;
  665. esac
  666. case "${Tomcat_version}" in
  667. 1)
  668. . include/tomcat-8.sh
  669. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  670. ;;
  671. 2)
  672. . include/tomcat-7.sh
  673. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  674. ;;
  675. 3)
  676. . include/tomcat-6.sh
  677. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  678. ;;
  679. esac
  680. # Pure-FTPd
  681. if [ "${FTP_yn}" == 'y' ]; then
  682. . include/pureftpd.sh
  683. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  684. fi
  685. # phpMyAdmin
  686. if [ "${phpMyAdmin_yn}" == 'y' ]; then
  687. . include/phpmyadmin.sh
  688. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  689. fi
  690. # redis
  691. if [ "${redis_yn}" == 'y' ]; then
  692. . include/redis.sh
  693. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  694. [ -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
  695. fi
  696. # memcached
  697. if [ "${memcached_yn}" == 'y' ]; then
  698. . include/memcached.sh
  699. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  700. [ -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
  701. [ -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
  702. fi
  703. # index example
  704. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${Web_yn}" == 'y' ]; then
  705. . include/demo.sh
  706. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  707. fi
  708. # get web_install_dir and db_install_dir
  709. . include/check_dir.sh
  710. # HHVM
  711. if [ "${HHVM_yn}" == 'y' ]; then
  712. . include/hhvm_CentOS.sh
  713. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  714. fi
  715. # Starting DB
  716. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  717. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  718. endTime=`date +%s`
  719. ((installTime=($endTime-$startTime)/60))
  720. echo "####################Congratulations########################"
  721. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  722. [ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  723. [ "${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}"
  724. [ "${Web_yn}" == 'y' -a "${Nginx_version}" == '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  725. [[ "${Tomcat_version}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  726. [ "${DB_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  727. [ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  728. [ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  729. [ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  730. [ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  731. [ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel url:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  732. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel url:")${CMSG}http://${IPADDR}/xcache${CEND}"
  733. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  734. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}"
  735. [ "${PHP_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel url:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  736. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel url:")${CMSG}http://${IPADDR}/control.php${CEND}"
  737. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  738. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  739. [ "${FTP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  740. [ "${FTP_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  741. [ "${phpMyAdmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  742. [ "${phpMyAdmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel url:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  743. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  744. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  745. [ "${Web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "index url:")${CMSG}http://${IPADDR}/${CEND}"
  746. while :; do echo
  747. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  748. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  749. if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
  750. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  751. else
  752. break
  753. fi
  754. done
  755. [ "${restart_yn}" == 'y' ] && reboot