pecl_swoole.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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-4.5.2.tgz && Download_src
  24. tar xzf swoole-4.5.2.tgz
  25. pushd swoole-4.5.2 > /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. elif [[ "${PHP_main_ver}" =~ ^7.[2-4]$ ]]; then
  29. src_url=https://pecl.php.net/get/swoole-${swoole_oldver}.tgz && Download_src
  30. tar xzf swoole-${swoole_oldver}.tgz
  31. pushd swoole-${swoole_oldver} > /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. else
  35. src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
  36. tar xzf swoole-${swoole_ver}.tgz
  37. pushd swoole-${swoole_ver} > /dev/null
  38. ${php_install_dir}/bin/phpize
  39. ./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
  40. fi
  41. make -j ${THREAD} && make install
  42. popd > /dev/null
  43. if [ -f "${phpExtensionDir}/swoole.so" ]; then
  44. echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
  45. echo "${CSUCCESS}PHP swoole module installed successfully! ${CEND}"
  46. rm -rf swoole-${swoole_ver} swoole-${swoole_oldver} swoole-1.10.5 swoole-4.5.2
  47. else
  48. 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
  49. fi
  50. popd > /dev/null
  51. fi
  52. }
  53. Uninstall_pecl_swoole() {
  54. if [ -e "${php_install_dir}/etc/php.d/06-swoole.ini" ]; then
  55. rm -f ${php_install_dir}/etc/php.d/06-swoole.ini
  56. echo; echo "${CMSG}PHP swoole module uninstall completed${CEND}"
  57. else
  58. echo; echo "${CWARNING}PHP swoole module does not exist! ${CEND}"
  59. fi
  60. }