这个问题搞了很久。
下面是安装教程。
1.安装 依赖包:
yum install openldap openldap-devel -y
yum install gcc
yum install make
安装完成之后执行下面这句话
cp -frp /usr/lib64/libldap* /usr/lib/ #这步很重要
2.进入php 源码包(php一定要编译的)
1.进入源码路径:/www/server/php/71/src/ext/ldap
3.执行phpize (一般都会在/usr/bin/ 是个软连接来的)
[root@localhost ldap]# /usr/bin/phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
[root@localhost ldap]# ./configure --with-php-config=/www/server/php/71/bin/php-config #等号后面的是php安装位置路径
。。。。。。。。。。。
creating libtool appending configuration tag "CXX" to libtool
configure: creating ./config.status config.status:
creating config.h (开到这里没有报错就开始编译)
[root@localhost ldap]# make && make install #(开始编译)
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 Libraries have been installed in: /www/server/php/71/src/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.
4.找到php.ini 配置文件
最后在php.ini中添加扩展文件
[root@mha-master ldap]# vim /usr/local/php/etc/php.ini
extension=ldap.so
重启php 使用 php -m查看模块
[root@mha-master ldap]# php -m