Think before you speak, read before you think.

使用apache和subversion整合

by

in

需求:可用浏览器打开svn查看,但使用tortoise提交需要认证

管理员安装

yum install mod_dav_svn subversion

在/etc/httpd/conf.d/subversion.conf添加

<Location /svn>
 DAV svn
 SVNParentPath /var/www/svn
 SVNListParentPath on
 AuthType Basic
 AuthName "Subversion repositories"
 AuthUserFile /etc/svn-auth-users
 <LimitExcept GET PROPFIND OPTIONS REPORT>
 Require valid-user
 </LimitExcept>
</Location>

上面的意思是都可以在浏览器里看到,但是svn提交需要认证

添加svn认证用户

## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password: 
Re-type new password: 
Adding password for user testuser

添加一个svn库

mkdir /var/www/svn
cd /var/www/svn

svnadmin create testrepo
chown -R apache.apache testrepo

chcon -R -t httpd_sys_content_t /var/www/svn/testrepo

## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo

重启apache

/etc/init.d/httpd restart

这样打开浏览器就直接看到库的内容,而如果提交还需要认证。

PS:如果全程认证,则把subversion.conf的Require valid-user从LimitExcept拿出来,并把LimitExcept去掉。

从上述过程可以发现,svnserve一直没有开,用到的协议是http,如果用svn来控制权限,则是另外一回事了。

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *