pecl_ldap.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 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_pecl_ldap() {
  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. src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  16. tar xzf php-${PHP_detail_ver}.tar.gz
  17. pushd php-${PHP_detail_ver}/ext/ldap > /dev/null
  18. if [ "${PM}" == 'yum' ]; then
  19. yum -y install openldap-devel
  20. else
  21. apt-get -y install libldap2-dev
  22. ln -s /usr/lib/${ARCH}-linux-gnu/libldap.so /usr/lib/
  23. ln -s /usr/lib/${ARCH}-linux-gnu/liblber.so /usr/lib/
  24. fi
  25. ${php_install_dir}/bin/phpize
  26. if [ "${PM}" == 'yum' ]; then
  27. ./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib64
  28. else
  29. ./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib/x86_64-linux-gnu
  30. fi
  31. make -j ${THREAD} && make install
  32. popd > /dev/null
  33. if [ -f "${phpExtensionDir}/ldap.so" ]; then
  34. echo 'extension=ldap.so' > ${php_install_dir}/etc/php.d/04-ldap.ini
  35. echo "${CSUCCESS}PHP ldap module installed successfully! ${CEND}"
  36. rm -rf php-${PHP_detail_ver}
  37. else
  38. echo "${CFAILURE}PHP ldap module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  39. fi
  40. popd > /dev/null
  41. fi
  42. }
  43. Uninstall_pecl_ldap() {
  44. if [ -e "${php_install_dir}/etc/php.d/04-ldap.ini" ]; then
  45. rm -f ${php_install_dir}/etc/php.d/04-ldap.ini
  46. echo; echo "${CMSG}PHP ldap module uninstall completed${CEND}"
  47. else
  48. echo; echo "${CWARNING}PHP ldap module does not exist! ${CEND}"
  49. fi
  50. }