Linux下安装openldap
1、安装Berkeley DB 4.7.25(伯克利大学嵌入式数据库方案, openldap用它作为存储方案)
[root@instance-0pk09gjj ldap]# wget http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz
[root@instance-0pk09gjj ldap]# tar xvf db-4.7.25.tar.gz
[root@instance-0pk09gjj ldap]# cd db-4.7.25/build_unix/
[root@instance-0pk09gjj build_unix]# ../dist/configure --prefix=/home/ldap/BerkeleyBD
[root@instance-0pk09gjj build_unix]# make
[root@instance-0pk09gjj build_unix]# make install
安装完成后 需要在 usr/lib 下面加上安装后中的lib中所有的文件
[root@instance-0pk09gjj include]# cp /home/ldap/BerkeleyBD/include/* /usr/include/
[root@instance-0pk09gjj include]# cp /home/ldap/BerkeleyBD/lib/* /usr/lib/
2、配置berkeleyDB 环境变量
添加下面代码
[root@instance-0pk09gjj openldap]# vi ~/.bash_profile
CPPFLAGS="-I/home/ldap/BerkeleyBD/include"
export CPPFLAGS
LDFLAGS="-L/usr/local/lib -L/home/ldap/BerkeleyBD/lib -R/home/ldap/BerkeleyBD/lib"
export LDFLAGS
LD_LIBRARY_PATH="/home/ldap/BerkeleyBD/lib"
export LD_LIBRARY_PATH
3、安装openLDAP
[root@instance-0pk09gjj ldap]#wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.40.tgz
[root@instance-0pk09gjj ldap]# tar -xzvf openldap-2.4.40.tgz
make: *** No targets specified and no makefile found. Stop.
https://blog.csdn.net/wangjiao1022/article/details/79424887
解决方案:
# tar –zxvf mysql-5.0.95
# ./configure --prefix=/usr/local/mysql --with-charset=gbk
# make
# make install
但在make的时候 出现
make: *** No targets specified and no makefile found. stop.
仔细查看 ./configure时,报了下边几个错
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found(重点错误)
看错误提示 可知是找不到curses,, 所以是缺少ncurses安装包 造成的
解决方法如下:
我的系统是RedHat5系列:
yum list|grep ncurses
yum -y install ncurses-devel
yum install ncurses-devel
完成后,重新 ./configure --prefix=/usr/local/mysql --with-charset=gbk,make && make install
[root@instance-0pk09gjj openldap-2.4.40]# cd /usr/local/ldap/openldap-2.4.40/
[root@instance-0pk09gjj openldap-2.4.40]# ./configure --prefix=/home/ldap/openldap
[root@instance-0pk09gjj openldap-2.4.40]# make depend
//其中make test一步时间较长, 但是这个步骤不可省略
[root@instance-0pk09gjj openldap-2.4.40]# make test
[root@instance-0pk09gjj openldap-2.4.40]# make
[root@instance-0pk09gjj openldap-2.4.40]# make install
4、修改配置文件, 配置一个数据库
database bdb
suffix "dc=my-domain,dc=com"
rootdn "cn=Manager,dc=my-domain,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoid. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw admin
生成加密后的密码(加密方式: CRYPT、MD5、SMD5、SHA和SSHA )
[root@instance-0pk09gjj sbin]# ./slappasswd -h{SSHA}
New password:
Re-enter new password:
{SSHA}OBCWlP7IQlGyE22uWkpd4J4sFhvC09fH
5、初始化OpenLDAP(Optional)
[root@instance-0pk09gjj /]# cd /home/ldap/openldap/var/openldap-data/
[root@instance-0pk09gjj openldap-data]# cp DB_CONFIG.example DB_CONFIG
6、启动LDAP
[root@instance-0pk09gjj libexec]#/home/ldap/openldap/libexec/slapd -d256
7、创建一个ldif文件
[root@instance-0pk09gjj openldap]# vi example.ldif
dn:dc=my-domain,dc=com
objectclass:dcObject
objectclass:organization
dc:my-domain
o:my-domain,Inc.
dn:ou=TDC,dc=my-domain,dc=com
objectclass:organizationalUnit
ou:TDC
8、添加ldif文件
[root@instance-0pk09gjj bin]# ldapadd -x -D 'cn=Manager,dc=my-domain,dc=com' -W -f /home/ldap/openldap/example.ldif
9、测试, 用开源软件LDAP admin
10、连接成功