1
0

pecl_swoole.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  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-1.10.5.tgz && Download_src
  18. tar xzf swoole-1.10.5.tgz
  19. pushd swoole-1.10.5 > /dev/null
  20. ${php_install_dir}/bin/phpize
  21. ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
  22. elif [[ "${PHP_main_ver}" =~ ^7.[0-1]$ ]]; then
  23. src_url=https://pecl.php.net/get/swoole-${swoole_oldver}.tgz && Download_src
  24. tar xzf swoole-${swoole_oldver}.tgz
  25. pushd swoole-${swoole_oldver} > /dev/null
  26. ${php_install_dir}/bin/phpize
  27. ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
  28. else
  29. src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
  30. tar xzf swoole-${swoole_ver}.tgz
  31. pushd swoole-${swoole_ver} > /dev/null
  32. ${php_install_dir}/bin/phpize
  33. ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} --enable-http2 --enable-swoole-json --enable-swoole-curl
  34. fi
  35. make -j ${THREAD} && make install
  36. popd > /dev/null
  37. if [ -f "${phpExtensionDir}/swoole.so" ]; then
  38. echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
  39. echo "${CSUCCESS}PHP swoole module installed successfully! ${CEND}"
  40. rm -rf swoole-${swoole_ver} swoole-${swoole_oldver}
  41. else
  42. echo "${CFAILURE}PHP swoole module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  43. fi
  44. popd > /dev/null
  45. fi
  46. }
  47. Uninstall_pecl_swoole() {
  48. if [ -e "${php_install_dir}/etc/php.d/06-swoole.ini" ]; then
  49. rm -f ${php_install_dir}/etc/php.d/06-swoole.ini
  50. echo; echo "${CMSG}PHP swoole module uninstall completed${CEND}"
  51. else
  52. echo; echo "${CWARNING}PHP swoole module does not exist! ${CEND}"
  53. fi
  54. }