php 致命错误:在 ubuntu 中调用未定义的函数 ldap_connect()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5725815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fatal error: Call to undefined function ldap_connect() in ubuntu
提问by Roshan Wijesena
I'm trying to connect to my LDAP server via PHP, but I get the following error:
我正在尝试通过 PHP 连接到我的 LDAP 服务器,但出现以下错误:
Fatal error: Call to undefined function ldap_connect()
致命错误:调用未定义的函数 ldap_connect()
Any help would be very appreciated.
任何帮助将不胜感激。
Thanks in advance, roshan
提前致谢, roshan
回答by Pascal MARTIN
Make sure the LDAP extensionis installed and enabled. This answer assumes you have PHP5, however, things should work similarly for PHP7 as well.
确保已安装并启用LDAP 扩展。这个答案假设您有 PHP5,但是,对于 PHP7,事情也应该类似。
Install LDAP Extension
安装 LDAP 扩展
There should be a package named like php5-ldap:
应该有一个名为php5-ldap的包:
aptitude show php5-ldap
Paquet?: php5-ldap
...
Description?: LDAP module for php5
This package provides a module for LDAP functions in PHP scripts.
Thus, the package can usually be installed like:
因此,通常可以像这样安装软件包:
sudo apt-get install php5-ldap
If you do not use apt-get
, use the equivalent command for the package manager you use.
如果您不使用apt-get
,请使用您使用的包管理器的等效命令。
Enable LDAP Extension
启用 LDAP 扩展
To enable the package after installation, you can use this command:
要在安装后启用软件包,您可以使用以下命令:
sudo php5enmod ldap
If you get any error message from the above command, it means something went wrong.
如果您从上述命令中收到任何错误消息,则表示出现问题。
Note:After enabling the package, you usually have to restart / reload services so that the newly enabled module is recognized. For apache, you can do this by:
注意:启用软件包后,您通常必须重新启动/重新加载服务,以便识别新启用的模块。对于 apache,您可以通过以下方式执行此操作:
sudo service apache2 restart
If you do not use apache, please use the equivalent command for your server.
如果您不使用 apache,请为您的服务器使用等效的命令。
回答by zerkms
sudo apt-get install php5-ldap
And don't afraid to google.
不要害怕谷歌。