本来我的项目都是放在自己的虚拟机svn仓库中,随着仓库越来越多,有的时候需要去查看项目文件.check out到本地之后,挨个查看也是可以的,可是check out也是需要时间的,就想起了apache提供的对svn http的支持,所以就花了一点时间配置了一下.配置的方法很简单,下面是我的apache配置文件.
1 # dav_svn.conf - Example Subversion/Apache configuration 2 # 3 # For details and further options see the Apache user manual and 4 # the Subversion book. 5 # 6 # NOTE: for a setup with multiple vhosts, you will want to do this 7 # configuration in /etc/apache2/sites-available/*, not here. 8 9 # <Location URL> ... </Location> 10 # URL controls how the repository appears to the outside world. 11 # In this example clients access the repository as http://hostname/svn/ 12 # Note, a literal /svn should NOT exist in your document root. 13 <Location /svn> 14 15 # Uncomment this to enable the repository 16 DAV svn 17 18 # Set this to the path to your repository 19 #SVNPath /svn 20 # Alternatively, use SVNParentPath if you have multiple repositories under 21 # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...). 22 # You need either SVNPath and SVNParentPath, but not both. 23 SVNParentPath /SVNRepos 24 SVNListParentPath on 25 # Access control is done at 3 levels: (1) Apache authentication, via 26 # any of several methods. A "Basic Auth" section is commented out 27 # below. (2) Apache <Limit> and <LimitExcept>, also commented out 28 # below. (3) mod_authz_svn is a svn-specific authorization module 29 # which offers fine-grained read/write access control for paths 30 # within a repository. (The first two layers are coarse-grained; you 31 # can only enable/disable access to an entire repository.) Note that 32 # mod_authz_svn is noticeably slower than the other two layers, so if 33 # you don't need the fine-grained control, don't configure it. 34 35 # Basic Authentication is repository-wide. It is not secure unless 36 # you are using https. See the 'htpasswd' command to create and 37 # manage the password file - and the documentation for the 38 # 'auth_basic' and 'authn_file' modules, which you will need for this 39 # (enable them with 'a2enmod'). 40 AuthType Basic 41 AuthName "Subversion Repository" 42 AuthzSVNAccessFile /SVNRepos/auth 43 AuthUserFile /SVNRepos/passwd 44 #To enable authorization via mod_authz_svn (enable that module separately): 45 #<IfModule mod_authz_svn.c> 46 #AuthzSVNAccessFile /SVNRepos/auth 47 #</IfModule> 48 49 # The following three lines allow anonymous read, but make 50 # committers authenticate themselves. It requires the 'authz_user' 51 # module (enable it with 'a2enmod'). 52 #<LimitExcept GET PROPFIND OPTIONS REPORT> 53 Require valid-user 54 #</LimitExcept> 55 56 </Location>
由于是本地,只有我自己会浏览仓库,所以权限方面本来是不需要做的,可是我还是做了一下.主要是提供了auth和passwd文件,配置的方法和svn仓库中conf下面的auth,passwd方法一样的。
1 auth 2 3 [groups] 4 admin = xiaoyan 5 6 [/] # 拥有所有控制权 7 * = # 匿名用户没有任何控制权(不可以r/w) 8 @admin = rw
passwd文件直接使用htpasswd生成就好了. 用户对应就是auth中的用户.这样之后,我就可以在浏览器中随意浏览自己仓库.注意的是,处理编码方面的问题,windows下面的浏览器编码自己设置一下,使用utf8,这样自己写的中文笔记文档就不会乱码了。