查询验证本地PHP的LDAP模块安装与否
[root@localhost ~]# /usr/local/php/sbin/php-fpm -m |grep ldap [root@localhost ~]#
1、安装软件包解决依赖:yum -y install openldap-devel
[root@localhost ~]# yum -y install openldap-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package openldap-devel.x86_64 0:2.4.44-15.el7_5 will be installed --> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.44-15.el7_5.x86_64 --> Running transaction check ---> Package cyrus-sasl-devel.x86_64 0:2.1.26-23.el7 will be installed --> Processing Dependency: cyrus-sasl(x86-64) = 2.1.26-23.el7 for package: cyrus-sasl-devel-2.1.26-23.el7.x86_64 --> Running transaction check ---> Package cyrus-sasl.x86_64 0:2.1.26-23.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================================================================== Installing: openldap-devel x86_64 2.4.44-15.el7_5 updates 803 k Installing for dependencies: cyrus-sasl x86_64 2.1.26-23.el7 base 88 k cyrus-sasl-devel x86_64 2.1.26-23.el7 base 310 k Transaction Summary ===================================================================================================================================================================================== Install 1 Package (+2 Dependent packages) Total download size: 1.2 M Installed size: 4.8 M Downloading packages: (1/3): cyrus-sasl-2.1.26-23.el7.x86_64.rpm | 88 kB 00:00:00 (2/3): cyrus-sasl-devel-2.1.26-23.el7.x86_64.rpm | 310 kB 00:00:00 (3/3): openldap-devel-2.4.44-15.el7_5.x86_64.rpm | 803 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 2.6 MB/s | 1.2 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : cyrus-sasl-2.1.26-23.el7.x86_64 1/3 Installing : cyrus-sasl-devel-2.1.26-23.el7.x86_64 2/3 Installing : openldap-devel-2.4.44-15.el7_5.x86_64 3/3 Verifying : cyrus-sasl-devel-2.1.26-23.el7.x86_64 1/3 Verifying : openldap-devel-2.4.44-15.el7_5.x86_64 2/3 Verifying : cyrus-sasl-2.1.26-23.el7.x86_64 3/3 Installed: openldap-devel.x86_64 0:2.4.44-15.el7_5 Dependency Installed: cyrus-sasl.x86_64 0:2.1.26-23.el7 cyrus-sasl-devel.x86_64 0:2.1.26-23.el7 Complete!
2、拷贝库文件:cp -frp /usr/lib64/libldap* /usr/lib/
[root@localhost ~]# cp -frp /usr/lib64/libldap* /usr/lib/
3、编译安装php-ldap模块:
a)根据实际情况进入源码包(跟本地安装版本一致)内的ldap目录位置 cd /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/
[root@localhost php-7.0.30]# cd /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/
b)根据PHP安装路径执行命令 /usr/local/php/bin/phpize
[root@localhost ldap]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 [root@localhost ldap]#
c)预编译 ./configure –with-php-config=/usr/local/php/bin/php-config #根据PHP安装路径指定配置文件
[root@localhost ldap]# ./configure --with-php-config=/usr/local/php/bin/php-config checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E ......此处省略...... checking whether to build shared libraries... yes checking whether to build static libraries... no creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h [root@localhost ldap]#
d)编译及安装:make && make install
[root@localhost ldap]# make && make install /bin/sh /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/libtool --mode=compile cc -DLDAP_DEPRECATED=1 -I. -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap -DPHP_ATOM_INC -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/include -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/main -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/ldap.c -o ldap.lo mkdir .libs cc -DLDAP_DEPRECATED=1 -I. -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap -DPHP_ATOM_INC -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/include -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/main -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/ldap.c -fPIC -DPIC -o .libs/ldap.o /bin/sh /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/include -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/main -I/usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o ldap.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/modules ldap.lo -lldap cc -shared .libs/ldap.o -lldap -Wl,-soname -Wl,ldap.so -o .libs/ldap.so creating ldap.la (cd .libs && rm -f ldap.la && ln -s ../ldap.la ldap.la) /bin/sh /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/libtool --mode=install cp ./ldap.la /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/modules cp ./.libs/ldap.so /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/modules/ldap.so cp ./.libs/ldap.lai /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/modules/ldap.la PATH="$PATH:/sbin" ldconfig -n /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/modules ---------------------------------------------------------------------- Libraries have been installed in: /usr/src/lnmp1.5-full/src/php-7.0.30/ext/ldap/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'. Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/ [root@localhost ldap]#
4、编译PHP配置文件(/usr/local/php/etc/php.ini)找到(;extension=php_ldap.dll)添加一行(extension=ldap.so)并保存退出。
;extension=php_ldap.dll extension=ldap.so
5、重启PHP-FPM
[root@localhost ldap]# systemctl restart php-fpm.service
再次查询验证本地PHP的LDAP模块安装与否
[root@localhost ldap]# /usr/local/php/sbin/php-fpm -m |grep ldap ldap [root@localhost ldap]#