1、 安装Berkeley DB
# tar zxvf db-4.8.26.tar.gz
# cd db-4.8.26/build_unix/
# ../dist/configure
# make
# make install
# vi /etc/ld.so.conf 加入
/usr/local/BerkeleyDB.4.8/lib
# /sbin/ldconfig
2、 安装openldap-stable-20100219.tgz
# tar zxvf openldap-stable-20100219.tgz
# cd openldap-2.4.21/
# env CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib" ./configure --prefix=/usr/local/openldap --enable-bdb
# make depend
# make
# make test
# make install
vi /usr/local/openldap/etc/openldap/slapd.conf 在include /usr/local/openldap/etc/openldap/schema/core.schema下面加入以下内容
include /usr/local/openldap/etc/openldap/schema/corba.schema
include /usr/local/openldap/etc/openldap/schema/cosine.schema
include /usr/local/openldap/etc/openldap/schema/dyngroup.schema
include /usr/local/openldap/etc/openldap/schema/inetorgperson.schema
include /usr/local/openldap/etc/openldap/schema/java.schema
include /usr/local/openldap/etc/openldap/schema/misc.schema
include /usr/local/openldap/etc/openldap/schema/nis.schema
include /usr/local/openldap/etc/openldap/schema/openldap.schema
suffix "dc=example,dc=com"
rootdn "cn=root,dc=example,dc=com"
rootpw {SSHA}YBW53fU7sd3wshdPHOWoA7x0EnJrFuRY
{SSHA}YBW53fU7sd3wshdPHOWoA7x0EnJrFuRY这个字符串的取得方法
# /usr/local/openldap/sbin/slappasswd 回车,再输入你用的密码
启动openldap
# /usr/local/openldap/libexec/slapd
建立DN
# ldapadd -x -D 'cn=root,dc=example,dc=com' -W
dn: dc=example,dc=com
objectClass: dcObject
objectClass: organization
dc: example
o: Corporation
description: d Corporation
注:冒号后要有空格,结尾不要有空格
输入完后按Ctrl+d结束
3、安装phpldapadmin
# tar zxvf phpldapadmin-1.2.0.5.tgz
# cp -a phpldapadmin-1.2.0.5 /var/www/html/phpldapadmin
# cd ../phpldapadmin/config
# cp config.php.example config.php
# vi config.php
$servers->newServer('ldap_pla');
$servers->setValue('server','name','LDAP Server');
$servers->setValue('server','host','127.0.0.1');
$servers->setValue('server','port',389);
$servers->setValue('server','base',array('dc=example,dc=com'));
$servers->setValue('login','auth_type','session');
$servers->setValue('login','bind_id','cn=root,dc=example,dc=com');
$servers->setValue('login','bind_pass','111111');
$servers->setValue('server','tls',false);
把phpldapadmin变成中文
# cd /var/www/html/phpldapadmin/locale/zh_CN/LC_MESSAGES
# iconv -f gbk -t utf8 messages.po > messages.new.po
# msgfmt -o messages.mo messages.new.po
# vi /var/www/html/phpldapadmin/htdocs/header.php
$language = isset($config) ? $language = $config->GetValue('appearance','language') : 'zh_CN'; 原auto
我安装出现的问题:
1、不能用apache 正常访问phpldapadmin
原来是PHP 没装好,,没装上php-ldap
使用 Yum install –y php-ldap
2、安装完后,用phpldapadmin 时,不能添加UID号 和 GID 号,解决办法是要先用ldapadd,添加用户的uidNumber,gidNumber
如:vim zxy.ldif
# zxy, people, example.com
dn: uid=zxy,ou=people,dc=example,dc=com
uid: zxy
cn: zxy
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: 111111
shadowLastChange: 14323
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1005
gidNumber: 1005
homeDirectory: /home/zxy
使用命令添加:
ldapadd -x -D "cn=root,dc=example,dc=com" -w 111111 –f zxy.ldif
查看
Ldapsearch -x –b “dc=example,dc=com"
至此就可以正常使用phpldapadmin添加用户了。。。