Home > Backend Development > PHP Tutorial > Install PHP ldap extension under Centos

Install PHP ldap extension under Centos

藏色散人
Release: 2023-04-07 18:26:02
forward
4759 people have browsed it

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
Copy after login

Possible problems:

Error: php70w-common- .. conflicts with php-common-5.4.... means version conflict.

Solution:

Check the php version:

php -v
Copy after login

Search for ldap with matching version:

yum search ldap
Copy after login

Find the matching version to install (mine is php70w -ldap.x86-64)

Reinstall:

yum install php70w-ldap.x86-64
Copy after login

You will be asked to enter a y midway to confirm.

Install PHP ldap extension under Centos

Then open the ldap extension in php.ini:

vi /usr/local/php/lib/php.ini
extension=ldap.so
Copy after login

Completed, restart Apache2: service httpd restart.

/usr/local/apache/bin/httpd -k restart
// 或这条命令
service httpd restart
Copy after login
Copy after login

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
Copy after login

2. Compile and install

For LDAP The installation must be installed first

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

Check:

yum list openldap
yum list openldap-devel
Copy after login

Install:

# yum install openldap
# yum install openldap-devel
Copy after login

Be sure to execute this command:

# cp -frp /usr/lib64/libldap* /usr/lib/
Copy after login

Enter the installation directory

# cd /root/lnmp1.0-full/php-5.2.17/ext/ldap
Copy after login

(If you don’t know the installation directory, you can use find -name "php-*" to find it and find your installation directory of the corresponding version)

Then run

# /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/
Copy after login

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]#
Copy after login

Modify vi /usr/local/php/etc/php.ini (your php configuration file, not necessarily this directory, can be viewed on the info.php page)

Add:

extension=ldap.so
Copy after login

Restart apache

/usr/local/apache/bin/httpd -k restart
// 或这条命令
service httpd restart
Copy after login
Copy after login

Install PHP ldap extension under Centos

The above is the detailed content of Install PHP ldap extension under Centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:segmentfault.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template