Subversion的安装部署与用户验证配置
注:本例采取subversion+apache的模式
一:所需软件包下载
编译svn需要依赖sqlite库,RHEL5自带的rpm包版本太低,编译不能通过。
#wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
#wget http://subversion.tigris.org/downloads/subversion-1.6.12.tar.bz2
#wget http://archive.apache.org/dist/httpd/httpd-2.2.16.tar.gz
二:sqlite库编译安装
#tar -zxvf sqlite-amalgamation-3.6.13.tar.gz
#cd sqlite-3.6.13/
#./configure--prefix=/usr/local/sqlite
#make && make install
三:apache编译安装
#cd../
#tar -zxvf httpd-2.2.16.tar.gz
#cd httpd-2.2.16.tar.gz ---subversion与apache结合的时候,需要使用apache服务器的dav模块,在编译apache的时候,需添加 --enable-dav选项
#./configure --prefix=/usr/local/apache --enable-dav --enable-so --enable-rewrite --enable-headers --enable-expires --enable-mods-shared=all
#make&& make install
四:subversion编译安装
#cd../
#tar -jxvf subversion-1.6.12.tar.bz2
#cd subversion-1.6.12
#./configure --prefix=/usr/local/subversion --with-sasl --with-zlib=/usr/lib --with-ssl --with-sqlite=/usr/local/sqlite --with-apxs=/usr/local/apache/bin/apxs
#make && make install
五:配置apache支持subversion
1:查看apache是否编译了dav模块:
#cat/usr/local/apache/build/config.nice
"./configure" \
"--prefix=/home/usr/local/apache"\
"--enable-so" \
"--enable-rewrite" \
"--enable-headers" \
"--enable-dav"\ ---有dav模块
"--enable-expires" \
"--enable-mods-shared=all" \
"$@"
2:配置apache主配置文件httpd.conf
修改servername:
Servername localhost:80
取消拓展配置文件中httpd-vhosts.conf之前的注释:
Includeconf /extra/httpd-vhosts.conf
3:配置/usr/local/apache/conf/extra/httpd-vhosts.conf
#cat /usr/local/apache/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/svn_data"
ServerName 192.168.189.132
<Directory /svn_data>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath /svn_data/
SVNPathAuthz Off
</Location>
创建/svn_data目录:
#mkdir -p /svn_data
4:启动apache服务
验证配置文件语法:
#/usr/local/apache/bin/apachectl -t
如果正常,则显示“SyntaxOK”。
首次配置subversion+apache时,通常会出现如下错误:
httpd: Syntax error online 105 of /usr/local/apache2.2.15/conf/httpd.conf: Cannot load/usr/local/apache2.2.15/modules/mod_dav_svn.so into server:/usr/local/subversion/lib/libsvn_subr-1.so.0: undefined symbol: sqlite3_open_v2
使用如下方法解决:
#echo “/usr/local/sqlite/lib” >>/etc/ld.so.conf
#ldconfig
若使用上述方法依然无法解决错误,则查看系统是否为64为,再使用以下方法:
#mv /usr/lib64/libsqlite3.so.0.8.6 /root/bak
#ln -s /usr/local/sqlite/lib/libsqlite3.so.0.8.6 /usr/lib64/libsqlite3.so.0.8.6
#ldconfig
六:测试subversion
创建svn目录cmh:
#svnadmin create /svn_data/cmh
#ls /svn_data/cmh
conf db format hooks locks README.txt
web界面测试:
出现以上界面,说明subversion初步配置使用完成。
七:配置subversion用户验证
创建subversion配置目录,并创建验证文件:
#mkdir /usr/local/subversion/conf
#cd /usr/local/subversion/conf
#touch authz
#cat authz (配置组、用户、目录权限)
[groups]
admin = admin,cmh
tech = user1,user2
[cmh:/]
@admin = rw
@tech = r
使用apache的htpasswd命令创建passwd文件(首次创建用-cm,后续添加用户用-m):
#/usr/local/apache/bin/htpasswd-cm /usr/local/subversion/conf/passwd cmh
配置/usr/local/apache2.2.15/conf/httpd.conf文件,在svn目录下添加验证配置。
<Location/svn>
DAV svn
SVNListParentPathon
SVNParentPath /svn_data/
SVNPathAuthz On
AuthzSVNAccessFile/usr/local/subversion/conf/authz
AuthName "Private Svn"
AuthType Basic
AuthUserFile/usr/local/subversion/conf/passwd
Require valid-user
</Location>
重启apache:
#/usr/local/apache/bin/apachectl –t
#/usr/local/apache/bin/apachectl –k restart
Web验证:
Subversion (SVN) 的详细介绍:请点这里
Subversion (SVN) 的下载地址:请点这里