文章转自:http://sjsky.iteye.com/blog/850804 因为这个文章有些老了,稍微做了点改动
一、首先需要获取服务端和客户端
1、下载服务器端安装包,最新版本1.8:
2、下载客户端安装包,最新版本1.8,由于机器是64位,所以下载对应的版本:
官网: http://tortoisesvn.tigris.org/ or http://tortoisesvn.net下载地址:http://sourceforge.net/projects/tortoisesvn
二、软件的安装
服务端是以.msi后缀名的安装文件,安装过程就不详细介绍了,按照它的提示一步步操作即可。
我的实际安装路径是D:\Program Files\Subversion
TortoiseSVN 客户端的安装完成后会提示系统需要重启。
三、配置过程
1.创建repository :有两种方法
方法一:命令行创建
打开命令窗口, 键入 svnadmin create D:\svnroot\test1 回车,
会在 目录 D:\svnroot\生成test1文件夹以及文件夹下相应的文件
方法二:图形化创建
新建文件夹 D:\svnroot\test2(文件夹下必须是空的),在该文件夹下右击选中TortoiseSVN,如下图
上面两种方法都能创建repository ,创建好后生成的目录结构如下:
2.修改配置文件(以上面创建的test1为例:)
在D:\svnroot\test1\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 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
这段配置文件的基本含义为:
- anon-access = read 匿名用户的权限,文件中为read表示拥有只读权限
- auth-access = write 验证通过用户的权限 ,文件中为write表示拥有写的权限
- 权限包括none、read、write三个值可选,none没有权限,写包含了读权限
- 去掉#注释时,前面不要有空格
- password-db = passwd密码数据存放到passwd文件中
- authz-db = authz 表示版本库中访问路径的规则,即谁只能访问哪个目录下的文件,其他目录下的文件无法访问
passwd
- ### This file is an example password file for svnserve.
- ### Its format is similar to that of svnserve.conf. As shown in the
- ### example below it contains one section labelled [users].
- ### The name and password for each user follow, one account per line.
- [users]
- # harry = harryssecret
- # sally = sallyssecret
- michael=michael
PS:passwd 文件中的配置,如:michael=michael表示用户名为michael,密码为michael
四、启动subversion服务
两种方法:命令启动和服务启动
1.命令行启动介绍:
svnserve -d -r D:\svnroot\test1
默认端口是3690,如果这个端口号已经被占用,则可以通过选项 --listen-port=端口号.
备注:经过自己的验证这句并没有起作用
2.服务启动介绍:
安装程序还不能把自己安装成windows服务,需要自己进行手动安装,
新建一个文件mysvn.bat 内容如下:需要将svnserve.exe换成自己的路径,D:\SVNROOT\svngoumin也换成自己的路径
sc create SVNService binPath= "\"C:\Program Files (x86)\Subversion\bin\svnserve.exe\" --service -r D:\SVNROOT\svngoumin" DisplayName= "Subversion" depend= Tcpip start= auto
sc start Subversion
pause
注:“=”前不得有空格,后必须有空格。
右击mysvn.bat 文件以管理员身份运行
执行成功会显示:[SC] CreateService 成功
打开命令窗口键入:services.msc 回车,会在windows的服务中看到刚创建的:
命令的简单解释:
- sc是windows自带的服务配置程序,
- 参数binPath表示svnserve可执行文件的安装路径,由于路径中的"Program Files"带有空格,因此整个路径需要用双引号引起来。而双引号本身是个特殊字符,需要进行转移,因此在路径前后的两个双引号都需要写成\"
- --service参数表示以windows服务的形式运行,
- -r/--root指明svn repository的位置,service参数与root参数都作为binPath的一部分,因此与svnserve.exe的路径一起被包含在一对双引号当中,而这对双引号不需要进行转义。
- displayname表示在windows服务列表中显示的名字
- depend =Tcpip 表示svnserve服务的运行需要tcpip服务
- start=auto表示开机后自动运行
- 若要卸载svn服务,则执行 sc delete svnserve 即可
安装服务后,svnserve要等下次开机时才会自动运行。
五、导入项目
这里可能要注意一下防火墙和杀毒软件,为了调试可以先关闭。
图形化操作即可实现具体步骤如下:
选中需要导入的项目:
输入URL和message
输入用户名和密码
成功导入文件
到此基本完成了svn服务端的安装、配置、启、导入项目等一系列操作。
******************************************************************************************
如果您还需要外网可以访问SVN请再往下看
这个文章介绍了Win7下搭建外网环境的SVN服务器 http://www.cnblogs.com/crazypebble/archive/2011/07/30/2119258.html
我在按照这个文章搭建的时候在配置SVN服务出现了问题,暂时还没得到解决
解决端口冲突的问题:http://blog.youkuaiyun.com/threedonkey/article/details/8217480