1:安装svn

apt-get install subversion

2. 开启svn服务器

svnserve -d

检查是否开启:ps aux | grep svnserve

若出现如下内容:

wkr 6537 0.0 0.0 13784 956 ? Ss 16:18 0:00 svnserve -d
wkr 7593 0.0 0.0 5784 864 pts/0 S+ 21:57 0:00 grep –color=auto svnserve

表示服务已开启。(注意:一定要有第1行,只有第2行说明服务未启动)

停止svn服务:  killall svnserve

3. 建立仓库

svnadmin create /home/svnrepos
理论上,仓库可以建立在任何目录中。

注意:重启svnserve  执行 svnserve -d  -r /home

这样在eclipse客户端把工程导入svn的时候 url需要填写

svn://ip/svnrepos/project_name 

如果启动的时候带如下参数:svnserve -d  -r /home/svnrepos

客户端:svn://ip/project_name  这样子会报错。验证失败

4. 修改配置文件

编辑 svnserve.conf

vi /home/svnrepos/conf/svnserve.conf

 把anon-access = read 改为 none,auth_access = write 

 password-db = passwd  authz-db = authz 的注释去掉,还有[general]的注释也要去掉(这个默认没有注释)。
注:当你去掉注释的时候,不要简单的把前面的#去掉,要把前面的空格一块去掉,不然在Eclipse中使用的时候会出现配置文件格式错误的问题。

注意:如果authz-db = authz 这个注释掉了,则不需要配置/home/svnrepos/conf/authz

5. 修改帐户文件

vi  /home/svnrepos/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]
# harry = harryssecret
# sally = sallyssecret
user1 = pass1  # 输入你定义的用户名和密码,密码显然没有加密

6. 修改授权文件

vi /home/svnrepos/conf/authz

修改或者输入下面2行:

[svnrepos:/]      ##格式为    版本库名称  + :/
user1 = rw

其中,repos1是仓库名称,user1是用户名,rw代表读写。

喜欢这篇文章?

点击后弹出微信二维码,可自选金额或输入其他金额