addons.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # Install/Uninstall Extensions #
  16. # For more information please visit https://oneinstack.com #
  17. #######################################################################
  18. "
  19. # Check if user is root
  20. [ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  21. oneinstack_dir=$(dirname "`readlink -f $0`")
  22. pushd ${oneinstack_dir} > /dev/null
  23. # get the IP information
  24. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  25. IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
  26. . ./versions.txt
  27. . ./options.conf
  28. . ./include/color.sh
  29. . ./include/memory.sh
  30. . ./include/check_os.sh
  31. . ./include/check_download.sh
  32. . ./include/download.sh
  33. . ./include/get_char.sh
  34. . ./include/zendopcache.sh
  35. . ./include/xcache.sh
  36. . ./include/apcu.sh
  37. . ./include/eaccelerator.sh
  38. . ./include/ZendGuardLoader.sh
  39. . ./include/ioncube.sh
  40. . ./include/ImageMagick.sh
  41. . ./include/GraphicsMagick.sh
  42. . ./include/memcached.sh
  43. . ./include/redis.sh
  44. . ./include/python.sh
  45. . ./include/ngx_lua_waf.sh
  46. # Check PHP
  47. if [ -e "${php_install_dir}/bin/phpize" ]; then
  48. phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
  49. PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
  50. PHP_main_ver=${PHP_detail_ver%.*}
  51. fi
  52. # Check PHP Extensions
  53. Check_PHP_Extension() {
  54. [ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; }
  55. [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { echo "${CWARNING}PHP ${PHP_extension} module already installed! ${CEND}"; exit 1; }
  56. }
  57. # restart PHP
  58. Restart_PHP() {
  59. [ -e "${apache_install_dir}/conf/httpd.conf" ] && /etc/init.d/httpd restart || /etc/init.d/php-fpm restart
  60. }
  61. # Check succ
  62. Check_succ() {
  63. [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP ${PHP_extension} module installed successfully! ${CEND}"; }
  64. }
  65. # Uninstall succ
  66. Uninstall_succ() {
  67. [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { rm -rf ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini; Restart_PHP; echo; echo "${CMSG}PHP ${PHP_extension} module uninstall completed${CEND}"; } || { echo; echo "${CWARNING}${PHP_extension} module does not exist! ${CEND}"; }
  68. }
  69. Install_fail2ban() {
  70. [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
  71. pushd ${oneinstack_dir}/src > /dev/null
  72. src_url=http://mirrors.linuxeye.com/oneinstack/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src
  73. tar xzf fail2ban-${fail2ban_ver}.tar.gz
  74. pushd fail2ban-${fail2ban_ver}
  75. ${python_install_dir}/bin/python setup.py install
  76. if [ "${OS}" == "CentOS" ]; then
  77. LOGPATH=/var/log/secure
  78. /bin/cp files/redhat-initd /etc/init.d/fail2ban
  79. sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/init.d/fail2ban
  80. sed -i 's@Starting fail2ban.*@&\n [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/init.d/fail2ban
  81. chmod +x /etc/init.d/fail2ban
  82. chkconfig --add fail2ban
  83. chkconfig fail2ban on
  84. fi
  85. if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then
  86. LOGPATH=/var/log/auth.log
  87. /bin/cp files/debian-initd /etc/init.d/fail2ban
  88. sed -i 's@2 3 4 5@3 4 5@' /etc/init.d/fail2ban
  89. sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/init.d/fail2ban
  90. chmod +x /etc/init.d/fail2ban
  91. update-rc.d fail2ban defaults
  92. fi
  93. [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1`
  94. cat > /etc/fail2ban/jail.local << EOF
  95. [DEFAULT]
  96. ignoreip = 127.0.0.1/8
  97. bantime = 86400
  98. findtime = 600
  99. maxretry = 5
  100. [ssh-iptables]
  101. enabled = true
  102. filter = sshd
  103. action = iptables[name=SSH, port=$now_ssh_port, protocol=tcp]
  104. logpath = $LOGPATH
  105. EOF
  106. cat > /etc/logrotate.d/fail2ban << EOF
  107. /var/log/fail2ban.log {
  108. missingok
  109. notifempty
  110. postrotate
  111. ${python_install_dir}/bin/fail2ban-client flushlogs >/dev/null || true
  112. endscript
  113. }
  114. EOF
  115. sed -i 's@^iptables = iptables.*@iptables = iptables@' /etc/fail2ban/action.d/iptables-common.conf
  116. kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1
  117. /etc/init.d/fail2ban start
  118. popd
  119. if [ -e "${python_install_dir}/bin/fail2ban-python" ]; then
  120. echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}"
  121. else
  122. echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}"
  123. fi
  124. popd
  125. }
  126. Uninstall_fail2ban() {
  127. /etc/init.d/fail2ban stop
  128. ${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1
  129. rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
  130. echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
  131. }
  132. ACTION_FUN() {
  133. while :; do
  134. echo
  135. echo "Please select an action:"
  136. echo -e "\t${CMSG}1${CEND}. install"
  137. echo -e "\t${CMSG}2${CEND}. uninstall"
  138. read -p "Please input a number:(Default 1 press Enter) " ACTION
  139. [ -z "${ACTION}" ] && ACTION=1
  140. if [[ ! "${ACTION}" =~ ^[1,2]$ ]]; then
  141. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  142. else
  143. break
  144. fi
  145. done
  146. }
  147. while :;do
  148. printf "
  149. What Are You Doing?
  150. \t${CMSG} 1${CEND}. Install/Uninstall PHP opcode cache
  151. \t${CMSG} 2${CEND}. Install/Uninstall ZendGuardLoader/ionCube PHP Extension
  152. \t${CMSG} 3${CEND}. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension
  153. \t${CMSG} 4${CEND}. Install/Uninstall fileinfo/imap PHP Extension
  154. \t${CMSG} 5${CEND}. Install/Uninstall memcached/memcache
  155. \t${CMSG} 6${CEND}. Install/Uninstall Redis
  156. \t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension
  157. \t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension
  158. \t${CMSG} 9${CEND}. Install/Uninstall PHP Composer
  159. \t${CMSG}10${CEND}. Install/Uninstall fail2ban
  160. \t${CMSG} q${CEND}. Exit
  161. "
  162. read -p "Please input the correct option: " Number
  163. if [[ ! "${Number}" =~ ^[1-9,q]$|^1[0-1]$ ]]; then
  164. echo "${CFAILURE}input error! Please only input 1~11 and q${CEND}"
  165. else
  166. case "${Number}" in
  167. 1)
  168. ACTION_FUN
  169. while :; do echo
  170. echo "Please select a opcode cache of the PHP:"
  171. echo -e "\t${CMSG}1${CEND}. Zend OPcache"
  172. echo -e "\t${CMSG}2${CEND}. XCache"
  173. echo -e "\t${CMSG}3${CEND}. APCU"
  174. echo -e "\t${CMSG}4${CEND}. eAccelerator"
  175. read -p "Please input a number:(Default 1 press Enter) " phpcache_option
  176. [ -z "${phpcache_option}" ] && phpcache_option=1
  177. if [[ ! "${phpcache_option}" =~ ^[1-4]$ ]]; then
  178. echo "${CWARNING}input error! Please only input number 1~4${CEND}"
  179. else
  180. case "${phpcache_option}" in
  181. 1)
  182. PHP_extension=opcache
  183. ;;
  184. 2)
  185. PHP_extension=xcache
  186. ;;
  187. 3)
  188. PHP_extension=apcu
  189. ;;
  190. 4)
  191. PHP_extension=eaccelerator
  192. ;;
  193. esac
  194. break
  195. fi
  196. done
  197. if [ "${ACTION}" = '1' ]; then
  198. Check_PHP_Extension
  199. case "${phpcache_option}" in
  200. 1)
  201. pushd ${oneinstack_dir}/src > /dev/null
  202. if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
  203. src_url=https://pecl.php.net/get/zendopcache-${zendopcache_ver}.tgz && Download_src
  204. Install_ZendOPcache
  205. else
  206. src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  207. Install_ZendOPcache
  208. fi
  209. popd
  210. Check_succ
  211. ;;
  212. 2)
  213. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
  214. while :; do
  215. read -p "Please input xcache admin password: " xcachepwd
  216. (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
  217. done
  218. checkDownload
  219. Install_XCache
  220. Check_succ
  221. else
  222. echo "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1
  223. fi
  224. ;;
  225. 3)
  226. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]]; then
  227. checkDownload
  228. Install_APCU
  229. Check_succ
  230. else
  231. echo "${CWARNING}Your php does not support APCU! ${CEND}"; exit 1
  232. fi
  233. ;;
  234. 4)
  235. if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
  236. checkDownload
  237. Install_eAccelerator
  238. Check_succ
  239. else
  240. echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
  241. fi
  242. ;;
  243. esac
  244. else
  245. Uninstall_succ
  246. fi
  247. ;;
  248. 2)
  249. ACTION_FUN
  250. while :; do echo
  251. echo "Please select ZendGuardLoader/ionCube:"
  252. echo -e "\t${CMSG}1${CEND}. ZendGuardLoader"
  253. echo -e "\t${CMSG}2${CEND}. ionCube Loader"
  254. read -p "Please input a number:(Default 1 press Enter) " Loader
  255. [ -z "${Loader}" ] && Loader=1
  256. if [[ ! "${Loader}" =~ ^[1,2]$ ]]; then
  257. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  258. else
  259. [ "${Loader}" = '1' ] && PHP_extension=ZendGuardLoader
  260. [ "${Loader}" = '2' ] && PHP_extension=ioncube
  261. break
  262. fi
  263. done
  264. if [ "${ACTION}" = '1' ]; then
  265. Check_PHP_Extension
  266. if [ "${Loader}" = '1' ]; then
  267. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]] && [ "${armplatform}" != 'y' ]; then
  268. zendguardloader_yn='y' && checkDownload
  269. Install_ZendGuardLoader
  270. Check_succ
  271. else
  272. echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
  273. fi
  274. elif [ "${Loader}" = '2' ]; then
  275. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${TARGET_ARCH}" != "arm64" ]; then
  276. ioncube_yn='y' && checkDownload
  277. Install_ionCube
  278. Restart_PHP; echo "${CSUCCESS}PHP ioncube module installed successfully! ${CEND}";
  279. else
  280. echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
  281. fi
  282. fi
  283. else
  284. Uninstall_succ
  285. fi
  286. ;;
  287. 3)
  288. ACTION_FUN
  289. while :; do echo
  290. echo "Please select ImageMagick/GraphicsMagick:"
  291. echo -e "\t${CMSG}1${CEND}. ImageMagick"
  292. echo -e "\t${CMSG}2${CEND}. GraphicsMagick"
  293. read -p "Please input a number:(Default 1 press Enter) " magick_option
  294. [ -z "${magick_option}" ] && magick_option=1
  295. if [[ ! "${magick_option}" =~ ^[1,2]$ ]]; then
  296. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  297. else
  298. [ "${magick_option}" = '1' ] && PHP_extension=imagick
  299. [ "${magick_option}" = '2' ] && PHP_extension=gmagick
  300. break
  301. fi
  302. done
  303. if [ "${ACTION}" = '1' ]; then
  304. Check_PHP_Extension
  305. magick_yn=y && checkDownload
  306. if [ "${magick_option}" = '1' ]; then
  307. [ ! -d "${imagick_install_dir}" ] && Install_ImageMagick
  308. Install_php-imagick
  309. Check_succ
  310. elif [ "${magick_option}" = '2' ]; then
  311. [ ! -d "${gmagick_install_dir}" ] && Install_GraphicsMagick
  312. Install_php-gmagick
  313. Check_succ
  314. fi
  315. else
  316. Uninstall_succ
  317. [ -d "${imagick_install_dir}" ] && rm -rf ${imagick_install_dir}
  318. [ -d "${gmagick_install_dir}" ] && rm -rf ${gmagick_install_dir}
  319. fi
  320. ;;
  321. 4)
  322. ACTION_FUN
  323. while :; do echo
  324. echo "Please select fileinfo/imap:"
  325. echo -e "\t${CMSG}1${CEND}. fileinfo"
  326. echo -e "\t${CMSG}2${CEND}. imap"
  327. read -p "Please input a number:(Default 1 press Enter) " phpext_option
  328. [ -z "${phpext_option}" ] && phpext_option=1
  329. if [[ ! "${phpext_option}" =~ ^[1,2]$ ]]; then
  330. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  331. else
  332. if [ "${phpext_option}" = '1' ]; then
  333. PHP_extension=fileinfo
  334. elif [ "${phpext_option}" = '2' ]; then
  335. PHP_extension=imap
  336. IMAP_ARGS='--with-kerberos --with-imap --with-imap-ssl'
  337. if [ "$OS" == 'CentOS' ]; then
  338. yum -y install libc-client-devel
  339. [ "${OS_BIT}" == '64' -a ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
  340. else
  341. apt-get -y install libc-client2007e-dev
  342. fi
  343. fi
  344. break
  345. fi
  346. done
  347. if [ "${ACTION}" = '1' ]; then
  348. Check_PHP_Extension
  349. pushd ${oneinstack_dir}/src > /dev/null
  350. src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  351. tar xzf php-${PHP_detail_ver}.tar.gz
  352. pushd php-${PHP_detail_ver}/ext/${PHP_extension}
  353. ${php_install_dir}/bin/phpize
  354. ./configure --with-php-config=${php_install_dir}/bin/php-config ${IMAP_ARGS}
  355. make -j ${THREAD} && make install
  356. popd;popd
  357. rm -rf php-${PHP_detail_ver}
  358. echo "extension=${PHP_extension}.so" > ${php_install_dir}/etc/php.d/04-${PHP_extension}.ini
  359. Check_succ
  360. else
  361. Uninstall_succ
  362. fi
  363. ;;
  364. 5)
  365. ACTION_FUN
  366. while :; do echo
  367. echo "Please select memcache/memcached PHP Extension:"
  368. echo -e "\t${CMSG}1${CEND}. memcache PHP Extension"
  369. echo -e "\t${CMSG}2${CEND}. memcached PHP Extension"
  370. echo -e "\t${CMSG}3${CEND}. memcache/memcached PHP Extension"
  371. read -p "Please input a number:(Default 1 press Enter) " Memcache
  372. [ -z "${Memcache}" ] && Memcache=1
  373. if [[ ! "${Memcache}" =~ ^[1-3]$ ]]; then
  374. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  375. else
  376. [ "${Memcache}" = '1' ] && PHP_extension=memcache
  377. [ "${Memcache}" = '2' ] && PHP_extension=memcached
  378. break
  379. fi
  380. done
  381. if [ "${ACTION}" = '1' ]; then
  382. memcached_yn=y && checkDownload
  383. case "${Memcache}" in
  384. 1)
  385. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
  386. Check_PHP_Extension
  387. Install_php-memcache
  388. Check_succ
  389. ;;
  390. 2)
  391. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
  392. Check_PHP_Extension
  393. Install_php-memcached
  394. Check_succ
  395. ;;
  396. 3)
  397. [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
  398. PHP_extension=memcache && Check_PHP_Extension
  399. Install_php-memcache
  400. PHP_extension=memcached && Check_PHP_Extension
  401. Install_php-memcached
  402. [ -f "${phpExtensionDir}/memcache.so" -a "${phpExtensionDir}/memcached.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP memcache/memcached module installed successfully! ${CEND}"; }
  403. ;;
  404. esac
  405. else
  406. PHP_extension=memcache && Uninstall_succ
  407. PHP_extension=memcached && Uninstall_succ
  408. [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; }
  409. fi
  410. ;;
  411. 6)
  412. ACTION_FUN
  413. PHP_extension=redis
  414. redis_yn=y && checkDownload
  415. if [ "${ACTION}" = '1' ]; then
  416. [ ! -d "${redis_install_dir}" ] && Install_redis-server
  417. Check_PHP_Extension
  418. Install_php-redis
  419. else
  420. Uninstall_succ
  421. [ -e "${redis_install_dir}" ] && { service redis-server stop > /dev/null 2>&1; rm -rf ${redis_install_dir} /etc/init.d/redis-server /usr/local/bin/redis-*; }
  422. fi
  423. ;;
  424. 7)
  425. ACTION_FUN
  426. PHP_extension=swoole
  427. if [ "${ACTION}" = '1' ]; then
  428. Check_PHP_Extension
  429. pushd ${oneinstack_dir}/src > /dev/null
  430. if [[ "${PHP_main_ver}" =~ ^7\.[0-2]$ ]]; then
  431. src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
  432. tar xzf swoole-${swoole_ver}.tgz
  433. pushd swoole-${swoole_ver}
  434. else
  435. src_url=https://pecl.php.net/get/swoole-1.10.5.tgz && Download_src
  436. tar xzf swoole-1.10.5.tgz
  437. pushd swoole-1.10.5
  438. fi
  439. ${php_install_dir}/bin/phpize
  440. ./configure --with-php-config=${php_install_dir}/bin/php-config
  441. make -j ${THREAD} && make install
  442. popd
  443. rm -rf swoole-${swoole_ver}
  444. popd
  445. echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
  446. Check_succ
  447. else
  448. Uninstall_succ
  449. fi
  450. ;;
  451. 8)
  452. ACTION_FUN
  453. PHP_extension=xdebug
  454. if [ "${ACTION}" = '1' ]; then
  455. Check_PHP_Extension
  456. pushd ${oneinstack_dir}/src > /dev/null
  457. if [[ "${PHP_main_ver}" =~ ^7\.[0-2]$ ]]; then
  458. src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
  459. src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
  460. tar xzf xdebug-${xdebug_ver}.tgz
  461. unzip -q webgrind-master.zip
  462. /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
  463. pushd xdebug-${xdebug_ver}
  464. elif [[ "${PHP_main_ver}" =~ ^5\.[5-6]$ ]]; then
  465. src_url=https://pecl.php.net/get/xdebug-2.5.5.tgz && Download_src
  466. src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
  467. tar xzf xdebug-2.5.5.tgz
  468. unzip -q webgrind-master.zip
  469. /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
  470. pushd xdebug-2.5.5
  471. else
  472. echo "${CWARNING}Need a PHP version >= 5.5.0 and <= 7.2.0${CEND}"
  473. exit 1
  474. fi
  475. ${php_install_dir}/bin/phpize
  476. ./configure --with-php-config=${php_install_dir}/bin/php-config
  477. make -j ${THREAD} && make install
  478. popd
  479. rm -rf xdebug-${xdebug_ver}
  480. popd
  481. [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; }
  482. [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; }
  483. chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/webgrind
  484. sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php
  485. sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php
  486. cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF
  487. [xdebug]
  488. zend_extension=xdebug.so
  489. xdebug.trace_output_dir=/tmp/xdebug
  490. xdebug.profiler_output_dir = /tmp/xdebug
  491. xdebug.profiler_enable = On
  492. xdebug.profiler_enable_trigger = 1
  493. EOF
  494. Check_succ
  495. echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}"
  496. else
  497. rm -rf /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind
  498. Uninstall_succ
  499. fi
  500. ;;
  501. 9)
  502. ACTION_FUN
  503. if [ "${ACTION}" = '1' ]; then
  504. [ -e "/usr/local/bin/composer" ] && { echo "${CWARNING}PHP Composer already installed! ${CEND}"; exit 1; }
  505. if [ "$IPADDR_COUNTRY"x == "CN"x ]; then
  506. wget -c https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
  507. ${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com
  508. else
  509. wget -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
  510. fi
  511. chmod +x /usr/local/bin/composer
  512. if [ -e "/usr/local/bin/composer" ]; then
  513. echo; echo "${CSUCCESS}Composer installed successfully! ${CEND}"
  514. else
  515. echo; echo "${CFAILURE}Composer install failed, Please try again! ${CEND}"
  516. fi
  517. else
  518. rm -rf /usr/local/bin/composer
  519. echo; echo "${CMSG}composer uninstall completed${CEND}";
  520. fi
  521. ;;
  522. 10)
  523. ACTION_FUN
  524. if [ "${ACTION}" = '1' ]; then
  525. Install_fail2ban
  526. else
  527. Uninstall_fail2ban
  528. fi
  529. ;;
  530. 11)
  531. ACTION_FUN
  532. if [ "${ACTION}" = '1' ]; then
  533. [ -e "${nginx_install_dir}/sbin/nginx" ] && Nginx_lua_waf
  534. [ -e "${tengine_install_dir}/sbin/nginx" ] && Tengine_lua_waf
  535. enable_lua_waf
  536. else
  537. disable_lua_waf
  538. fi
  539. ;;
  540. q)
  541. exit
  542. ;;
  543. esac
  544. fi
  545. done