install.sh 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  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" -a -e "${pgsql_install_dir}/bin/psql" ] && { 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. echo -e "\t${CMSG}12${CEND}. Install PostgreSQL"
  181. echo -e "\t${CMSG}13${CEND}. Install MongoDB"
  182. read -p "Please input a number:(Default 2 press Enter) " DB_version
  183. [ -z "$DB_version" ] && DB_version=2
  184. [ "$DB_version" == '13' -a "$OS_BIT" == '32' ] && { echo "${CWARNING}By not supporting 32-bit! ${CEND}"; continue; }
  185. if [[ "${DB_version}" =~ ^[1-9]$|^1[0-3]$ ]]; then
  186. while :; do
  187. if [ "$DB_version" == '12' ]; then
  188. read -p "Please input the postgres password of database: " dbrootpwd
  189. else
  190. read -p "Please input the root password of database: " dbrootpwd
  191. fi
  192. [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
  193. if (( ${#dbrootpwd} >= 5 )); then
  194. if [ "$DB_version" == '12' ]; then
  195. sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf
  196. dbpostgrespwd="$dbrootpwd"
  197. elif [ "$DB_version" == '13' ]; then
  198. sed -i "s+^dbmongopwd.*+dbmongopwd='$dbrootpwd'+" ./options.conf
  199. dbmongopwd="$dbrootpwd"
  200. else
  201. sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf
  202. fi
  203. break
  204. else
  205. echo "${CWARNING}password least 5 characters! ${CEND}"
  206. fi
  207. done
  208. # choose install methods
  209. if [[ "${DB_version}" =~ ^[1-9]$|^10$ ]]; then
  210. while :; do echo
  211. echo "Please choose installation of the database:"
  212. echo -e "\t${CMSG}1${CEND}. Install database from binary package."
  213. echo -e "\t${CMSG}2${CEND}. Install database from source package."
  214. read -p "Please input a number:(Default 1 press Enter) " dbInstallMethods
  215. [ -z "$dbInstallMethods" ] && dbInstallMethods=1
  216. if [[ ! $dbInstallMethods =~ ^[1-2]$ ]]; then
  217. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  218. else
  219. break
  220. fi
  221. done
  222. fi
  223. break
  224. else
  225. echo "${CWARNING}input error! Please only input number 1~13${CEND}"
  226. fi
  227. done
  228. fi
  229. break
  230. fi
  231. done
  232. # check PHP
  233. while :; do echo
  234. read -p "Do you want to install PHP? [y/n]: " PHP_yn
  235. if [[ ! $PHP_yn =~ ^[y,n]$ ]]; then
  236. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  237. else
  238. if [ "$PHP_yn" == 'y' ]; then
  239. [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; }
  240. while :; do echo
  241. echo 'Please select a version of the PHP:'
  242. echo -e "\t${CMSG}1${CEND}. Install php-5.3"
  243. echo -e "\t${CMSG}2${CEND}. Install php-5.4"
  244. echo -e "\t${CMSG}3${CEND}. Install php-5.5"
  245. echo -e "\t${CMSG}4${CEND}. Install php-5.6"
  246. echo -e "\t${CMSG}5${CEND}. Install php-7.0"
  247. echo -e "\t${CMSG}6${CEND}. Install php-7.1"
  248. echo -e "\t${CMSG}7${CEND}. Install php-7.2"
  249. read -p "Please input a number:(Default 5 press Enter) " PHP_version
  250. [ -z "$PHP_version" ] && PHP_version=5
  251. if [[ ! $PHP_version =~ ^[1-7]$ ]]; then
  252. echo "${CWARNING}input error! Please only input number 1~7${CEND}"
  253. else
  254. while :; do echo
  255. read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn
  256. if [[ ! $PHP_cache_yn =~ ^[y,n]$ ]]; then
  257. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  258. else
  259. if [ "$PHP_cache_yn" == 'y' ]; then
  260. if [ $PHP_version == 1 ]; then
  261. while :; do
  262. echo 'Please select a opcode cache of the PHP:'
  263. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  264. echo -e "\t${CMSG}2${CEND}. Install XCache"
  265. echo -e "\t${CMSG}3${CEND}. Install APCU"
  266. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
  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-4]$ ]]; then
  270. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  271. else
  272. break
  273. fi
  274. done
  275. fi
  276. if [ $PHP_version == 2 ]; then
  277. while :; do
  278. echo 'Please select a opcode cache of the PHP:'
  279. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  280. echo -e "\t${CMSG}2${CEND}. Install XCache"
  281. echo -e "\t${CMSG}3${CEND}. Install APCU"
  282. echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
  283. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  284. [ -z "$PHP_cache" ] && PHP_cache=1
  285. if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
  286. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  287. else
  288. break
  289. fi
  290. done
  291. fi
  292. if [ $PHP_version == 3 ]; then
  293. while :; do
  294. echo 'Please select a opcode cache of the PHP:'
  295. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  296. echo -e "\t${CMSG}2${CEND}. Install XCache"
  297. echo -e "\t${CMSG}3${CEND}. Install APCU"
  298. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  299. [ -z "$PHP_cache" ] && PHP_cache=1
  300. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  301. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  302. else
  303. break
  304. fi
  305. done
  306. fi
  307. if [ $PHP_version == 4 ]; then
  308. while :; do
  309. echo 'Please select a opcode cache of the PHP:'
  310. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  311. echo -e "\t${CMSG}2${CEND}. Install XCache"
  312. echo -e "\t${CMSG}3${CEND}. Install APCU"
  313. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  314. [ -z "$PHP_cache" ] && PHP_cache=1
  315. if [[ ! $PHP_cache =~ ^[1-3]$ ]]; then
  316. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  317. else
  318. break
  319. fi
  320. done
  321. fi
  322. if [[ $PHP_version =~ ^[5-6]$ ]]; then
  323. while :; do
  324. echo 'Please select a opcode cache of the PHP:'
  325. echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
  326. echo -e "\t${CMSG}3${CEND}. Install APCU"
  327. read -p "Please input a number:(Default 1 press Enter) " PHP_cache
  328. [ -z "$PHP_cache" ] && PHP_cache=1
  329. if [[ ! $PHP_cache =~ ^[1,3]$ ]]; then
  330. echo "${CWARNING}input error! Please only input number 1,3${CEND}"
  331. else
  332. break
  333. fi
  334. done
  335. fi
  336. [ $PHP_version == 7 ] && PHP_cache=1
  337. fi
  338. break
  339. fi
  340. done
  341. if [ "$PHP_cache" == '2' ]; then
  342. while :; do
  343. read -p "Please input xcache admin password: " xcache_admin_pass
  344. (( ${#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}"
  345. done
  346. fi
  347. if [[ $PHP_version =~ ^[1-4]$ ]] && [ "$PHP_cache" != '1' -a "${armPlatform}" != "y" ]; then
  348. while :; do echo
  349. read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
  350. if [[ ! $ZendGuardLoader_yn =~ ^[y,n]$ ]]; then
  351. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  352. else
  353. break
  354. fi
  355. done
  356. fi
  357. # ionCube
  358. if [ "${TARGET_ARCH}" != "arm64" ]; then
  359. while :; do echo
  360. read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
  361. if [[ ! $ionCube_yn =~ ^[y,n]$ ]]; then
  362. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  363. else
  364. break
  365. fi
  366. done
  367. fi
  368. # ImageMagick or GraphicsMagick
  369. while :; do echo
  370. read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
  371. if [[ ! $Magick_yn =~ ^[y,n]$ ]]; then
  372. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  373. else
  374. break
  375. fi
  376. done
  377. if [ "$Magick_yn" == 'y' ]; then
  378. while :; do
  379. echo 'Please select ImageMagick or GraphicsMagick:'
  380. echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
  381. echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
  382. read -p "Please input a number:(Default 1 press Enter) " Magick
  383. [ -z "$Magick" ] && Magick=1
  384. if [[ ! $Magick =~ ^[1-2]$ ]]; then
  385. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  386. else
  387. break
  388. fi
  389. done
  390. fi
  391. break
  392. fi
  393. done
  394. fi
  395. break
  396. fi
  397. done
  398. # check Pureftpd
  399. while :; do echo
  400. read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
  401. if [[ ! $FTP_yn =~ ^[y,n]$ ]]; then
  402. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  403. else
  404. [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; FTP_yn=Other; }
  405. break
  406. fi
  407. done
  408. # check phpMyAdmin
  409. if [[ $PHP_version =~ ^[1-7]$ ]] || [ -e "$php_install_dir/bin/phpize" ]; then
  410. while :; do echo
  411. read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
  412. if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]]; then
  413. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  414. else
  415. [ "$phpMyAdmin_yn" == 'y' -a -d "$wwwroot_dir/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpMyAdmin_yn=Other; }
  416. break
  417. fi
  418. done
  419. fi
  420. # check redis
  421. while :; do echo
  422. read -p "Do you want to install redis? [y/n]: " redis_yn
  423. if [[ ! $redis_yn =~ ^[y,n]$ ]]; then
  424. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  425. else
  426. break
  427. fi
  428. done
  429. # check memcached
  430. while :; do echo
  431. read -p "Do you want to install memcached? [y/n]: " memcached_yn
  432. if [[ ! $memcached_yn =~ ^[y,n]$ ]]; then
  433. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  434. else
  435. break
  436. fi
  437. done
  438. while :; do echo
  439. read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
  440. if [[ ! $HHVM_yn =~ ^[y,n]$ ]]; then
  441. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  442. else
  443. if [ "$HHVM_yn" == 'y' ]; then
  444. [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; HHVM_yn=Other; break; }
  445. if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.[5-9]' /etc/redhat-release`" ]; then
  446. break
  447. else
  448. echo
  449. echo "${CWARNING}HHVM only support CentOS6.5+ 64bit, CentOS7 64bit! ${CEND}"
  450. echo "Press Ctrl+c to cancel or Press any key to continue..."
  451. char=`get_char`
  452. HHVM_yn=Other
  453. fi
  454. fi
  455. break
  456. fi
  457. done
  458. # get the IP information
  459. IPADDR=`./include/get_ipaddr.py`
  460. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  461. IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
  462. IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
  463. [ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun
  464. # del openssl for jcloud
  465. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  466. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  467. # Check binary dependencies packages
  468. . ./include/check_sw.sh
  469. case "${OS}" in
  470. "CentOS")
  471. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  472. ;;
  473. "Debian")
  474. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  475. ;;
  476. "Ubuntu")
  477. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  478. ;;
  479. esac
  480. # init
  481. startTime=`date +%s`
  482. . ./include/memory.sh
  483. case "${OS}" in
  484. "CentOS")
  485. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  486. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  487. ;;
  488. "Debian")
  489. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  490. ;;
  491. "Ubuntu")
  492. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  493. ;;
  494. esac
  495. # Check download source packages
  496. . ./include/check_download.sh
  497. downloadDepsSrc=1
  498. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  499. # Install dependencies from source package
  500. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  501. # Jemalloc
  502. if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' ]; then
  503. . include/jemalloc.sh
  504. Install_Jemalloc | tee -a $oneinstack_dir/install.log
  505. fi
  506. # openSSL
  507. . ./include/openssl.sh
  508. if [[ $Tomcat_version =~ ^[1-3]$ ]] || [[ $Apache_version =~ ^[1-2]$ ]] || [[ $PHP_version =~ ^[1-7]$ ]]; then
  509. Install_openSSL102 | tee -a $oneinstack_dir/install.log
  510. fi
  511. # Database
  512. case "${DB_version}" in
  513. 1)
  514. if [ "${dbInstallMethods}" == "2" ]; then
  515. . include/boost.sh
  516. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  517. fi
  518. . include/mysql-5.7.sh
  519. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  520. ;;
  521. 2)
  522. . include/mysql-5.6.sh
  523. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  524. ;;
  525. 3)
  526. . include/mysql-5.5.sh
  527. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  528. ;;
  529. 4)
  530. if [ "${dbInstallMethods}" == "2" ]; then
  531. . include/boost.sh
  532. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  533. fi
  534. . include/mariadb-10.2.sh
  535. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  536. ;;
  537. 5)
  538. if [ "${dbInstallMethods}" == "2" ]; then
  539. . include/boost.sh
  540. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  541. fi
  542. . include/mariadb-10.1.sh
  543. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  544. ;;
  545. 6)
  546. . include/mariadb-10.0.sh
  547. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  548. ;;
  549. 7)
  550. . include/mariadb-5.5.sh
  551. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  552. ;;
  553. 8)
  554. if [ "${dbInstallMethods}" == "2" ]; then
  555. . include/boost.sh
  556. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  557. fi
  558. . include/percona-5.7.sh
  559. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  560. ;;
  561. 9)
  562. . include/percona-5.6.sh
  563. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  564. ;;
  565. 10)
  566. . include/percona-5.5.sh
  567. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  568. ;;
  569. 11)
  570. . include/alisql-5.6.sh
  571. Install_AliSQL56 2>&1 | tee -a $oneinstack_dir/install.log
  572. ;;
  573. 12)
  574. . include/postgresql.sh
  575. Install_PostgreSQL 2>&1 | tee -a $oneinstack_dir/install.log
  576. ;;
  577. 13)
  578. . include/mongodb.sh
  579. Install_MongoDB 2>&1 | tee -a $oneinstack_dir/install.log
  580. ;;
  581. esac
  582. # Apache
  583. if [ "$Apache_version" == '1' ]; then
  584. . include/apache-2.4.sh
  585. Install_Apache24 2>&1 | tee -a $oneinstack_dir/install.log
  586. elif [ "$Apache_version" == '2' ]; then
  587. . include/apache-2.2.sh
  588. Install_Apache22 2>&1 | tee -a $oneinstack_dir/install.log
  589. fi
  590. # PHP
  591. case "${PHP_version}" in
  592. 1)
  593. . include/php-5.3.sh
  594. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  595. ;;
  596. 2)
  597. . include/php-5.4.sh
  598. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  599. ;;
  600. 3)
  601. . include/php-5.5.sh
  602. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  603. ;;
  604. 4)
  605. . include/php-5.6.sh
  606. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  607. ;;
  608. 5)
  609. . include/php-7.0.sh
  610. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  611. ;;
  612. 6)
  613. . include/php-7.1.sh
  614. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  615. ;;
  616. 7)
  617. . include/php-7.2.sh
  618. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  619. ;;
  620. esac
  621. # pecl_pgsql
  622. if [ "${DB_version}" == '12' -a -e "${php_install_dir}/bin/phpize" ]; then
  623. . include/pecl_pgsql.sh
  624. Install_pecl-pgsql 2>&1 | tee -a $oneinstack_dir/install.log
  625. fi
  626. # pecl_mongodb
  627. if [ "${DB_version}" == '13' -a -e "${php_install_dir}/bin/phpize" ]; then
  628. . include/pecl_mongodb.sh
  629. Install_pecl-mongodb 2>&1 | tee -a $oneinstack_dir/install.log
  630. fi
  631. # ImageMagick or GraphicsMagick
  632. if [ "$Magick" == '1' ]; then
  633. . include/ImageMagick.sh
  634. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
  635. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a $oneinstack_dir/install.log
  636. elif [ "$Magick" == '2' ]; then
  637. . include/GraphicsMagick.sh
  638. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
  639. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a $oneinstack_dir/install.log
  640. fi
  641. # ionCube
  642. if [ "$ionCube_yn" == 'y' ]; then
  643. . include/ioncube.sh
  644. Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
  645. fi
  646. # PHP opcode cache
  647. case "${PHP_cache}" in
  648. 1)
  649. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  650. . include/zendopcache.sh
  651. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  652. fi
  653. ;;
  654. 2)
  655. . include/xcache.sh
  656. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  657. ;;
  658. 3)
  659. . include/apcu.sh
  660. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  661. ;;
  662. 4)
  663. if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
  664. . include/eaccelerator.sh
  665. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  666. fi
  667. ;;
  668. esac
  669. # ZendGuardLoader (php <= 5.6)
  670. if [ "$ZendGuardLoader_yn" == 'y' ]; then
  671. . include/ZendGuardLoader.sh
  672. Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
  673. fi
  674. # Web server
  675. case "${Nginx_version}" in
  676. 1)
  677. . include/nginx.sh
  678. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  679. ;;
  680. 2)
  681. . include/tengine.sh
  682. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  683. ;;
  684. 3)
  685. . include/openresty.sh
  686. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  687. ;;
  688. esac
  689. # JDK
  690. case "${JDK_version}" in
  691. 1)
  692. . include/jdk-1.8.sh
  693. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  694. ;;
  695. 2)
  696. . include/jdk-1.7.sh
  697. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  698. ;;
  699. 3)
  700. . include/jdk-1.6.sh
  701. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  702. ;;
  703. esac
  704. case "${Tomcat_version}" in
  705. 1)
  706. . include/tomcat-8.sh
  707. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  708. ;;
  709. 2)
  710. . include/tomcat-7.sh
  711. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  712. ;;
  713. 3)
  714. . include/tomcat-6.sh
  715. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  716. ;;
  717. esac
  718. # Pure-FTPd
  719. if [ "${FTP_yn}" == 'y' ]; then
  720. . include/pureftpd.sh
  721. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  722. fi
  723. # phpMyAdmin
  724. if [ "${phpMyAdmin_yn}" == 'y' ]; then
  725. . include/phpmyadmin.sh
  726. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  727. fi
  728. # redis
  729. if [ "${redis_yn}" == 'y' ]; then
  730. . include/redis.sh
  731. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  732. [ -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
  733. fi
  734. # memcached
  735. if [ "${memcached_yn}" == 'y' ]; then
  736. . include/memcached.sh
  737. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  738. [ -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
  739. [ -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
  740. fi
  741. # index example
  742. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${Web_yn}" == 'y' ]; then
  743. . include/demo.sh
  744. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  745. fi
  746. # get web_install_dir and db_install_dir
  747. . include/check_dir.sh
  748. # HHVM
  749. if [ "${HHVM_yn}" == 'y' ]; then
  750. . include/hhvm_CentOS.sh
  751. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  752. fi
  753. # Starting DB
  754. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  755. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  756. endTime=`date +%s`
  757. ((installTime=($endTime-$startTime)/60))
  758. echo "####################Congratulations########################"
  759. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  760. [ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  761. [ "${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}"
  762. [ "${Web_yn}" == 'y' -a "${Nginx_version}" == '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  763. [[ "${Tomcat_version}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  764. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  765. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  766. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  767. [[ "${DB_version}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  768. [ "${DB_version}" == '12' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  769. [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  770. [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  771. [ "${DB_version}" == '12' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  772. [ "${DB_version}" == '13' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  773. [ "${DB_version}" == '13' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  774. [ "${DB_version}" == '13' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  775. [ "${DB_version}" == '13' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  776. [ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  777. [ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  778. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  779. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  780. [ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}"
  781. [ "${PHP_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  782. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  783. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  784. [ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  785. [ "${FTP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  786. [ "${FTP_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  787. [ "${phpMyAdmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  788. [ "${phpMyAdmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  789. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  790. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  791. [ "${Web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  792. while :; do echo
  793. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  794. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  795. if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
  796. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  797. else
  798. break
  799. fi
  800. done
  801. [ "${restart_yn}" == 'y' ] && reboot