1
0

pecl_swoole.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 8+ and Ubuntu 14+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_pecl_swoole() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
  14. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  15. PHP_main_ver=${PHP_detail_ver%.*}
  16. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
  17. src_url=https://pecl.php.net/get/swoole-${swoole_oldver}.tgz && Download_src
  18. tar xzf swoole-${swoole_oldver}.tgz
  19. pushd swoole-${swoole_oldver} > /dev/null
  20. else
  21. src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
  22. tar xzf swoole-${swoole_ver}.tgz
  23. pushd swoole-${swoole_ver} > /dev/null
  24. fi
  25. ${php_install_dir}/bin/phpize
  26. ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
  27. make -j ${THREAD} && make install
  28. popd > /dev/null
  29. if [ -f "${phpExtensionDir}/swoole.so" ]; then
  30. echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
  31. echo "${CSUCCESS}PHP swoole module installed successfully! ${CEND}"
  32. rm -rf swoole-${swoole_ver} swoole-${swoole_oldver}
  33. else
  34. echo "${CFAILURE}PHP swoole module install failed, Please contact the author! ${CEND}" && lsb_release -a
  35. fi
  36. popd > /dev/null
  37. fi
  38. }
  39. Uninstall_pecl_swoole() {
  40. if [ -e "${php_install_dir}/etc/php.d/06-swoole.ini" ]; then
  41. rm -f ${php_install_dir}/etc/php.d/06-swoole.ini
  42. echo; echo "${CMSG}PHP swoole module uninstall completed${CEND}"
  43. else
  44. echo; echo "${CWARNING}PHP swoole module does not exist! ${CEND}"
  45. fi
  46. }