在PHP编译安装目录执行(如果目录删除可在重新下载)

进入ldap扩展目录

cd /usr/local/webSoft/php-7.1.9/ext/ldap

进行安装

# 检查环境
/usr/local/php/v7.1.9/bin/phpize

如果提示 Cannot find autoconf. Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.

上述错误 安装 m4、autoconf

#### m4 安装
wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
tar -xvf m4-1.4.9.tar.gz
cd m4-1.4.9
./configure
make && make install (如果提示没有权限分开执行加sudo)
#### autoconf 安装
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
tar -xvf autoconf-2.62.tar.gz
cd autoconf-2.62
./configure
make && make install

进入 ldap 扩展目录后重新执行

./configure --with-php-config=/usr/local/php/v7.1.9/bin/php-config --with-ldap

如果提示 configure: error: Cannot find ldap.h

#### 执行:
sudo apt-get install libldap2-dev
#### 重新执行
./configure --with-php-config=/usr/local/php/v7.1.9/bin/php-config --with-ldap

没问题后进行安装

make && make install

php.ini 中添加扩展

extension = /usr/local/php/v7.1.9/lib/php/extensions/no-debug-non-zts-20160303/ldap.so

重启 php-fpm