Home  >  Article  >  Backend Development  >  How to install ldap extension in php

How to install ldap extension in php

藏色散人
藏色散人Original
2021-10-20 09:50:004501browse

How to install ldap extension in php: 1. Install the ldap extension online through "yum install PHP-ldap"; 2. Place "ldap.so" in the extensions directory.

How to install ldap extension in php

The operating environment of this article: centOS6.8 system, PHP7.0 version, DELL G3 computer

How to install ldap extension for php?

Installing PHP ldap extension under Centos

##There are two methods to install PHP ldap extension under Centos, for reference only.

1. Online installation

Execute the following command:

yum install PHP-ldap
Possible problems:

Error: php70w-common-..   conflicts with php-common-5.4.... 就是版本冲突的意思。
Solution:

View php Version:

php -v
Search for a matching version of ldap:

yum search ldap
Find a matching version to install (mine is php70w-ldap.x86-64)

Reinstall:

yum install php70w-ldap.x86-64
You will be asked to lose a y midway to confirm.

How to install ldap extension in php

Then open the ldap extension in php.ini:

vi /usr/local/php/lib/php.ini

extension=ldap.so
Completed, restart Apache2: service httpd restart.

/usr/local/apache/bin/httpd -k restart

// 或这条命令
service httpd restart
After completion, check the info.php page, there will be the ldap module, showing enabled.

ldap
LDAP Support    enabled
RCS Version    $Id: 109508bbbecf73ca923b37138cbac56802f1231b $
Total Links    0/unlimited
API Version    3001
Vendor Name    OpenLDAP
Vendor Version    20440
SASL Support    Enabled
Directive    Local Value    Master Value
ldap.max_links    Unlimited    Unlimited
2. Compile and install

For LDAP installation, you must install it first

Check whether the following has been installed, if not:
Check:

yum list openldap
yum list openldap-devel

安装 :
# yum install openldap
# yum install openldap-devel
 
一定要执行这条命令:
# cp -frp /usr/lib64/libldap* /usr/lib/ 
进入安装目录下
# cd /root/lnmp1.0-full/php-5.2.17/ext/ldap 
(不知道安装目录的可以用find -name "php-*" 来查找,找到你安装的对应版本的目录)
然后运行
# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

# ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
# make
# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
To generate such an extension, we enter the directory and place ldap.so in the extensions directory:

[root@openldap ldap]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
[root@openldap ldap]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
[root@openldap no-debug-non-zts-20131226]# ls -l
total 748
-rwxr-xr-x 1 root root 173086 Jul 16 16:05 ldap.so
-rwxr-xr-x 1 root root 586024 Jul 16 12:04 opcache.so
[root@openldap no-debug-non-zts-20131226]# cp ldap.so /usr/local/php/lib/php/extensions/ldap.so
[root@openldap no-debug-non-zts-20131226]# cd ..
[root@openldap extensions]# ls -l
total 176
-rwxr-xr-x 1 root root 173086 Jul 16 16:08 ldap.so
drwxr-xr-x 2 root root   4096 Jul 16 16:05 no-debug-non-zts-20131226
[root@openldap extensions]#
Modify

vi /usr/local/php/etc/php.ini (Your php configuration file is not necessarily in this directory, you can view it on the info.php page)Add :

extension=ldap.so
Restart apache

/usr/local/apache/bin/httpd -k restart

// 或这条命令
service httpd restart

How to install ldap extension in php

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of How to install ldap extension in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn