Winodw平台下的svn的搭建

来源:互联网 发布:人工智能英文介绍双语 编辑:程序博客网 时间:2024/05/19 20:42

Window下配置SVN服务器与客户端

我将详细的介绍一下关于svn的配置,下面的经过是我自己在配置过程中遇到的问题及解决方案.

如何配置svn服务器:

前提条件:

下载最新的svn服务器: svn-1.4.5-setup.rar

下载最新的svn客户端: TortoiseSVN-1.4.5.10425-win32-svn-1.4.5.rar

下载配置svn服务成window service自动运行的工具: SVNService.rar 配置的步骤如下前提是将本机作为一个服务器:

1.下载并安装svn1.4.5-setup.rar, 假设你安装在:C:/Program Files/Subversion目录下,为系统默认的.

 

2. 建立Repository, 我们可以先在本机上建立一个文件目录如e:/svnroot, 之后再打开命令行窗口, 输入svnadmin create e:/svnroot/project,  Repository的名称自己定如project,你可以去查看e盘下的svnroot文件夹,是否有一个叫project的项目,如果有的话就说明是创建成功了,可以进行下一步了.

 

3.配置Repository,进入Repository目录,这里是e:/svnroot/projects, 你会看到conf目录,进入该目录,你会看到 svnserver.conf和passwd两个文件.

对两个文件作如下修改:

svnserve.conf [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 = read

auth-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 conf directory.

### Uncomment the line below to use the default password file.

password-db = passwd

含义是: 未验证用户无任何权限 (如果把none修改为read就是给予读权限) 已验证用户给予写权限 (当然也能读) 密码数据存放到passwd文件中 passwd [users] harry = harryssecret sally = sallyssecret maoyg=maoyg 注意最后passwd中的配置,一个用户以行,如:maoyg=maoyg 表示用户名为maoyg,密码为maoyg的一个用户。

 

4.启动subversion服务两种方式启动:

(1).以Dos的命令行方式运行:svnserve -d -r e:/svnroot/默认端口是3690,如果不幸这个端口被别的程序暂用,可以通过选项 --listem --port=绑定端口. 我的电脑端口因为没有被别的程序占用,所以输入上面的svnserve -d -r e:/svnroot就可以.

(2)subversion服务:默认情况下载window service中是没有的,必须通过svnservice -install -d -r  e:/svnroot/projects,(svnservice必须和svnserve在同一个目录下)(在后面我单独给介绍,我们先以第一种方式先运行程序) 再用net start svnservice来将其作为服务运行,建议打开控制面板找到SVNService,将其启动类型设置为自动。这样服务器的配置就架构好了。

 

5. 你可以安装TortoiseSVN程序,现在可以用客户端来访问刚刚配置好的服务器了,在IE窗口中输入下列的URL格式:  svn://IP地址/Repository名,  在这里是: svn://127.0.0.1/projects.

可以进行一些客户端的简单日常操作:

要取得当前的服务器的最新版本文件,可以使用SVN updated.

要将修改的文件更新到服务器,选择SVN submit 即可(谨慎的话先更新到最新版本后再提交).

 

遇到的第一个问题就是:

svnserve.conf:12: Option expected,它的解决方法如下:

经常有新手配置基于svnserve的subversion服务器后,在客户端访问subversion版本库时出现这个错误: svnserve.conf:12: Option expected 为什么会出现这个错误呢,就是因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件,

### 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 = read  

auth-access = write

像上面的配置文件中,anon-access是顶行的,没问题,而auth-access就存在前置空格,会导致这个错误。要避免出现这个错误,应该在去掉这些行前的#时,也要顺手去掉前面的空格,所以问题就解决了.

 

遇到的第二个问题是:启动服务的方式,我们在之前使用的是第一个启动方式,我觉得有点麻烦,就是一直都得开一个Dos窗口,这样不方便工作,所以就想到用别的办法来替换了.

SVNService(将svn作为windows服务运行的工具) 将你们下载的第三个软件如SVNServices.rar解压后,把SVNServices.exe放在subversion的bin目录下面,我的是在C:/Program Files/Subversion/bin. SVNService的指令如下:                                                         

Usage instructions:   

SVNService -?                               to display this list   

SVNService -install <svnserve parameters>   to install the service   

SVNService -setup <svnserve parameters>     to change command line parameters for svnserve   

SVNService -remove                          to remove the service   

SVNService -debug                           to run as a console app for debugging       

                                 

例如, 你所有项目都在e:/svnroot下,只介绍下面两个命令的用法: 安装时用  SVNService -install -d -r e:/svnroot 更改时用  SVNService -setup -d -r e:/otherplace/svnroot 再用net start SVNService 来将其作为服务运行,建议打开控制面板找到SVNService,将其启动类型设置为自动。这样服务器的配置就架构好了.                       

参考文章有:

http://www.cnblogs.com/changchangcc520/archive/2007/11/06/950867.html   

http://doc.iusesvn.com/show-28-1.html                             

http://bbs.iusesvn.com/thread-6-1-1.html

原创粉丝点击