linux svn域账号认证

操作系统: centos 5.5 i386
需要软件包:
openldap-2.3.43-25.el5
mysql-5.0.45.tar.gz
php-5.2.4.tar.gz
httpd-2.2.6.tar.gz
subversion-1.7.1.tar.gz


1.安装openldap
#yum install openldap
# rpm -qa openldap*
openldap-2.3.43-25.el5

2、安装mysql
#groupadd mysql
#useradd -g mysql -s /bin/false -M mysql
#tar zxvf mysql-5.0.45.tar.gz
#cd mysql-5.0.45
#./configure --prefix=/usr/local/mysql   --enable-thread-safe-client --enable-local-infile --with-charset=utf8 --with-extra-charset=all --with-low-memory
#make && make install
#cp support-files/my-medium.cnf  /etc/my.cnf
#cd  /usr/local/mysql
#chown -R mysql .
#chgrp -R mysql .
#bin/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql var
#bin/mysqld_safe --user=mysql &

#cd  /mysql-5.0.45
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#chmod  700  /etc/rc.d/init.d/mysqld
加入自动启动服务队列:
#chkconfig --add mysqld
#chkconfig  --level  345  mysqld  on

添加root密码
#/usr/local/mysql/bin/mysqladmin -uroot -p 旧密码 password 新密码
说明:此时mysql的root用户的密码为空
配置库文件搜索路径

# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig -v

添加/usr/local/mysql/bin到环境变量PATH中
#export PATH=$PATH:/usr/local/mysql/bin

3.安装、配置httpd
svn需要加载 --enable-dav --enable-dav-fs
ldap需要加载 --enable-ldap --enable-authnz-ldap
# useradd apache
#tar zxvf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
#./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --enable-dav --enable-dav-fs --enable-rewrite --en
able-ssl --enable-ldap --enable-authnz-ldap --with-included-apr --with-ldap --with-ldap-include=/usr/lib/evolution-openldap/include
--with-ldap-lib=/usr/lib
#make && make install
#echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local(系统启动时服务自动启动)

更改apache配置文件
#vim /usr/local/apache2/http.conf
添加
User apache
Group apache
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule ldap_module modules/mod_ldap.so

4.安装php
#yum install libpng-devel
#yum install libjpeg-devel
# tar -zvxf php-5.2.3.tar.gz
# mkdir -p /usr/local/php
# cd php-5.2.3
#./configure --prefix=/usr/local/php  --with-apxs2=/usr/local/apache/bin/apxs --with-mysql  --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libdir=lib64 --with-png-dir=/usr/lib64/libpng.so --with-jpeg-dir=/usr/lib64/libjpeg.so  --with-zlib --with-gd --with-freetype --enable-mbstring=all
# make

/php-5.2.3/ext/mysqli/mysqli_api.c:603: error: 'gptr' undeclared (first use in this function)

make: *** [mysqli_api.lo] 错误 1

查找mysqli_api.c所有gptr,有四处分别位于行144、行150、行603、行607,以 char* 替换

#make install
# cp php.ini-dist  /usr/local/php/lib/php.ini
#vim /usr/local/apache/conf/httpd.conf
添加
 LoadModule php5_module        modules/libphp5.so
 AddType application/x-httpd-php  .php
 AddType application/x-httpd-php-source  .phps
 DirectoryIndex  index.php  index.html

5.安装subversion
#mkdir /usr/local/svn  
#tar zxvf subversion-1.7.1.tar.gz
#cd subversion-1.7.1
# ./configure --prefix=/usr/local/svn --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/bin/apr-1-config
--with-apr-util=/usr/local/apache2/bin/apu-1-config
# make && make install
更改apache配置
#vim /usr/local/apache/conf/httpd.conf
添加
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

6、配置svn
#mkdir -p /data/svn/svn
#mkdir -p /data/svn/svn_auth
#/usr/local/apache2/bin/htpasswd -b /data/svn/svn_ahth/passwd test1 test  #新建用户test1 密码为test
#touch /data/svn/svn_ahth/auth.conf #创建svn配置文件
#svn admin create /data/svn/svn/mysvn #建立svn配置mysvn
#chown apache.apache /data/svn/svn/mysvn -R #更改svn库权限
#vim /data/svn/svn_ahth/auth.conf #为用户test1增加访问权限
[mysvn:/]
test1 = rw

#vim /usr/local/apache/conf/httpd.conf
若需要本地认证,配置如下
<Location /svn_local>
DAV svn
SVNParentPath /data/svn/svn  #svn库存放路径
AuthType Basic
AuthName "Welcome to svn"
AuthUserFile /data/svn/svn_auth/passwd #svn用户名、密码
AuthzSVNAccessFile /data/svn/svn_auth/auth.conf #svn权限配置文件
Require valid-user
</Location>
#/usr/local/apache2/bin/apachectl restart
在浏览器访问mysvn库
http://svn.test.com/svn_local/mysvn

如需要ldap(域账号)认证,配置如下:
#svn ldap认证缓存
LDAPSharedCacheSize 200000
LDAPCacheEntries 1024
LDAPCacheTTL 600
LDAPOpCacheEntries 1024
LDAPOpCacheTTL 600

<Location /svn_ldap>
DAV svn
SVNParentPath /data/svn/svn
AuthzSVNAccessFile /data/svn/svn_auth/auth.conf
# authentication
AuthType Basic
AuthName "ldap svn"
AuthBasicProvider ldap #ldap认证
AuthLDAPBindDN "cn=admin,ou=Admin,dc=test,dc=com"  #绑定ldap认证用户  
AuthLDAPBindPassword 123456 #绑定ldap认证用户密码
AuthLDAPURL "ldap://10.10.1.13:389/ou=Users,dc=test,dc=com?sAMAccountName?sub?(objectClass=*)"  
Allow from All
require valid-user
</Location>
在域控ou “Users”添加用户test2
通过浏览器访问mysvn库测试
http://svn.test.com/svn_ldap/mysvn


参考文档
http://81236880.blog.51cto.com/3301633/605198
http://bbs.iusesvn.com/viewthread.php?tid=2134&extra=page%3D1%26amp%3Bfilter%3Ddigest
http://apache.jz123.cn/mod/mod_authnz_ldap.html