SVN安裝與配置

1、系統環境

[root@localhost alan]# cat /etc/redhat-release
CentOS release 6.5 (Final)

  1. 檢查svn是否已經安裝
[root@localhost alan]# rpm -aq subversion
subversion-1.6.11-15.el6_7.x86_64

    2.如果沒有以上結果安裝svn

yum -y install subversion    

2、配置並啓動svn

     建立svn版本數據庫存儲根目錄

[root@localhost alan]# mkdir -p /local/svndata
[root@localhost alan]# mkdir -p /local/svnpasswd

    啓動svn

    svnserve -d -r /local/svndata/

    查看是否啓動

[root@localhost /]# svnserve -d -r /local/svndata/
[root@localhost /]# ps -ef|grep svn
root       3431      1  0 23:46 ?        00:00:00 svnserve -d -r /local/svndata/
root       3438   2988  0 23:47 pts/1    00:00:00 grep svn
[root@localhost /]# netstat -lnt|grep 3690
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN
[root@localhost /]# netstat -lntup|grep svn
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      3431/svnserve
[root@localhost /]# netstat -lntup|grep 3690
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      3431/svnserve
[root@localhost /]# lsof -i tcp:3690
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
svnserve 3431 root    3u  IPv4  26482      0t0  TCP *:svn (LISTEN)
[root@localhost /]# lsof -i :3690
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
svnserve 3431 root    3u  IPv4  26482      0t0  TCP *:svn (LISTEN)

    創建一個新的subversion項目sadoc。

[root@localhost /]# svnadmin create /local/svndata/sadoc    

    用tree命令查看結構,如果沒有安裝tree命名,先安裝tree命令

# tree /local/svndata/
/local/svndata/
└── sadoc
    ├── 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

11 directories, 28 files

    配置svnserve.conf

[root@localhost /]# cd /local/svndata/
[root@localhost svndata]# cd sadoc/conf/

    修改anon-access = none

    auth-access = write

    password-db去掉註釋修改爲 password-db = /local/svnpasswd/passwd  

    authz-db去掉註釋修改爲authz-db = /local/svnpasswd/authz

    與備份文件對比產看修改的部分

[root@localhost conf]# diff svnservecopy.conf svnserve.conf
2c2
< ### use it to allow access to this repository.  (If you only allow
---
> ## use it to allow access to this repository.  (If you only allow
12,13c12,13
< # anon-access = read
< # auth-access = write
---
> anon-access = read
> auth-access = write
20c20
< # password-db = passwd
---
> password-db = /local/svnpasswd/passwd
27c27
< # authz-db = authz
---
> authz-db = /local/svnpasswd/authz  

    拷貝authz、passwd文件到/local/svnpasswd

[root@localhost conf]# cp authz passwd /local/svnpasswd/ 

    修改文件權限

[root@localhost svnpasswd]# chmod 7700 * 

    設置用戶名和密碼

[root@localhost svnpasswd]# vim passwd

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
alan = alan123
amber = amber123


~
"passwd" 10L, 341C written 

    設置用戶權限

[root@localhost svnpasswd]# vim 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,


### 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
sagroup = alan,amber
[sadoc:/]
alan = rw
amber = r
@sagroup = r
"authz" 37L, 1144C written
[root@localhost svnpasswd]#

    重新啓動svn,並查看進程

[root@localhost svnpasswd]# pkill svnserve
[root@localhost svnpasswd]# svnserve -d -r /local/svndata/
[root@localhost svnpasswd]# ps -ef|grep svn
root       4996      1  0 03:37 ?        00:00:00 svnserve -d -r /local/svndata/
root       5006   2988  0 03:38 pts/1    00:00:00 grep svn

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章