OpenLDAP服务端+PhpLdapAdmin 基本安装与配置

来源:互联网 发布:ipad淘宝购物车打不开 编辑:程序博客网 时间:2024/06/06 14:06

转载:http://blog.csdn.net/post_yuan/article/details/53129735


参考了一些其他人写的一些关于安装配置OpenLDAP的文章,于是乎手痒痒也自己动手尝试了一下安装与配置OpenLDAP,并安装PhpLdapAdmin用来通过WEB界面去管理LDAP。

下面就详细介绍如何一步步安装配置LDAP服务器,仅供参考~


1 yum安装OpenLDAP

[html] view plain copy
  1. <span style="font-size:14px;">[root@ha-3 yum.repos.d]# yum install openldap openldap-* -y  
  2. [root@ha-3 yum.repos.d]# rpm -qa | grep openldap  
  3. openldap-servers-2.4.40-12.el6.x86_64  
  4. openldap-devel-2.4.40-12.el6.x86_64  
  5. openldap-servers-sql-2.4.40-12.el6.x86_64  
  6. openldap-clients-2.4.40-12.el6.x86_64  
  7. openldap-2.4.40-12.el6.x86_64  
  8. </span>  

2 配置ldap,包括准备DB_CONFIG和slapd.conf

[html] view plain copy
  1. <span style="font-size:14px;">[root@ha-3 yum.repos.d]# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG  
  2. [root@ha-3 yum.repos.d]# cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf</span>  

3 生成ldap管理员密码

[html] view plain copy
  1. <span style="font-size:14px;">[root@ha-3 yum.repos.d]# slappasswd -s ldap123  
  2. {SSHA}iVje00GFFMDTkymLvxTF3lA7aRgiWRwZ</span>  

4 修改slapd.conf,主要配置dc和rootpw,rootpw配置为上述步骤中的密码

[html] view plain copy
  1. <span style="font-size:14px;">database        bdb  
  2. suffix          "dc=esgyn,dc=com"  
  3. checkpoint      1024 15  
  4. rootdn          "cn=Manager,dc=esgyn,dc=com"  
  5. # Cleartext passwords, especially for the rootdn, should  
  6. # be avoided.  See slappasswd(8) and slapd.conf(5) for details.  
  7. # Use of strong authentication encouraged.  
  8. # rootpw                secret  
  9. # rootpw                {crypt}ijFYNcSNctBYg  
  10. rootpw                  {SSHA}iVje00GFFMDTkymLvxTF3lA7aRgiWRwZ</span>  

5 检测并重新生成ldap数据库

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 slapd.d]# ls  
  2. cn=config  cn=config.ldif  
  3. [root@cent-1 slapd.d]# rm -rf *  
  4. [root@cent-1 slapd.d]# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d/  
  5. config file testing succeeded</span>  

6 修改相关ldap文件权限

[html] view plain copy
  1. <span style="font-size:14px;">[root@ha-3 yum.repos.d]# chown -R ldap:ldap /var/lib/ldap/  
  2. [root@ha-3 yum.repos.d]# chown -R ldap:ldap /etc/openldap/</span>  

7 启动slapd服务

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 ~]# service slapd status  
  2. slapd is stopped  
  3. [root@cent-1 ~]# service slapd start  
  4. Starting slapd:                                            [  OK  ]</span>  
8 yum安装migrationtools

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 slapd.d]# yum install migrationtools -y</span>  
9 编辑/usr/share/migrationtools/migrate_common.ph并修改相关配置

[html] view plain copy
  1. <span style="font-size:14px;"># Default DNS domain  
  2. $DEFAULT_MAIL_DOMAIN = "esgyn.com";  
  3.   
  4. # Default base  
  5. $DEFAULT_BASE = "dc=esgyn,dc=com";  
  6. </span>  
10 生成base.ldif

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 slapd.d]# /usr/share/migrationtools/migrate_base.pl >base.ldif</span>  
11 添加base.ldif到ldap

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 migrationtools]# ldapadd -x -D "cn=Manager,dc=esgyn,dc=com" -W -f ./base.ldif  
  2. Enter LDAP Password:  
  3. adding new entry "dc=esgyn,dc=com"  
  4.   
  5. adding new entry "ou=Hosts,dc=esgyn,dc=com"  
  6.   
  7. adding new entry "ou=Rpc,dc=esgyn,dc=com"  
  8.   
  9. adding new entry "ou=Services,dc=esgyn,dc=com"  
  10.   
  11. adding new entry "nisMapName=netgroup.byuser,dc=esgyn,dc=com"  
  12.   
  13. adding new entry "ou=Mounts,dc=esgyn,dc=com"  
  14.   
  15. adding new entry "ou=Networks,dc=esgyn,dc=com"  
  16.   
  17. adding new entry "ou=People,dc=esgyn,dc=com"  
  18.   
  19. adding new entry "ou=Group,dc=esgyn,dc=com"  
  20.   
  21. adding new entry "ou=Netgroup,dc=esgyn,dc=com"  
  22.   
  23. adding new entry "ou=Protocols,dc=esgyn,dc=com"  
  24.   
  25. adding new entry "ou=Aliases,dc=esgyn,dc=com"  
  26.   
  27. adding new entry "nisMapName=netgroup.byhost,dc=esgyn,dc=com"</span>  
12 检查ldapadd是否成功

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 migrationtools]# ldapsearch -x -D "cn=Manager,dc=esgyn,dc=com" -b "ou=Aliases,dc=esgyn,dc=com" -W  
  2. # extended LDIF  
  3. #  
  4. # LDAPv3  
  5. # base <ouou=Aliases,dc=esgyn,dc=com> with scope subtree  
  6. # filter: (objectclass=*)  
  7. # requesting: ALL  
  8. #  
  9.   
  10. # Aliases, hadoop.com  
  11. dn: ou=Aliases,dc=esgyn,dc=com  
  12. ou: Aliases  
  13. objectClass: top  
  14. objectClass: organizationalUnit  
  15.   
  16. # search result  
  17. search: 2  
  18. result: 0 Success  
  19.   
  20. # numResponses: 2  
  21. # numEntries: 1</span>  
13 yum安装httpd及PhpLdapAdmin

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 migrationtools]# yum install httpd phpldapadmin -y</span>  
14 配置/etc/httpd/conf.d/phpldapadmin.conf允许从远程访问

[html] view plain copy
  1. <span style="font-size:14px;">Alias /phpldapadmin /usr/share/phpldapadmin/htdocs  
  2. Alias /ldapadmin /usr/share/phpldapadmin/htdocs  
  3.   
  4. <Directory /usr/share/phpldapadmin/htdocs>  
  5.   Order Deny,Allow  
  6.   Allow from all  
  7. </Directory></span>  

15 修改/etc/phpldapadmin/config.php配置用DN登录

[html] view plain copy
  1. <span style="font-size:14px;">$servers->setValue('login','attr','dn');  
  2. // $servers->setValue('login','attr','uid');</span>  
16 启动httpd服务

[html] view plain copy
  1. <span style="font-size:14px;">[root@cent-1 migrationtools]# service httpd status  
  2. httpd is stopped  
  3. [root@cent-1 migrationtools]# service httpd start  
  4. Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.16 for ServerName  
  5.                                                            [  OK  ]</span>  

17 打开Web UI并登录LDAP








原创粉丝点击