Ubuntu下OpenLDAP服务器的部署步骤
1:安装zlib
下载zlib-1.2.3.tar.gz(或其他版本)
wget http://down1.chinaunix.net/distfiles/zlib-1.2.3.tar.gz
# ./configure --shared
# make
# make install
2:安装openssl
不要卸载系统自带的Openssl,否则很多服务都起不来
wget http://101.44.1.124/files/613900000275279B/mirrors.163.com/gentoo/distfiles/openssl-1.0.1j.tar.gz
# ./config shared #注意这里是用./config 会安装到/usr/local/ssl
# make
# make install
出现报错:
“POD document had syntax errors at /usr/bin/pod2man line 71. make: *** [install_docs] 错误 25”
编辑/usr/bin/pod2man文件,注释掉第71行。
#配置库文件搜索路径
# echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
# ldconfig -v
3:安装BerkeleyDB
下载db-5.3.28.tar.gz
解压到文件夹db-5.3.28
进入到文件夹db-5.3.28/build_unix
# ../dist/configure --sysconfdir=/etc #默认路径/usr/local/BerkeleyDB.5.3
# make
# make install
#配置库文件搜索路径
# echo "/usr/local/BerkeleyDB.5.3/lib" >> /etc/ld.so.conf
# ldconfig -v
4:安装openldap
下载openldap-2.4.30.tgz
解压到openldap-2.4.30
进入文件夹openldap-2.4.30
# env CPPFLAGS="-I/user/include -I/usr/local/BerkeleyDB.5.3/include -I/usr/local/ssl/include-D_GNU_SOURCE" LDFLAGS="-L/usr/lib -L/usr/local/BerkeleyDB.5.3/lib -L/usr/local/ssl/lib" ./configure --prefix=/usr/local/openldap --with-tls=openssl -enable-dynamic (注意引入的三组临时变量需要对应BerkeleyDB和openSSL的库文件文件夹目录)
# make depend
# make
# make test #这一步时间会很长
# make install
#配置库文件搜索路径
# echo "/usr/local/openldap/lib" >> /etc/ld.so.conf
# ldconfig -v
启动LDAP:
/usr/local/openldap/libexec/slapd
写一个test.ldif数据文件
dn: dc=Tree,dc=com objectClass: dcObject objectClass: organization dc: Tree o: Tree Company
dn: cn=Manager,dc=Tree,dc=com objectClass: organizationalRole objectClass: top cn: Manager
执行:
/usr/local/openldap/bin/ldapadd -x -D "cn=Manager,dc=Tree,dc=com" -w 123456 -f test.ldif
导入成功则部署完毕。