您的位置主页 > SVN配置

SVN安装手记

Subversion适合于规模一般(几十开发人员)的项目代码的版本管理工作。使用体验较VSS、CVS等好,推荐在选择版本管理工具时可以试用一下。



安装Subversion



1 安装svn-1.4.0-setup。



2 将SVN配置成服务。一般情况下,我们将SVN服务安装成可以以windows系统服务的形式在开机时自动运行。但Subversion安装程序还不能把自己安装成windows服务,需要我们自己进行手动安装,方法如下:打开一个DOS命令窗口,执行如下命令:
sc create svnserve binPath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service --root d:\svn" DisplayName= "Subversion" depend= Tcpip start= auto   

注意在binPath 、 DisplayName、depend、start后的=号要紧跟其后。

其中,sc是windows自带的服务配置程序,参数binPath表示svnserve可执行文件的安装路径,由于路径中的"Program Files"带有空格,因此整个路径需要用双引号引起来。而双引号本身是个特殊字符,需要进行转移,因此在路径前后的两个双引号都需要写成\"

--service参数表示以windows服务的形式运行,--root指明svn repository的位置,service参数与root参数都作为binPath的一部分,因此与svnserve.exe的路径一起被包含在一对双引号当中,而这对双引号不需要进行转义。

displayname表示在windows服务列表中显示的名字, depend= Tcpip 表示svnserve服务的运行需要tcpip服务,start= auto表示开机后自动运行。

安装服务后,svnserve要等下次开机时才会自动运行。若要马上运行服务,则执行net start Subversion即可。

若要卸载svn服务,则执行 sc delete svnserve 即可。



3 安装客户端TortoiseSVN-1.4.0.7501-win32-svn-1.4.0。在SVN服务器上也安装客户端,便于在服务器上对SVN进行配置。



4 安装简体中文语言包LanguagePack-1.4.0.7501-win32-zh_CN。安装完毕后,单击右键,选择Settings...。

Language选择简体中文。



5 在服务器上创建数据仓库。我们在启动服务器时指定了数据仓库的位置: d:\svn。因此,我们在该目录下单击右键,选择TortoiseSVN->在此创建版本库..., 选择本地文件系统。



6 配置用户权限。
使匿名用户无访问权限。只允许认证用户访问。
打开d:\svn\conf\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 = none
# 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
### 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 conf
### directory. 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

添加用户robindy,就是我,^_^。密码:520
打开D:\svn\conf\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]
robindy = 520

建立一个用户组admin,并把我自己加入这个组,赋予这个组中成员读写的权利。^_^,只有我能这个SVN版本库进行操作喽。
打开D:\svn\conf\authz,修改如下:
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to a
### single user, to a group of users defined in a special [groups]
### section, or to anyone using the '*' wildcard. Each definition can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[groups]
admin = robindy

[/]
* = r
@admin = rw

重启Subversion服务后生效。

此外, 经常有朋友问到Subversion是否可以对中文目录进行权限控制,如果可以,该如何配置。

经过测试,发现subversion是可以很好地控制中文目录的权限的。

方法很简单,就是将你的权限控制文件的格式转换为UTF-8格式,
将权限文件改成UTF-8格式我使用的是UltraEdit的菜单"ASCII to UTF-8 (Unicode Editing)"。

7 接下来就可以使用集成于右键菜单的SVN客户端工具对SVN版本库进行操作喽。这些就留给你自己摸索一下吧,很简单的。



祝使用愉快。