Subversion SVN服务器

来源:互联网 发布:visual studio php 编辑:程序博客网 时间:2024/05/17 22:30

一、下载安装


svn是apache的一个开源项目,全称为subversion。是一个基于版本的项目管理软件,一般在多人开发的项目中使用,目前svn已经替代了原来的cvs。大多数情况下,svn服务安装在linux服务器上。下面简单的说一下svn在windows服务上的安装。
 

1、准备svn的安装文件

进入http://subversion.apache.org/packages.html#windows 下载svn的安装文件,
如下图:




 2、下载完成后

在相应的盘符中会有一个Setup-Subversion-1.8.5.msi的文件。然后双击安装文件进行安装。我安装在D:\Program Files (x86)\Subversion目录里。如下图:



3、把svn安装目录里的bin目录添加到path路径中。

即:D:\Program Files (x86)\Subversion\bin添加到path的环境中去,添加完成后在命令行窗口中输入 svnserve --help 。如果能显示如下内容,证明svn已经在path路径中设置成功 。同时这样可以打开svn的帮助信息。如下图:


二、账户设置


1、这样svn基本算是安装完成了,

svn安装完成后,就要对svn进行配置,首先要设置一个本地根目录,这个根目录是用来存放以后要进行管理的所有项目,本例子将svn的根目录设置在 d:\svn\下面,即在相应的盘符创建文件夹就可以了。


2、创建仓库

svnadmin create d:/svn/test



3、修改版本配置库文件


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 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 = test [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

对用户配置文件的修改是立即生效的,不必重启svn。


4、开始设置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.### 在下面添加用户和密码,每行一组username = password[users]# harry = harryssecret# sally = sallyssecret###===========下面是我添加的用户信息========#######iitshare = password1itblood = password2


5、开始设置authz. 用户访问权限


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,###  - a group of users defined in a special [groups] section,###  - an alias defined in a special [aliases] section,###  - all authenticated users, using the '$authenticated' token,###  - only anonymous users, using the '$anonymous' token,###  - anyone, using the '*' wildcard.###### A match can be inverted by prefixing the rule with '~'. Rules can### grant read ('r') access, read-write ('rw') access, or no access### (''). [aliases]# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil,         Ltd./OU=Research Institute/CN=Joe Average # [groups]# harry_and_sally = harry,sally# harry_sally_and_joe = harry,sally,&joe # [/foo/bar]# harry = rw# &joe = r# * = # [repository:/baz/fuz]# @harry_and_sally = rw# * = r ###--------------------下面我新加的------------------------######屏蔽掉上面的[groups] 因为在下面添加了 [groups]devteam = iitshare, itblood #devteam 项目组包括两个用户iitshare,itblood [/]iitshare = rwitblood =[test:/tb2c]@devteam = rwitblood = [test:/tb2b2c]@devteam = rwitblood = r

其中,1个用户组可以包含1个或多个用户,用户间以逗号分隔。
说明:


devteam = iitshare, itblood #devteam 项目组包括两个用户iitshare,itblood[/]iitshare = rw #iitshare 对根目录有读写权限itblood = #itblood 对根目录没有任何权限####如果需要配置tb2c、tb2b2c项目的权限,前提条件是test仓库下面需要有这两个项目####如果没有的话,test都将不能访问[tshop:/tb2c] #对test仓库的tb2c项目进行权限控制@devteam = rw #控制 devteam 组对tb2c项目有读写权限itblood = #限制 itblood 所有权限,其它用户有读写权限[tshop:/tb2b2c] #对 test: 仓库的 tb2b2c 项目进行权限控制@devteam = rw #限制 devteam 组对tb2b2c项目有读写权限itblood = r #限制 itblood 只有读权限,其它用户有读写权限

6、注意:


* 权限配置文件中出现的用户名必须已在用户配置文件中定义。
* 对权限配置文件的修改立即生效,不必重启svn。
用户组格式:


[groups]= ,其中,1个用户组可以包含1个或多个用户,用户间以逗号分隔。版本库目录格式:[<版本库>:/项目/目录]@<用户组名> = <权限><用户名> = <权限>

其中,方框号内部分可以有多种写法:
[/],表示根目录及以下,根目录是svnserve启动时指定的,我们指定为/home/svndata,[/]就是表示对全部版本库设置权限。
[tshop:/] 表示对版本库tshop设置权限;
[tshop:/abc] 表示对版本库tshop中的abc项目设置权限;
[tshop:/abc/aaa] 表示对版本库tshop中的abc项目的aaa目录设置权限;
权限主体可以是用户组、用户或*,用户组在前面加@,*表示全部用户。
权限可以是w、r、wr和空,空表示没有任何权限。


三、启动服务


1、通过命令行


在windwos下启动svn有两种方式,一种是在命令行中直接使用svnserve -d  -r  d:/svn (到根目录即可)这样就可以启动svn了,如下图:




回车后如果不报错,那么证明svn已经成功启动,这时可以在重新打开一个命令行窗口,然后在窗口中输入netstat -na命令来查看相应的端口,如下图:




2、添加到windows服务


这种启动svn的方式会有一个问题,启动svn的命令行窗口一直不能关掉,如果关掉,svn服务就停止了,这样很不方便,因为有这样的问题,所以就有了svn的第二种启动方式了。即把svn的启动命令添加到windows服务中去。操作如下:
在命令行窗口中输入如下命令:

C:\Users\WHP>sc create svnserve binPath= "D:/Program Files (x86)/Subversion/bin/svnserve  -r  d:/svn --service"


然后回车创建。上面命令格式是windows固定的格式。 
sc create用来向windows服务中添加一个服务,sc delete删除windows服务中的一个服务。
binPath是要设置服务命令所在的位置。
-r设置svn服务的根目录位置。
--service意思是要把这个命令以windows服务的形式进行启动,即会向windows的服务中添加一个名字为svnserve的命令。如下图所示:



执行完后,系统返回,[SC] CreateService SUCCESS,表示服务创建成功。


 把相应的服务设置成自动启动。这样svn就在windows服务中添加成功了。


四、客户端


1、安装


先从网站上下载与svn版本相对应的tortoisesvn软件,例子中安装的是1.8.5版本,所以这里也下载1.8.5版本的tortoisesvn。http://tortoisesvn.net/downloads.html 到这个网站下载想对应的版本。


下载完成后进行安装,安装采用傻瓜式的安装,不用改任何东西,安装完成后,在windows的右键菜单中就可以多出一些svn的选项来,如下图所示:




2、checkout


右键点击SVN checkout


url处输入svn://SVNserver IP/仓库名




输入账号、密码即可。


3、文件图标


右键tortoiseSVN->setting->icon oveylays->overlay handlers->start registry editor,会发现Tortoise前缀的一些文件,选中右键重命名,在前面加个空格就可以排到最前面了,如下图:




这时图标还是没有出来,需要重启下explorer.exe进程,

在任务管理器的进程里找到explorer.exe,结束进程,

然后 文件>新建任务(运行...),输入explorer.exe,图标就会显示出来了。




原创粉丝点击