SVN配置(SVN1.6.5)

来源:互联网 发布:方正排版软件怎么用 编辑:程序博客网 时间:2024/05/16 16:01

 首先在网上参考了很多的文章,其实这个使用起来还是很简单的,主要是在增加为windows自启动时,花了很多的时间。记下来。方便以后自己和大家需要用到时候少走弯路。

在windows7 和xp都安装过

1. TortoiseSVN 1.6.5 这个是客户端

http://dl.pconline.com.cn/download/53122.html  里面包括安装msi和中文语言包(可以选择安装),也可以到http://tortoisesvn.net/downloads.html下载最新的客户端,如果要安装服务器记得下面的SVN版本要对应,否则会出问题,这个我是在网上看到的,自己没有亲自试个安装版本不对应的情况,既然别人那么说了就没有去尝试了(批评下自己容易相信别人,哈哈,最后的结果还是自己试过才会知道)。

下载完了安装就可以了

2.Subversion-1.6.5.msi  这个是SVN服务器

http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=11151&expandFolder=11151&folderID=91

下载好了后安装并配置SVN服务器。

1)  安装路径选择

     选择的是D:\Program Files\Subversion下,就是安装这个路径下导致我后来按照网上的方法设置自启动一直没有成功,不过后来发现没有必要加转义符,所安装路径选择类似的没有问题的。

 

2)配置用户和权限
     用文本编辑器打开D:\svn\repository1\conf目录,修改svnserve.conf:

     行前凡是有#的都等于是被注释忽略了, 你可以把#去掉让那一行生效,不要留空格。 或者自己新添加行。对这个文件主要修改3处:
     把" #anon-access = read"改为"anon-access = none"
    (表示没有经过验证的用户无任何权限,之前的意思是没经过验证的用户可以进行读操作。建议该成none,不然别人没有验证的人都可以看到项目文件)

     把" #auth-access = write"去掉#为"auth-access = write"
    (通过验证的用户有写操作,写操作是包含读操作的)

    把"# password-db = passwd" 前的注释#去掉。

    (密码数据存放到passwd文件中)

   如果需要用到文件authz文件得把# authz-db = authz的注释去掉。

### This file controls the configuration of the svnserve daemon, if you### use it to allow access to this repository.  (If you only allow### access through http: and/or file: URLs, then this file is### irrelevant.)### Visit http://subversion.tigris.org/ for more information.[general]### These options control access to the repository for unauthenticated### and authenticated users.  Valid values are "write", "read",### and "none".  The sample settings below are the defaults.anon-access = noneauth-access = write### The password-db option controls the location of the password### database file.  Unless you specify a path starting with a /,### the file's location is relative to the directory containing### this configuration file.### If SASL is enabled (see below), this file will NOT be used.### Uncomment the line below to use the default password file.password-db = passwd### The authz-db option controls the location of the authorization### rules for path-based access control.  Unless you specify a path### starting with a /, the file's location is relative to the the### directory containing this file.  If you don't specify an### authz-db, no path-based access control is done.### Uncomment the line below to use the default authorization file.# authz-db = authz### This option specifies the authentication realm of the repository.### If two repositories have the same authentication realm, they should### have the same password database, and vice versa.  The default realm### is repository's uuid.# realm = My First Repository[sasl]### This option specifies whether you want to use the Cyrus SASL### library for authentication. Default is false.### This section will be ignored if svnserve is not built with Cyrus### SASL support; to check, run 'svnserve --version' and look for a line### reading 'Cyrus SASL authentication is available.'# use-sasl = true### These options specify the desired strength of the security layer### that you want SASL to provide. 0 means no encryption, 1 means### integrity-checking only, values larger than 1 are correlated### to the effective key length for encryption (e.g. 128 means 128-bit### encryption). The values below are the defaults.# min-encryption = 0# max-encryption = 256


打开passwd文件
设置一个用户名如 test=test1(用户名为test,密码为test1)

[users]
#harry = harryssecret
#sally = sallyssecret
test = test1

