pecl_swoole.sh 2.0 KB

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