一、下载 openldap-2.4.11.tar.gz和db-4.7.25.tar.gz
二、安装db-4.7.25.tar(先删除系统自带的db包rpm -qa|grep db)
1.tar -zxvf db-4.7.25.tar.gz
2.cd db-4.7.25/dist
3. ./configure
4.make
5.make install
6.vi /etc/ld.so.conf 加入下面一行
/usr/local/BerkeleyDB.4.7/lib
保存
7.ldconfig
三、安装openldap-2.4.11.tar.gz
1.tar -zxvf openldap-2.4.11.tar.gz
2.cd openldap-2.4.11
3.
env CPPFLAGS="-I/usr/local/BerkeleyDB.4.7/include"
LDFLAGS="-L/usr/local/BerkeleyDB.4.7/lib"
./configure --prefix=/usr/local/openldap
--enable-bdb
如果报错:
checking Berkeley DB version for BDB/HDB backends... no
configure: error: BDB/HDB: BerkeleyDB version incompatible
解决方法:
把/usr/local/BerkeleyDB.4.7/include中的所有文件拷贝到/usr/include
/usr/local/BerkeleyDB.4.7/lib中的所有文件拷贝到/usr/lib
4.make depend
5.make
如果提示错误:
make[3]: *** [init.lo] Error 1
make[3]: Leaving directory `/work/ceno/lab/openldap-2.4.11/servers/slapd/back-bdb'
make[2]: *** [.backend] Error 1
make[2]: Leaving directory `/work/ceno/lab/openldap-2.4.11/servers/slapd'
make[1]: *** [all-common] Error 1
make[1]: Leaving directory `/work/ceno/lab/openldap-2.4.11/servers'
make: *** [all-common] Error 1
解决方法:
cd openldap-2.4.11/servers/slapd/back-bdb/
将init.c 和 cache.c中
#if DB_VERSION_FULL >= 0x04060012
改为
#if 0 && DB_VERSION_FULL >= 0x04060012
之后再make 就能通过了。
6.make test
7.make install
四、配置文件
1.vi etc/openldap/slapd.conf
include /usr/local/openldap/etc/openldap/schema/core.schema #设置schema配置文档包含
pidfile /usr/local/openldap/var/slapd.pid
argsfile /usr/local/openldap/var/slapd.args #设置pid和args文档位置
database bdb #设置使用的资料库,也可用lbdm。
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 secret #设置管理密码,这里用了明文的“secret”密码。这样设置不安全,需使用加密的密码,下面会讲到如何设置加密密码。
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /usr/local/openldap/var/openldap-data #设置资料库路径
# Indices to maintain
index objectClass eq #设置目录项索引
2. ./slapd启动服务
3.vi etc/openldap/ldap.conf
# $OpenLDAP: pkg/ldap/libraries/libldap/ldap.conf,v 1.9 2000/09/04 19:57:01 kurt Exp $
#
# LDAP Defaults
#
# See ldap.conf(5) for details
# This file should be world readable but not world writable.
BASE dc=it, dc=com设置目录起点
#URI ldap://ldap.example.com ldap://ldap-master.example.com:666
#SIZELIMIT 12
#TIMELIMIT 15
#DEREF never