pecl_xdebug.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_pecl-xdebug() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
  14. PHP_main_ver=${PHP_detail_ver%.*}
  15. if [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-2]$ ]]; then
  16. if [[ "${PHP_main_ver}" =~ ^7.[0-2]$ ]]; then
  17. src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
  18. tar xzf xdebug-${xdebug_ver}.tgz
  19. pushd xdebug-${xdebug_ver} > /dev/null
  20. elif [[ "${PHP_main_ver}" =~ ^5.[5-6]$ ]]; then
  21. src_url=https://pecl.php.net/get/xdebug-${xdebug_oldver}.tgz && Download_src
  22. tar xzf xdebug-${xdebug_oldver}.tgz
  23. pushd xdebug-${xdebug_oldver} > /dev/null
  24. fi
  25. ${php_install_dir}/bin/phpize
  26. ./configure --with-php-config=${php_install_dir}/bin/php-config
  27. make -j ${THREAD} && make install
  28. popd > /dev/null
  29. if [ -f "${phpExtensionDir}/xdebug.so" ]; then
  30. src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
  31. unzip -q webgrind-master.zip
  32. /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
  33. [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; }
  34. [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; }
  35. chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/webgrind
  36. sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php
  37. sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php
  38. cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF
  39. [xdebug]
  40. zend_extension=xdebug.so
  41. xdebug.trace_output_dir=/tmp/xdebug
  42. xdebug.profiler_output_dir = /tmp/xdebug
  43. xdebug.profiler_enable = On
  44. xdebug.profiler_enable_trigger = 1
  45. EOF
  46. echo "${CSUCCESS}PHP xdebug module installed successfully! ${CEND}"
  47. echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}"
  48. rm -rf xdebug-${xdebug_ver} xdebug-${xdebug_oldver}
  49. else
  50. echo "${CFAILURE}PHP xdebug module install failed, Please contact the author! ${CEND}"
  51. fi
  52. else
  53. echo "${CWARNING}Your php ${PHP_detail_ver} does not support xdebug! ${CEND}";
  54. fi
  55. popd > /dev/null
  56. fi
  57. }
  58. Uninstall_pecl-xdebug() {
  59. if [ -e "${php_install_dir}/etc/php.d/08-xdebug.ini" ]; then
  60. rm -rf ${php_install_dir}/etc/php.d/08-xdebug.ini /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind
  61. echo; echo "${CMSG}PHP xdebug module uninstall completed${CEND}"
  62. else
  63. echo; echo "${CWARNING}PHP xdebug module does not exist! ${CEND}"
  64. fi
  65. }