基于 svnserve 的服务器


有一些情况下,不能使用Apache作为� 的服务器,Subversion包括Svnserve-一个轻型的独立服务器,使用普通TCP/IP连接之上的自定义协议。

大多数情况下svnserve的设置更� 简单,也比Apache的服务器更� 快。

安装 svnserve

  1. http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91得到最新版本的Subversion。

  2. 如果� 已经安装了Subversion,svnserve已经运行,� 需要在继续之前把它停下来。

  3. 运行Subversion安装程序,如果� 在� 的服务器上运行,可以跳过第4步。

  4. 打开资源管理器,进入Subversion的安装目录(通常是C:\Program Files\Subversion)的bin目录,找到文件svnserve.exeintl3_svn.dlllibapr.dlllibapriconv.dlllibapriutil.dlllibdb*.dlllibeay32.dllssleay32.dll,复制这些文件,或所有bin目录内的文件到� 的服务器目录,例如c:\svnserve

运行 svnserve

现在svnserve已经安装了,� 需要在� 的server运行它,最简单的方法是在DOS窗口或者windows快捷方式输入:

svnserve.exe --daemon

svnserve将会在端口3690等待请求,--daemon选项告诉svnserve以守护进程方式运行,这� �在手动终止之前不会退出。

如果� 没有创建一个版本库,� �据下面的Apache服务器设置指令“配置”一节


假定� 的版本库位于c:\repos\TestRepo,� 的服务器叫做localhost,输入:



You can also increase security and save time entering URLs with svnserve by using the --root switch to set the root location and restrict access to a specified directory on the server:

svnserve.exe --daemon --root drive:\path\to\repository\root

Using the previous test as a guide, svnserve would now run as:

svnserve.exe --daemon --root c:\repos

And in TortoiseSVN our repo-browser URL is now shortened to:


Note that the --root switch is also needed if your repository is located on a different partition or drive than the location of svnserve on your server.

Svnserve 可以提供任意数量的版本库服务。只要将这些版本库放到� 刚才定义的� �目录下即可,然后使用相对于� �的URL访问它们。


不要创建和访问网络共享上的 Berkeley DB 版本库,它不能存在于一个远程的文件系统,即使是� 射到盘符的共享。如果� 希望在网络共享使用 Berkeley DB,结果难以预料-� 可能会立刻看到奇怪的错误,也有可能� 个月之后才发现数据库已经损坏了。

以服务形式运行 svnserve

使用普通用户直接运行 svnserve 通常不是最好的方法。它意味着� 的服务器必须有一个用户登录,还要记着重新启动服务器后重新启动 svnserve。最好的方法是将 svnserve 作为 windows 服务运行。从 Subversion 1.4 开始,svnserve 可以安装为 windows 服务。

To install svnserve as a native windows service, execute the following command all on one line to create a service which is automatically started when windows starts.

sc create svnserve binpath= "c:\svnserve\svnserve.exe --service 
    --root c:\repos" displayname= "Subversion" depend= tcpip start= auto

If any of the paths include spaces, you have to use (escaped) quotes around the path, like this:

sc create svnserve binpath= "
    \"C:\Program Files\Subversion\bin\svnserve.exe\"
    --service --root c:\repos" displayname= "Subversion" depend= tcpip start= auto

You can also add a description after creating the service. This will show up in the Windows Services Manager.

sc description svnserve "Subversion server (svnserve)"

注意 sc 的命令行很特殊。在 key= value 对中,key 与 = 之间不能有空� �,但是在 value 之前,必须有空� �。


Microsoft now recommend services to be run as under either the Local Service or Network Service account. Refer to The Services and Service Accounts Security Planning Guide. To create the service under the Local Service account, append the following to the example above.

obj= "NT AUTHORITY\LocalService"

Note that you would have to give the Local Service account appropriate rights to both Subversion and your repositories, as well as any applications which are used by hook scripts. The built-in group for this is called "LOCAL SERVICE".

服务安装完毕后,� 需要在服务管理器中启动它(仅此一次;当服务器重启后它会自动启动)。

为了得到更详细的信息,可参考 Windows Service Support for Svnserve

If you installed an earlier version of svnserve using the SVNService wrapper, and you now want to use the native support instead, you will need to unregister the wrapper as a service (remember to stop the service first!). Simply use the command

svnservice -remove

to remove the service registry entry.

svnserve 的认证

The default svnserve setup provides anonymous read-only access. This means that you can use an svn:// URL to checkout and update, or use the repo-browser in TortoiseSVN to view the repository, but you won't be able to commit any changes.

为了打开对版本库的写访问,� 可以编辑版本库目录的conf/svnserve.conf文件,这个文件控制了svnserve守护进程的配置,也提供了有用的文档。


anon-access = write

然而,� 不会知道谁修改了版本库,� 为svn:author属性是空的,� 也不能控制谁来修改版本库,这是一个很危险的设置。

One way to overcome this is to create a password database:

anon-access = none
auth-access = write
password-db = userfile

Where userfile is a file which exists in the same directory as svnserve.conf. This file can live elsewhere in your file system (useful for when you have multiple repositories which require the same access rights) and may be referenced using an absolute path, or a path relative to the conf directory. If you include a path, it must be written /the/unix/way. Using \ or drive letters will not work. The userfile should have a structure of:

username = password

This example would deny all access for unauthenticated (anonymous) users, and give read-write access to users listed in userfile.


If you maintain multiple repositories using the same password database, the use of an authentication realm will make life easier for users, as TortoiseSVN can cache your credentials so that you only have to enter them once. More information can be found in the Subversion book, specifically in the sections Create a 'users' file and realm and Client Credentials Caching

使用 svn+ssh 认证


通过此方法,svnserve不会作为守护进程启动,而是SSH为� 启动svnserve,以SSH授权用户运行,为此,� 需要在� 的服务器上有SSH守护进程。

It is beyond the scope of this documentation to detail the installation and setup of a secure shell, however you can find further information in the TortoiseSVN FAQ, SSH How-To. You can find other SSH topics within the FAQ by searching for “SSH”.

更多的关于svnserve的信息可以看《使用 Subversion 进行版本管理》

svnserve 以路径为基础的授权

从Subversion1.3开始,svnserve支持与mod_authz_svn相同的路径为基础的授权模式,� 需要编辑版本库路径下的conf/svnserve.conf引用的授权文件。

authz-db = authz

在这里,authz是� 创建用来定义访问权限的文件,� 可以为每一个版本库使用单独的文件,或者为所有的版本库使用相同的文件,关于此文件的� �式可以查看“路径为基础的授权”一节

Cyrus SASL Support

Starting with Subversion 1.5.0, svnserve and TortoiseSVN support Cyrus SASL (Simple Authentication and Security Layer) for the svn:// protocol. You can find further information in this subversion app note: Using Cyrus SASL Authentication with Subversion.