Linux系统下安装配置 OpenLDAP + phpLDAPadmin.docx
《Linux系统下安装配置 OpenLDAP + phpLDAPadmin.docx》由会员分享,可在线阅读,更多相关《Linux系统下安装配置 OpenLDAP + phpLDAPadmin.docx(17页珍藏版)》请在冰豆网上搜索。
Linux系统下安装配置OpenLDAP+phpLDAPadmin
Linux系统下安装配置OpenLDAP+phpLDAPadmin
实验环境:
操作系统:
Centos7.4
服务器ip:
192.168.3.41
运行用户:
root
网络环境:
Internet
LDAP(轻量级目录访问协议)是一个能实现提供被称为目录服务的信息服务,也是一套用户认证体系系统;一般在大型企业、学校、政府单位使用的比较多,LDAP是由4部分组成,这4部分分别是slapd(独立LDAP守护进程)、slurpd(独立的LDAP更新复制守护进程)、LDAP协议库、工具软件和示例客户端(phpLDAPadmin),目录服务是一种特殊的数据库系统,用来存储用户信息的数据库,读写速度非常快,扩展性非常强,可以实现与地方系统直接对接整合起来统一管理用户信息。
LDAP说起来也不简单,但是ALDP在Linux应用范围是比较广泛的,如果想要深入的了解LDAP,建议去看下刘遄老师《Linux就该这么学》这本教程,里面解释的非常详细,也可以在XX输入此书名去官网看,想要在Linux部署还是推荐这本书去系统的学习,对初学者还是很有版本的,这篇文章搭建ldap+phpldapadmin也是在Linux环境下运行的,所以还是需要Linux基础才能看懂下面的配置步骤。
1、安装OpenLDAP
[root@centos7~]#yuminstallopenldap-serversopenldap-clients-y
[root@centos7~]#cp/usr/share/openldap-servers/DB_CONFIG.example/var/lib/ldap/DB_CONFIG
[root@centos7~]#ll/var/lib/ldap/DB_CONFIG
-rw-r--r--.1rootroot845Aug110:
04/var/lib/ldap/DB_CONFIG
[root@centos7~]#chownldap./var/lib/ldap/DB_CONFIG//授权配置文件
[root@centos7~]#more/etc/passwd|grepldap
ldap:
x:
55:
55:
OpenLDAPserver:
/var/lib/ldap:
/sbin/nologin
[root@centos7~]#systemctlstartslapd.service//启动slapd服务
[root@centos7~]#systemctlenableslapd.service//设置开机自动启动slapd服务
2、设置OpenLDAP管理员密码
[root@centos7~]#slappasswd
Newpassword:
//password
Re-enternewpassword:
{SSHA}d5pkA0TU6b+8/kEoMIxJ59QofCLV
为“olcRootPW”指定上面生成的密码
[root@centos7~]#vimchrootpw.ldif
dn:
olcDatabase={0}config,cn=config
changetype:
modify
add:
olcRootPW
olcRootPW:
{SSHA}d5pkA0TU6b+8/kEokgQeMIxJ59QofCLV
[root@centos7~]#ldapadd-YEXTERNAL-Hldapi:
///-fchrootpw.ldif
SASL/EXTERNALauthenticationstarted
SASLusername:
gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASLSSF:
0
modifyingentry"olcDatabase={0}config,cn=config"
3、导入基本模式
[root@centos7~]#ldapadd-YEXTERNAL-Hldapi:
///-f/etc/openldap/schema/cosine.ldif
SASL/EXTERNALauthenticationstarted
SASLusername:
gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASLSSF:
0
addingnewentry"cn=cosine,cn=schema,cn=config"
[root@centos7~]#ldapadd-YEXTERNAL-Hldapi:
///-f/etc/openldap/schema/nis.ldif
SASL/EXTERNALauthenticationstarted
SASLusername:
gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASLSSF:
0
addingnewentry"cn=nis,cn=schema,cn=config"
[root@centos7~]#ldapadd-YEXTERNAL-Hldapi:
///-f/etc/openldap/schema/inetorgperson.ldif
SASL/EXTERNALauthenticationstarted
SASLusername:
gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASLSSF:
0
addingnewentry"cn=inetorgperson,cn=schema,cn=config"
4、在LDAPDB上设置域名,生成目录管理器密码
[root@centos7~]#slappasswd
Newpassword:
Re-enternewpassword:
{SSHA}Oq61fgUFW9+ItZboTaW1+VbLuAYst7zw
注意:
下面配置文件这里得注意每一个属性:
后必须有空格,但是值的后面不能有任何空格
[root@centos7~]#vimchdomain.ldif
#replacetoyourowndomainnamefor"dc=***,dc=***"section
#specifythepasswordgeneratedabovefor"olcRootPW"section
dn:
olcDatabase={1}monitor,cn=config
changetype:
modify
replace:
olcAccess
olcAccess:
{0}to*bydn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
readbydn.base="cn=Manager,dc=srv,dc=world"readby*none
dn:
olcDatabase={2}hdb,cn=config
changetype:
modify
replace:
olcSuffix
olcSuffix:
dc=srv,dc=world
dn:
olcDatabase={2}hdb,cn=config
changetype:
modify
replace:
olcRootDN
olcRootDN:
cn=Manager,dc=srv,dc=world
dn:
olcDatabase={2}hdb,cn=config
changetype:
modify
add:
olcRootPW
olcRootPW:
{SSHA}Oq61fgUFW9+ItZboTaW1+VbLuAYst7zw
dn:
olcDatabase={2}hdb,cn=config
changetype:
modify
add:
olcAccess
olcAccess:
{0}toattrs=userPassword,shadowLastChangeby
dn="cn=Manager,dc=srv,dc=world"writebyanonymousauthbyselfwriteby*none
olcAccess:
{1}todn.base=""by*read
olcAccess:
{2}to*bydn="cn=Manager,dc=srv,dc=world"writeby*read
[root@centos7~]#ldapmodify-YEXTERNAL-Hldapi:
///-fchdomain.ldif
SASL/EXTERNALauthenticationstarted
SASLusername:
gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASLSSF:
0
modifyingentry"olcDatabase={1}monitor,cn=config"
modifyingentry"olcDatabase={2}hdb,cn=config"
modifyingentry"olcDatabase={2}hdb,cn=config"
modifyingentry"olcDatabase={2}hdb,cn=config"
modifyingentry"olcDatabase={2}hdb,cn=config"
[root@centos7~]#vimbasedomain.ldif
#replacetoyourowndomainnamefor"dc=***,dc=***"section
dn:
dc=srv,dc=world
objectClass:
top
objectClass:
dcObject
objectclass:
organization
o:
ServerWorld
dc:
Srv
dn:
cn=Manager,dc=srv,dc=world
objectClass:
organizationalRole
cn:
Manager
description:
DirectoryManager
dn:
ou=People,dc=srv,dc=world
objectClass:
organizationalUnit
ou:
People
dn:
ou=Group,dc=srv,dc=world
objectClass:
organizationalUnit
ou:
Group
[root@centos7~]#ldapadd-x-D"cn=Manager,dc=srv,dc=world"-W-fbasedomain.ldif
EnterLDAPPassword:
//输入上面设置的目录管理器密码password
addingnewentry"dc=srv,dc=world"
addingnewentry"cn=Manager,dc=srv,dc=world"
addingnewentry"ou=People,dc=srv,dc=world"
addingnewentry"ou=Group,dc=srv,dc=world"
[root@centos7~]#ldapsearch-x-b"cn=Manager,dc=srv,dc=world"
#extendedLDIF
#
#LDAPv3
#basewithscopesubtree
#filter:
(objectclass=*)
#requesting:
ALL
#
#Manager,srv.world
dn:
cn=Manager,dc=srv,dc=world
objectClass:
organizationalRole
cn:
Manager
description:
DirectoryManager
#searchresult
search:
2
result:
0Success
#numResponses:
2
#numEntries:
1
5、设置Firewalld,如果未启用防火墙关闭,忽略
[root@centos7~]#firewall-cmd--add-service=ldap--permanent
[root@centos7~]#firewall-cmd--reload
6、安装并配置Apache
[root@centos7~]#yuminstallhttpd-devel.x86_64httpd.x86_64-y
[root@centos7~]#mv/etc/httpd/conf.d/welcome.conf/etc/httpd/conf.d/welcome.conf.bak
[root@centos7~]#vim/etc/httpd/conf/httpd.conf
#line86:
changetoadmin'semailaddress
ServerAdminroot@srv.world
#line95:
changetoyourserver'sname
ServerNamewww.srv.world:
80
#line151:
change
AllowOverrideAll
#line164:
addfilenamethatitcanaccessonlywithdirectory'sname
DirectoryIndexindex.htmlindex.cgiindex.php
#addfollowstotheend//在尾部新增
#server'sresponseheader
ServerTokensProd
#keepaliveisON
KeepAliveOn
[root@centos7~]#systemctlstarthttpd.service
[root@centos7~]#systemctlenablehttpd.service
[root@centos7~]#firewall-cmd--add-service=http--permanent//防火墙排除httpd服务,如果没有启用防火墙,此步骤可以忽略。
success
[root@centos7~]#firewall-cmd--reload//重新加载firewall
success
[root@centos7~]#vim/var/www/html/index.html//测试apache服务
100%;font-size:
40px;font-weight:
bold;text-align:
center;">
TestPage