Linux中Centos系统搭建svn服务器

1.1 查看服务端系统环境及版本
服务端:

[root@svnServer ~]# hostname
svnServer
[root@svnServer ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:1B:97:8B  
          inet addr:192.168.3.150  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe1b:978b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:496 errors:0 dropped:0 overruns:0 frame:0
          TX packets:287 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:54717 (53.4 KiB)  TX bytes:51607 (50.3 KiB)

[root@svnServer ~]# uname -r
2.6.32-431.el6.x86_64
[root@svnServer ~]# cat /etc/redhat-release 
CentOS release 6.5 (Final)
[root@svnServer ~]# 
[root@svnServer ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@svnServer ~]#  ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=54 time=53.1 ms
64 bytes from 180.97.33.107: icmp_seq=2 ttl=54 time=54.4 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=54 time=39.4 ms
64 bytes from 180.97.33.107: icmp_seq=4 ttl=54 time=40.3 ms
64 bytes from 180.97.33.107: icmp_seq=5 ttl=54 time=38.9 ms

#确保服务器防火墙、selinux关闭,可以上网。

[root@svnServer ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@svnServer ~]# 
[root@svnServer ~]# getenforce
Disabled

1.2 yum安装subversion软件

[root@svnServer ~]# yum install -y subversion

1.3 查看yum安装subversion软件的安装路径(太多了,这里只拷贝了部分)以及svn的版本信息

[root@svnServer ~]# rpm -ql subversion
/etc/bash_completion.d
/etc/bash_completion.d/subversion
/etc/rc.d/init.d/svnserve
/etc/subversion
/usr/bin/svn
/usr/bin/svnadmin
/usr/bin/svndumpfilter
/usr/bin/svnlook
/usr/bin/svnserve
/usr/bin/svnsync
/usr/bin/svnversion
[root@svnServer bin]# ll /usr/bin/svn*                          #查看与svn服务端相关的命令脚本
-rwxr-xr-x 1 root root 200320 Aug 17  2015 /usr/bin/svn
-rwxr-xr-x 1 root root  62936 Aug 17  2015 /usr/bin/svnadmin
-rwxr-xr-x 1 root root  33880 Aug 17  2015 /usr/bin/svndumpfilter
-rwxr-xr-x 1 root root  62536 Aug 17  2015 /usr/bin/svnlook
-rwxr-xr-x 1 root root  75368 Aug 17  2015 /usr/bin/svnserve
-rwxr-xr-x 1 root root  44712 Aug 17  2015 /usr/bin/svnsync
-rwxr-xr-x 1 root root  11552 Aug 17  2015 /usr/bin/svnversion
[root@svnServer bin]#
[root@svnServer bin]# /usr/bin/svnversion  --version            #执行命令查看svn版本
svnversion, version 1.6.11 (r934486)
   compiled Aug 17 2015, 08:37:43

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

1.4创建svn版本库目录

[root@svnServer bin]# mkdir -p /home/svn/

1.5创建svn版本库(将本地建立的版本库目录和svn服务端关联起来)

[root@svnServer bin]# /usr/bin/svnadmin  create /home/svn/davesvn    # davesvn为版本库名称
[root@svnServer ~]# cd /home/svn/davesvn
[root@svnServer davesvn]# ll
total 24
drwxr-xr-x 2 root root 4096 Jul 16 10:36 conf       #该svn版本库的配置文件所在目录
drwxr-sr-x 6 root root 4096 Jul 16 10:36 db
-r--r--r-- 1 root root    2 Jul 16 10:36 format
drwxr-xr-x 2 root root 4096 Jul 16 10:36 hooks
drwxr-xr-x 2 root root 4096 Jul 16 10:36 locks
-rw-r--r-- 1 root root  229 Jul 16 10:36 README.txt
[root@svnServer davesvn]# 
[root@svnServer conf]# ll /home/svn/davesvn/conf/
total 12
-rw-r--r-- 1 root root 1080 Jul 16 10:36 authz              #账号权限控制文件
-rw-r--r-- 1 root root  309 Jul 16 10:36 passwd             #账号密码文件
-rw-r--r-- 1 root root 2279 Jul 16 10:36 svnserve.conf      #svn服务配置文件
[root@svnServer conf]

1.6设置账号密码(可以多个)

设置账号密码是在[users]块中添加用户和密码,格式:用户名 = 密码
[root@svnServer conf]# vi /home/svn/davesvn/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
dave = dave123456
yuki= yuki123456
helen = helen123456

1.7 设置账号对于目录(项目)的具体权限

[root@svnServer ~]# egrep -v '#|^$' /home/svn/davesvn/conf/authz     
[aliases]
[groups]
admin = dave        #组名 = 组员 (多个组员用逗号隔开)
dev = helen,yuki
[davesvn:/]     #这是设置针对此版本库下的目录(任何项目)的访问权限
@admin = rw     #@组名 = 可读/可写/可执行(若为空,表示没有任何权限)
@dev = r
[root@svnServer ~]#

1.8修改svnserve.conf文件

打开下面的几个进行注释:
[root@svnServer ~]# vi /home/svn/davesvn/conf/svnserve.conf 
anon-access = read              #匿名用户可读
auth-access = write             #授权用户可写
password-db = passwd            #使用哪个文件作为账号文件
authz-db = authz                #使用哪个文件作为权限文件
realm = /home/svn/davesvn       #认证空间名,版本库所在目录#指定版本库的认证域,即在登录时提示的认证域名称。若两个版本库的认证域相同,建议使用相同的用户名口令数据文件。

1.9启动svn版本库

[root@svnServer ~]#/usr/bin/svnserve  -d -r /home/svn/  #启动svn版本库时只到其所在目录,不包括他本身
[root@svnServer ~]# ps -ef |grep svn
root       1975      1  0 12:05 ?        00:00:00 /usr/bin/svnserve -d -r /home/svn/davesvn
root       1977   1917  0 12:05 pts/1    00:00:00 grep svnserve
[root@svnServer ~]#
-d表示后台运行
-r 指定根目录是 /home/svn

1.10 在Windows上安装svn客户端(TortoiseSVN)进行测试

svn://192.168.3.150/davasvn 

猜你喜欢

转载自blog.csdn.net/yuki5233/article/details/75907432