还有一个文件authz
用这个首先将svnserve.conf中的# authz-db = authz的注释去掉。这个文件主要是用来针对不同的目录给用户分配不同的权限的。
如:
[groups]
team1 = manager,staff
表示划定一个小组,组员有manager和staff用户

[repository:/baz/fuz]
@team1= rw
 * = r
表示team1这个组对资源有读写权限,资源对所有人有读权限

[/foo/bar]
manager = rw
* =r
也可以像这样对个人设置权限,manager有读写权限,该资源对所有人有读权限
这些可以根据个人需要修改。

3)建立SVN资源库(Repository)

     运行Subversion服务器需要首先要建立一个版本库(Repository),版本库可以看作是服务器上集中存放和管理数据的地方。在安装客户端时默认已经创建了一个版本库,可以直接用这个库,或是根据需要重新建立一个库。

   新建一个版本库具体操作步骤如下首先建立d:\svn 空文件夹作为所有版本库的根目录。然后,进入命令行并切换到subversion的bin目录。输入如下命令:

   svnadmin create D:\svn\repository1

   此命令在D:\svn 下建立一个版本库repository1。repository1下面会自动生成一些文件夹和文件。就会在目录D:\svn\repository1下创建一个版本库。

  也可以使用TortoiseSVN 图形化的完成这一步:

  先建立空目录D:\svn\repository1,注意一定是要空的。然后在repository1文件夹上“右键->TortoiseSVN->Create Repository here”,然后可以选择版本库模式,这里使用默认的FSFS即可,然后就创建了一系列文件夹和文件,同命令行建立的一样。(可能有的版本不能直接选择版本库模式)。

4)  运行svn服务器
在安装的Subversion目录下有个bin目录里svnserve.exe,我们直接运行这个文件是无效的。需要在控制台来启动他。直接在cmd命令中输入svnserve -d -r D:\svn这样服务就启动了当然你关闭dos窗口的时候svn服务也就关闭了。svn的所有操作都需要在这个服务器启动的基础上进行。但是一直开着这个dos命令窗口很不爽,添加启动项开机自动启动。
首先我们需要为svnserve创建一个系统服务(cmd.exe中输入以下):

sc create svnserver binPath= "D:\Program Files\Subversion\bin\svnserve.exe --service -r D:\svn" DisplayName= "Subversion" depend= Tcpip start= auto


binpath指svnserve.exe的路径,当时在网上看到“如果你的路径里有空格记得要在binpath的头尾用转义字符把整个binpath框起来,D:\svn指svn资源库根目录)(sc create svnserver binPath= “\“D:\ProgramFiles\Subversion\bin\”--service -r D:\svn\repository“ DisplayName= "subversion“ depend= Tcpip start= auto 结果我创建N次都不能启动),我实践结果是不需要加什么转义符启动成功,或者到服务里去手工启动。
displayname指服务名称
depend指协议是tcpid
start指开机自动启动
注意:以上的=后面的一个空格千万不要丢了

为了验证svnserve正常工作,使用TortoiseSVN -> Repo-browser 来查看版本库。在弹出的URL 对话框中输入:
svn://localhost/repository1

如果无能访问的话(直接在cmd命令中输入svnserve -d -r D:\svn这样服务就启动了当然你关闭dos窗口的时候svn服务也就关闭了。)

这时如果没有导入项目的话显示为空。

初始化导入

比如,在d:\wwwroot 下有个guestbook 文件夹,里面存放的是编写的留言簿程序。在此文件夹上“右键-> TortoiseSVN -> Import...” ,在弹出对话框的“URL of repository”输入“svn://localhost/repository1/guestbook”。在“Import message”输入“导入整个留言簿”作为注释。点OK 后要求输入帐号。我们在用户名和密码处都输入test 。完成后guestbook 中的内容全部导入到了svn://localhost/repository1/guestbook 。我们看到在e:\svn\repository1没有任何变化,连个guestbook 文件夹都没有建立,唯一的变化就是e:\svn\repository1容量变大了。实际上我们源guestbook中的内容已经导入repository1版本库了,源guestbook 文件夹可以删除了。

剩下其他基本操作就慢慢学习吧~