SVN 服务器搭建步骤及使用实战

SVN 服务器搭建步骤及使用实战

一、实验环境:

[root@node02 ~]# uname -a

Linux node02 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[root@node02 ~]# cat /etc/RedHat-release 

CentOS release 6.6 (Final)

[root@node02 ~]#

[root@node02 ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:DF:59:C7  

          inet addr:192.168.112.129  Bcast:192.168.112.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fedf:59c7/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:37078 errors:0 dropped:0 overruns:0 frame:0

          TX packets:21925 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:26850825 (25.6 MiB)  TX bytes:3241796 (3.0 MiB)

[root@node02 ~]# 

二、SVN Apache安装

这里我直接用yum安装

[root@node02 ~]# yum install subversion apr apr-util   mod_dav_svn  httpd

[root@node02 ~]#

[root@node02 ~]# rpm -qa subversion apr apr-util   mod_dav_svn  httpd

apr-util-1.3.9-3.el6_0.1.x86_64

subversion-1.6.11-15.el6_7.x86_64

apr-1.3.9-5.el6_2.x86_64

httpd-2.2.15-55.el6.centos.2.x86_64

mod_dav_svn-1.6.11-15.el6_7.x86_64

[root@node02 ~]# 

查看目录结构:

[root@node02 ~]# tree /etc/httpd/

/etc/httpd/

├── conf

│   ├── httpd.conf

│   └── magic

├── conf.d

│   ├── passwd

│   ├── README

│   ├── subversion.conf

│   ├── subversion.conf.bak

│   └── welcome.conf

├── logs -> ../../var/log/httpd

├── modules -> ../../usr/lib64/httpd/modules

└── run -> ../../var/run/httpd

5 directories, 7 files

[root@node02 ~]# 

目录配置:

(1)svn目录配置

[root@node02 ~]# mkdir -p /application/svn/svndata

[root@node02 ~]# mkdir -p /application/svn/svndata/svnpasswd/

[root@node02 ~]# 

注意:这里的/application/svn/svndata是SVN的项目目录,该目录下就是我们平常的项目存放位置

目录/application/svn/svndata/svnpasswd/是用用户认证和权限文件存放路径,结构如下:

[root@node02 ~]# tree /application/svn/svndata/svnpasswd/

/application/svn/svndata/svnpasswd/

├── authz

└── passwd

0 directories, 2 files

[root@node02 ~]# 

(2)启动SVN

[root@node02 ~]# svnserve -d -r /application/svn/svndata/

[root@node02 ~]# ps -ef|grep svn

root     13512     1  0 18:48 ?        00:00:00 svnserve -d -r /application/svn/svndata/

root     14068  1977  0 22:49 pts/0    00:00:00 grep svn

[root@node02 ~]# netstat -lnput|grep svn

tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      13512/svnserve      

[root@node02 ~]# 

(3)创建项目

[root@node02 ~]# svnadmin create /application/svn/svndata/project001

[root@node02 ~]# tree /application/svn/svndata/project001/

/application/svn/svndata/project001/

├── conf

│   ├── authz

│   ├── passwd

│   └── svnserve.conf

├── db

│   ├── current

│   ├── format

│   ├── fsfs.conf

│   ├── fs-type

│   ├── min-unpacked-rev

│   ├── rep-cache.db

│   ├── revprops

│   │   └── 0

│   │       └── 0

│   ├── revs

│   │   └── 0

│   │       └── 0

│   ├── transactions

│   ├── txn-current

│   ├── txn-current-lock

│   ├── txn-protorevs

│   ├── uuid

│   └── write-lock

├── format

├── hooks

│   ├── post-commit.tmpl

│   ├── post-lock.tmpl

│   ├── post-revprop-change.tmpl

│   ├── post-unlock.tmpl

│   ├── pre-commit.tmpl

│   ├── pre-lock.tmpl

│   ├── pre-revprop-change.tmpl

│   ├── pre-unlock.tmpl

│   └── start-commit.tmpl

├── locks

│   ├── db.lock

│   └── db-logs.lock

└── README.txt

10 directories, 28 files

[root@node02 ~]# 

(3)修改项目配置文件

[root@node02 ~]# cd /application/svn/svndata/project001

[root@node02 project001]# ls

conf  db  format  hooks  locks  README.txt

[root@node02 project001]# 

[root@node02 project001]# cd conf/

[root@node02 conf]# ll

total 12

-rw-r--r-- 1 root root 1080 Dec 31 22:53 authz

-rw-r--r-- 1 root root  309 Dec 31 22:53 passwd

-rw-r--r-- 1 root root 2279 Dec 31 22:53 svnserve.conf

[root@node02 conf]# 

[root@node02 conf]# vim svnserve.conf

anon-access = none         ------------------->12行去掉注释

auth-access = write        ------------------->13行去掉注释

password-db = /application/svn/svndata/svnpasswd/passwd ------------>18行去掉注释

authz-db = /application/svn/svndata/svnpasswd/authz ---------------->25行去掉注释

[root@node02 conf]#

提示:svnserve.conf中每个参数都要定格写,开头不能有空格

或者执行如下命令修改:

[root@node02 conf]# sed -i 's/# anon-access = read/anon-access = none/g' svnserve.conf  

[root@node02 conf]# sed -i 's/# auth-access = write/auth-access = write/g' svnserve.conf  

[root@node02 conf]# sed -i 's%# password-db = passwd%password-db = /application/svn/svndata/svnpasswd/passwd%g' svnserve.conf

[root@node02 conf]# sed -i 's%# authz-db = authz%authz-db = /application/svn/svndata/svnpasswd/authz%g' svnserve.conf  

修改完之后可以运行如下命令进行检查

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/679a668307474be7542bc5e79284d555.html