1
0

pecl_ldap.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 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. ./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib64
  27. make -j ${THREAD} && make install
  28. popd > /dev/null
  29. if [ -f "${phpExtensionDir}/ldap.so" ]; then
  30. echo 'extension=ldap.so' > ${php_install_dir}/etc/php.d/04-ldap.ini
  31. echo "${CSUCCESS}PHP ldap module installed successfully! ${CEND}"
  32. rm -rf php-${PHP_detail_ver}
  33. else
  34. 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
  35. fi
  36. popd > /dev/null
  37. fi
  38. }
  39. Uninstall_pecl_ldap() {
  40. if [ -e "${php_install_dir}/etc/php.d/04-ldap.ini" ]; then
  41. rm -f ${php_install_dir}/etc/php.d/04-ldap.ini
  42. echo; echo "${CMSG}PHP ldap module uninstall completed${CEND}"
  43. else
  44. echo; echo "${CWARNING}PHP ldap module does not exist! ${CEND}"
  45. fi
  46. }