install.sh 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  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`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
  34. while :; do echo
  35. read -p "Please input SSH port(Default: $now_ssh_port): " ssh_port
  36. [ -z "$ssh_port" ] && ssh_port=$now_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_ver
  73. [ -z "$nginx_ver" ] && nginx_ver=1
  74. if [[ ! $nginx_ver =~ ^[1-4]$ ]]; then
  75. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  76. else
  77. [ "$nginx_ver" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; nginx_ver=Other; }
  78. [ "$nginx_ver" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; nginx_ver=Other; }
  79. [ "$nginx_ver" != '4' -a -e "$openresty_install_dir/nginx/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; nginx_ver=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_ver
  90. [ -z "$apache_ver" ] && apache_ver=3
  91. if [[ ! $apache_ver =~ ^[1-3]$ ]]; then
  92. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  93. else
  94. [ "$apache_ver" != '3' -a -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_ver=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_ver
  106. [ -z "$tomcat_ver" ] && tomcat_ver=4
  107. if [[ ! $tomcat_ver =~ ^[1-4]$ ]]; then
  108. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  109. else
  110. [ "$tomcat_ver" != '4' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; tomcat_ver=Other; }
  111. if [ "$tomcat_ver" == '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_ver" == '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_ver" == '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" -a -e "${mongo_install_dir}/bin/mongo" ] && { 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_ver
  183. [ -z "$db_ver" ] && db_ver=2
  184. [ "$db_ver" == '13' -a "$OS_BIT" == '32' ] && { echo "${CWARNING}By not supporting 32-bit! ${CEND}"; continue; }
  185. if [[ "${db_ver}" =~ ^[1-9]$|^1[0-3]$ ]]; then
  186. while :; do
  187. if [ "$db_ver" == '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_ver" == '12' ]; then
  195. sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbrootpwd'+" ./options.conf
  196. dbpostgrespwd="$dbrootpwd"
  197. elif [ "$db_ver" == '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_ver}" =~ ^[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) " dbinstallmethod
  215. [ -z "$dbinstallmethod" ] && dbinstallmethod=1
  216. if [[ ! $dbinstallmethod =~ ^[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_ver
  250. [ -z "$php_ver" ] && php_ver=5
  251. if [[ ! $php_ver =~ ^[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_ver == 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_ver == 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_ver == 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_ver == 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_ver =~ ^[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_ver == 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_ver =~ ^[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_ver =~ ^[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. # del openssl for jcloud
  464. [ -e "/usr/local/bin/openssl" ] && rm -rf /usr/local/bin/openssl
  465. [ -e "/usr/local/include/openssl" ] && rm -rf /usr/local/include/openssl
  466. # Check binary dependencies packages
  467. . ./include/check_sw.sh
  468. case "${OS}" in
  469. "CentOS")
  470. installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
  471. ;;
  472. "Debian")
  473. installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
  474. ;;
  475. "Ubuntu")
  476. installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
  477. ;;
  478. esac
  479. # init
  480. startTime=`date +%s`
  481. . ./include/memory.sh
  482. case "${OS}" in
  483. "CentOS")
  484. . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  485. [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
  486. ;;
  487. "Debian")
  488. . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  489. ;;
  490. "Ubuntu")
  491. . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
  492. ;;
  493. esac
  494. # Check download source packages
  495. . ./include/check_download.sh
  496. downloadDepsSrc=1
  497. checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
  498. # Install dependencies from source package
  499. installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
  500. # Jemalloc
  501. if [[ $nginx_ver =~ ^[1-3]$ ]] || [ "$db_yn" == 'y' ]; then
  502. . include/jemalloc.sh
  503. Install_Jemalloc | tee -a $oneinstack_dir/install.log
  504. fi
  505. # openSSL
  506. . ./include/openssl.sh
  507. if [[ $tomcat_ver =~ ^[1-3]$ ]] || [[ $apache_ver =~ ^[1-2]$ ]] || [[ $php_ver =~ ^[1-7]$ ]]; then
  508. Install_openSSL102 | tee -a $oneinstack_dir/install.log
  509. fi
  510. # Database
  511. case "${db_ver}" in
  512. 1)
  513. if [ "${dbinstallmethod}" == "2" ]; then
  514. . include/boost.sh
  515. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  516. fi
  517. . include/mysql-5.7.sh
  518. Install_MySQL57 2>&1 | tee -a ${oneinstack_dir}/install.log
  519. ;;
  520. 2)
  521. . include/mysql-5.6.sh
  522. Install_MySQL56 2>&1 | tee -a ${oneinstack_dir}/install.log
  523. ;;
  524. 3)
  525. . include/mysql-5.5.sh
  526. Install_MySQL55 2>&1 | tee -a ${oneinstack_dir}/install.log
  527. ;;
  528. 4)
  529. if [ "${dbinstallmethod}" == "2" ]; then
  530. . include/boost.sh
  531. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  532. fi
  533. . include/mariadb-10.2.sh
  534. Install_MariaDB102 2>&1 | tee -a ${oneinstack_dir}/install.log
  535. ;;
  536. 5)
  537. if [ "${dbinstallmethod}" == "2" ]; then
  538. . include/boost.sh
  539. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  540. fi
  541. . include/mariadb-10.1.sh
  542. Install_MariaDB101 2>&1 | tee -a ${oneinstack_dir}/install.log
  543. ;;
  544. 6)
  545. . include/mariadb-10.0.sh
  546. Install_MariaDB100 2>&1 | tee -a ${oneinstack_dir}/install.log
  547. ;;
  548. 7)
  549. . include/mariadb-5.5.sh
  550. Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
  551. ;;
  552. 8)
  553. if [ "${dbinstallmethod}" == "2" ]; then
  554. . include/boost.sh
  555. installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
  556. fi
  557. . include/percona-5.7.sh
  558. Install_Percona57 2>&1 | tee -a ${oneinstack_dir}/install.log
  559. ;;
  560. 9)
  561. . include/percona-5.6.sh
  562. Install_Percona56 2>&1 | tee -a ${oneinstack_dir}/install.log
  563. ;;
  564. 10)
  565. . include/percona-5.5.sh
  566. Install_Percona55 2>&1 | tee -a ${oneinstack_dir}/install.log
  567. ;;
  568. 11)
  569. . include/alisql-5.6.sh
  570. Install_AliSQL56 2>&1 | tee -a $oneinstack_dir/install.log
  571. ;;
  572. 12)
  573. . include/postgresql.sh
  574. Install_PostgreSQL 2>&1 | tee -a $oneinstack_dir/install.log
  575. ;;
  576. 13)
  577. . include/mongodb.sh
  578. Install_MongoDB 2>&1 | tee -a $oneinstack_dir/install.log
  579. ;;
  580. esac
  581. # Apache
  582. if [ "$apache_ver" == '1' ]; then
  583. . include/apache-2.4.sh
  584. Install_Apache24 2>&1 | tee -a $oneinstack_dir/install.log
  585. elif [ "$apache_ver" == '2' ]; then
  586. . include/apache-2.2.sh
  587. Install_Apache22 2>&1 | tee -a $oneinstack_dir/install.log
  588. fi
  589. # PHP
  590. case "${php_ver}" in
  591. 1)
  592. . include/php-5.3.sh
  593. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  594. ;;
  595. 2)
  596. . include/php-5.4.sh
  597. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  598. ;;
  599. 3)
  600. . include/php-5.5.sh
  601. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  602. ;;
  603. 4)
  604. . include/php-5.6.sh
  605. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  606. ;;
  607. 5)
  608. . include/php-7.0.sh
  609. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  610. ;;
  611. 6)
  612. . include/php-7.1.sh
  613. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  614. ;;
  615. 7)
  616. . include/php-7.2.sh
  617. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  618. ;;
  619. esac
  620. # pecl_pgsql
  621. if [ "${db_ver}" == '12' -a -e "${php_install_dir}/bin/phpize" ]; then
  622. . include/pecl_pgsql.sh
  623. Install_pecl-pgsql 2>&1 | tee -a $oneinstack_dir/install.log
  624. fi
  625. # pecl_mongodb
  626. if [ "${db_ver}" == '13' -a -e "${php_install_dir}/bin/phpize" ]; then
  627. . include/pecl_mongodb.sh
  628. Install_pecl-mongodb 2>&1 | tee -a $oneinstack_dir/install.log
  629. fi
  630. # ImageMagick or GraphicsMagick
  631. if [ "$magick" == '1' ]; then
  632. . include/ImageMagick.sh
  633. [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick 2>&1 | tee -a $oneinstack_dir/install.log
  634. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/imagick.so" ] && Install_php-imagick 2>&1 | tee -a $oneinstack_dir/install.log
  635. elif [ "$magick" == '2' ]; then
  636. . include/GraphicsMagick.sh
  637. [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick 2>&1 | tee -a $oneinstack_dir/install.log
  638. [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/gmagick.so" ] && Install_php-gmagick 2>&1 | tee -a $oneinstack_dir/install.log
  639. fi
  640. # ionCube
  641. if [ "$ioncube_yn" == 'y' ]; then
  642. . include/ioncube.sh
  643. Install_ionCube 2>&1 | tee -a $oneinstack_dir/install.log
  644. fi
  645. # PHP opcode cache
  646. case "${php_cache}" in
  647. 1)
  648. if [[ "${php_ver}" =~ ^[1,2]$ ]]; then
  649. . include/zendopcache.sh
  650. Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
  651. fi
  652. ;;
  653. 2)
  654. . include/xcache.sh
  655. Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
  656. ;;
  657. 3)
  658. . include/apcu.sh
  659. Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
  660. ;;
  661. 4)
  662. if [[ "${php_ver}" =~ ^[1,2]$ ]]; then
  663. . include/eaccelerator.sh
  664. Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
  665. fi
  666. ;;
  667. esac
  668. # ZendGuardLoader (php <= 5.6)
  669. if [ "$zendguardloader_yn" == 'y' ]; then
  670. . include/ZendGuardLoader.sh
  671. Install_ZendGuardLoader 2>&1 | tee -a $oneinstack_dir/install.log
  672. fi
  673. # Web server
  674. case "${nginx_ver}" in
  675. 1)
  676. . include/nginx.sh
  677. Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
  678. ;;
  679. 2)
  680. . include/tengine.sh
  681. Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
  682. ;;
  683. 3)
  684. . include/openresty.sh
  685. Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
  686. ;;
  687. esac
  688. # JDK
  689. case "${jdk_version}" in
  690. 1)
  691. . include/jdk-1.8.sh
  692. Install-JDK18 2>&1 | tee -a ${oneinstack_dir}/install.log
  693. ;;
  694. 2)
  695. . include/jdk-1.7.sh
  696. Install-JDK17 2>&1 | tee -a ${oneinstack_dir}/install.log
  697. ;;
  698. 3)
  699. . include/jdk-1.6.sh
  700. Install-JDK16 2>&1 | tee -a ${oneinstack_dir}/install.log
  701. ;;
  702. esac
  703. case "${tomcat_ver}" in
  704. 1)
  705. . include/tomcat-8.sh
  706. Install_Tomcat8 2>&1 | tee -a ${oneinstack_dir}/install.log
  707. ;;
  708. 2)
  709. . include/tomcat-7.sh
  710. Install_Tomcat7 2>&1 | tee -a ${oneinstack_dir}/install.log
  711. ;;
  712. 3)
  713. . include/tomcat-6.sh
  714. Install_Tomcat6 2>&1 | tee -a ${oneinstack_dir}/install.log
  715. ;;
  716. esac
  717. # Pure-FTPd
  718. if [ "${ftp_yn}" == 'y' ]; then
  719. . include/pureftpd.sh
  720. Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
  721. fi
  722. # phpMyAdmin
  723. if [ "${phpmyadmin_yn}" == 'y' ]; then
  724. . include/phpmyadmin.sh
  725. Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
  726. fi
  727. # redis
  728. if [ "${redis_yn}" == 'y' ]; then
  729. . include/redis.sh
  730. [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
  731. [ -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
  732. fi
  733. # memcached
  734. if [ "${memcached_yn}" == 'y' ]; then
  735. . include/memcached.sh
  736. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
  737. [ -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
  738. [ -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
  739. fi
  740. # index example
  741. if [ ! -e "${wwwroot_dir}/default/index.html" -a "${web_yn}" == 'y' ]; then
  742. . include/demo.sh
  743. DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
  744. fi
  745. # get web_install_dir and db_install_dir
  746. . include/check_dir.sh
  747. # HHVM
  748. if [ "${hhvm_yn}" == 'y' ]; then
  749. . include/hhvm_CentOS.sh
  750. Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
  751. fi
  752. # Starting DB
  753. [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  754. [ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
  755. endTime=`date +%s`
  756. ((installTime=($endTime-$startTime)/60))
  757. echo "####################Congratulations########################"
  758. echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
  759. [ "${web_yn}" == 'y' -a "${nginx_ver}" != '4' -a "${apache_ver}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
  760. [ "${web_yn}" == 'y' -a "${nginx_ver}" != '4' -a "${apache_ver}" != '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}"
  761. [ "${web_yn}" == 'y' -a "${nginx_ver}" == '4' -a "${apache_ver}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
  762. [[ "${tomcat_ver}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
  763. [[ "${db_ver}" =~ ^[1-9]$|^1[0-1]$ ]] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
  764. [[ "${db_ver}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
  765. [[ "${db_ver}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
  766. [[ "${db_ver}" =~ ^[1-9]$|^1[0-1]$ ]] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
  767. [ "${db_ver}" == '12' ] && echo -e "\n$(printf "%-32s" "PostgreSQL install dir:")${CMSG}${pgsql_install_dir}${CEND}"
  768. [ "${db_ver}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL data dir:")${CMSG}${pgsql_data_dir}${CEND}"
  769. [ "${db_ver}" == '12' ] && echo "$(printf "%-32s" "PostgreSQL user:")${CMSG}postgres${CEND}"
  770. [ "${db_ver}" == '12' ] && echo "$(printf "%-32s" "postgres password:")${CMSG}${dbpostgrespwd}${CEND}"
  771. [ "${db_ver}" == '13' ] && echo -e "\n$(printf "%-32s" "MongoDB install dir:")${CMSG}${mongo_install_dir}${CEND}"
  772. [ "${db_ver}" == '13' ] && echo "$(printf "%-32s" "MongoDB data dir:")${CMSG}${mongo_data_dir}${CEND}"
  773. [ "${db_ver}" == '13' ] && echo "$(printf "%-32s" "MongoDB user:")${CMSG}root${CEND}"
  774. [ "${db_ver}" == '13' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
  775. [ "${php_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
  776. [ "${php_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
  777. [ "${php_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
  778. [ "${php_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
  779. [ "${php_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}"
  780. [ "${php_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
  781. [ "${php_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
  782. [ "${php_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
  783. [ "${php_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
  784. [ "${ftp_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
  785. [ "${ftp_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
  786. [ "${phpmyadmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
  787. [ "${phpmyadmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel URL:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
  788. [ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
  789. [ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
  790. [ "${web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Index URL:")${CMSG}http://${IPADDR}/${CEND}"
  791. while :; do echo
  792. echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
  793. read -p "Do you want to restart OS ? [y/n]: " restart_yn
  794. if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
  795. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  796. else
  797. break
  798. fi
  799. done
  800. [ "${restart_yn}" == 'y' ] && reboot