注册
 找回密码
 注册
江西广告网
查看: 276|回复: 0
打印 上一主题 下一主题

手把手教你:安装Opldap历险记

[复制链接]

该用户从未签到

1
跳转到指定楼层
发表于 2008-12-28 12:10:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
  安装环境:   RedHat Linux9.0 内核版本2.40.2-8      一、准备工作:   按照http://www.openldap.org/faq/data/cache/196.html所列的软件准备:      1.安装的先决条件为:C开发环境,支持Posix标准的正规表达式,支持Berkeley标准的网络协议。      OpenLDAP 2.x is designed to "configure" and "build" on UNIX (and UNIX-like) systems.      The prerequisites depending upon the which features you desire.      General prerequisites include:       C Development Environment       POSIX REGEX routines       Berkeley Networking (socket/select) routines      2.安装SLAPD即为openldap的守护程序所需的软件:Berkeley数据库和GBDM数据库可以两者选择其一。我选择了前者。      Berkeley数据库4.2和相关的patches文件:源代码和补丁文件可从http://www.sleepycat.com/下载。打补丁要使用patch命令运行,主要功能为在编译前更新源代码中的bug。关于patch的详细用法请参考www-900.ibm.com/developerWorks/ cn/linux/l-diffp/index.shtml。      SLAPD (with BDB database) prerequisites includes:       Berkeley Database 4.2 from Sleepycat (http://www.sleepycat.com/)      Latest version with patches is recommended.      SLAPD (with LDBM database) prerequisites include suitable database support. One of following packages can fulfill the prerequisite.       Berkeley Database from Sleepycat (http://www.sleepycat.com/)       GNU Database Manager (GDBM) from FSF (http://www.gnu.org/)      For OpenLDAP 2.1 (or later), Berkeley DB 4.1 is recommended.      SLURPD prerequisites include:       Thread support (Posix Threads and others)      3.选装软件:SSL/TLS和SASL。SSL/TLS提供信息加密功能,可以从http://www.openssl.org下载,但是在安装前需要打补丁详情见http://www.openldap.org/faq/index.cgi?file=185。Cyrus-SASL主要提供给一些安全认证的功能,可以从http://asg.web.cmu.edu/sasl/下载源代码。由于这两个都是选装软件,所以按照计算机的负载方面来选择了后者。      SSL/TLS prerequisites(选装):       OpenSSL 0.9.6 from http://www.openssl.org      The OpenSSL library usually needs to be patched before it will work correctly. See this FAQ article for details: http://www.openldap.org/faq/index.cgi?file=185 (Note about OpenSSL and crypt())      SASL prerequisites(选装):       Cyrus-SASL from http://asg.web.cmu.edu/sasl/      二、开始安装:   1.安装Berkeley数据库(Berkeley Database 4.2.52):      tar -zxvf db-4.2.52.NC.tar.gz或者gzip –d db-4.2.52.NC.tar.gz再tar –xf db-4.2.52.NC.tar。   解完压后,会生成一个db-4.2.52.NC目录,进行该目录下的build_unix目录,我们将在这个目录中配置和安装Berkeley4.2.52。执行以下命令进行配置安装。   # ../dist/configure   # make   # make install   也是按linux源码安装的三步曲完成,没有什么好说的了。该软件默认是安装在/usr/local/BerkeleyDB.4.2目录下。安装完成后,要把/usr/local/BerkeleyDB.4.2/lib的库路径加到/etc/ld.so.conf文件内,这个文件就是系统动态链接库的配置文件。此文件内,存放着可被LINUX共享的动态链接库所在目录的名字(系统目录 /lib,/usr/lib除外),各个目录名间以空白字符(空格,换行等)或冒号或逗号分隔。一般的LINUX发行版中,此文件均含一个共享目录 /usr/X11R6/lib,为X window窗口系统的动态链接库所在的目录。添加完成后执行一次 ldconfig –v,使用配置文件生效。这样编译openldap时才能找到相应的库文件。      2.安装Cyrus-SASL(cyrus-sasl-2.1.20):      tar –zxvf cyrus-sasl-2.1.20.tar.gz或者gzip –d cyrus-sasl-2.1.20.tar.gz再tar –xf cyrus-sasl-2.1.20.tar。      解完压缩,会生成cyrus-sasl-2.1.20目录,进入该目录,按照linux源码安装的三步曲完成配置和安装:      # ./configure      # make      # make install      由于Cyrus-sasl需要一些库支持,如果在编译时遇到问题,请访问http://asg.web.cmu.edu/sasl/。我比较幸运:-)。安装完成后,要把/usr/local/lib/sasl2和/usr/local/lib的库路径加到/etc/ld.so.conf文件内,添加完成后执行一次 ldconfig –v,使用配置文件生效。这样编译openldap时才能找到相应的库文件。      运行结果:      ldconfig -v      ...      /usr/local/lib:          libldap_r-2.2.so.7 -> libldap_r-2.2.so.7.0.13          libldap-2.2.so.7 -> libldap-2.2.so.7.0.13          liblber-2.2.so.7 -> liblber-2.2.so.7.0.13          libsasl2.so.2 -> libsasl2.so.2.0.20      /usr/local/lib/sasl2:          libanonymous.so.2 -> libanonymous.so.2.0.20          libplain.so.2 -> libplain.so.2.0.20          libotp.so.2 -> libotp.so.2.0.20          libdigestmd5.so.2 -> libdigestmd5.so.2.0.20          libcrammd5.so.2 -> libcrammd5.so.2.0.20          libsasldb.so.2 -> libsasldb.so.2.0.20      ...      可以看见sasl的一些软链接信息。Linux中的命令ldd也可以查看执行文件或者库文件的库链接信息,详细用法可以用ldd --help查到。      3.安装openldap(openldap-stable2.2.20(20050103)):      同上Cyrus-SASL的安装一样,解压缩后进入生成的openldap-2.2.20目录,按照linux源代码安装的三部曲 测试(make test):      # ./configure      A.首尝失败:问题来了,刚刚运行./configure就出现了下面的错误1:      checking Berkeley DB version for BDB backend... no      configure: error: BDB: BerkeleyDB version incompatible      这个错误说明Berkeley数据库的版本与openldap需要的不兼容??奇怪,我安装的4.2.52可是openldap官方文档明确说明支持的!仔细一查才发现原来我的RH9上已经默认安装了Berkeley(版本较低)。      于是我在执行configure之前,首先设置了环境变量:      export CPPFLAGS="-I/usr/local/BerkeleyDB.4.2/include"      export LDFLAGS="-L/usr/local/BerkeleyDB.4.2/lib"      configure所用的环境变量列表:      CC=...   C编译器的名称   CPPFLAGS=...   各种C预处理和编译器参数   CFLAGS=...   C编译器的调试和优化参数   LDFLAGS=...   各种连接器参数   LIBS=...   连接器的库位置信息("-L" and "-l"参数)   INCLUDES=...   头文件的搜索目录("-Idir").   TARGET=... [Default: apache]   目标执行文件名   NOTEST_CPPFLAGS=...   NOTEST_CFLAGS=...   NOTEST_LDFLAGS=...   NOTEST_LIBS=...      这两个环境变量指定了预处理编译参数、连接器参数,它们将在执行configure时被configure所读取,并且在以后的make时使用。果然执行configure该处没有问题了。      B.再次受打击:刚刚解决一个问题,还没喘过气,configure又出问题了,错误2:      checking Cyrus SASL library version... no      configure: error: Cyrus SASL library located but is incompatible      与Berkeley数据库一样,Cycrus SASL的版本也不兼容??原来还是一样的原因:系统中装有个版本低的Cycrus SASL。。。L。。。麻烦!只好在丰富一下环境变量了:      export CPPFLAGS="-I/usr/local/BerkeleyDB.4.2/include"      export LDFLAGS="-L/usr/local/lib/ -L/usr/local/BerkeleyDB.4.2/lib -L/usr/local/lib/sasl2"      将刚刚安装的Cycrus sasl的库路径放到了连接器参数LDFLAGS中。接着重新configure,通过了。      # make      这个阶段基本上我的工作就是等着,喝点水。。。等make结束后。。      # make test      C.一波三折:出大问题了(如果配置不正确,这个错误在make install后运行slapd –d 9时也会出现)。。错误3:      cd tests; make test      make[1]: Entering directory `/home/liudan/openldap-2.2.20/tests'      make[2]: Entering directory `/home/liudan/openldap-2.2.20/tests'      Initiating LDAP tests for BDB...      Running ./scripts/all...      >>>>> Executing all LDAP tests for bdb      >>>>> Starting test000-rootdse ...      running defines.sh      Starting slapd on TCP/IP port 9011...      …      slapd init: initiated server.      slap_sasl_init: SASL library ver
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表