CentOS 서브버전 서버 설치 및 설정 (svn)

  다른 뜻에 대해서는 우분투 서브버전 설치 문서를 참조하십시오.

1 개요[ | ]

서브버전 설치 및 설정하기
CentOS 서브버전 설치
CentOS SVN 설치
  • 리눅스 subversion 패키지는 서버 + 클라이언트
  • 이 문서에서는 저장소(repository)의 상위 디렉토리를 /repos으로 한 예이다.
  • 해당 디렉토리 아래에 저장소(디렉토리)를 여러 개 둘 수 있다(예: proejct1, project2...).

2 설치 확인[ | ]

[root@zetawiki ~]# svn
-bash: svn: command not found
[root@zetawiki ~]# rpm -qa | grep subversion
[root@zetawiki ~]# yum list subversion
... (생략)
Available Packages
subversion.i686                              1.6.11-10.el6_5                             base
subversion.x86_64                            1.6.11-10.el6_5                             base
→ 설치되어 있지 않으며, yum을 통해 설치가능하다.

3 설치[ | ]

[root@zetawiki ~]# yum install subversion
... (생략)
=============================================================================================
 Package               Arch              Version                       Repository       Size
=============================================================================================
Installing:
 subversion            x86_64            1.6.11-10.el6_5               base            2.3 M
Installing for dependencies:
 neon                  x86_64            0.29.3-3.el6_4                base            119 k
 pakchois              x86_64            0.4-3.2.el6                   base             21 k

Transaction Summary
=============================================================================================
Install       3 Package(s)

Total download size: 2.4 M
Installed size: 12 M
Is this ok [y/N]: y
... (생략)
Installed:
  subversion.x86_64 0:1.6.11-10.el6_5                                                        

Dependency Installed:
  neon.x86_64 0:0.29.3-3.el6_4                 pakchois.x86_64 0:0.4-3.2.el6                

Complete!

4 저장소 생성[ | ]

서버 1대에 저장소를 여러 개 생성할 수 있다. 프로젝트 저장소 폴더들이 /repos 아래에 있도록 설정할 것이다.

명령어
mkdir /repos
cd /repos
svnadmin create --fs-type fsfs 저장소명
ll
실행 예시
[root@zetawiki ~]# mkdir /repos
[root@zetawiki ~]# cd /repos
[root@zetawiki repos]# svnadmin create --fs-type fsfs project1
[root@zetawiki repos]# ll
total 4
drwxr-xr-x. 6 root root 4096 Jun  1 09:27 project1
  • 여러 프로젝트를 담기 위해 반드시 저장소를 여러 개 만들 필요는 없다. 저장소 폴더 아래에 다시 프로젝트별 폴더들을 만들어 관리하면 되기 때문이다.
  • 그렇다면 언제 저장소를 여러 개 만들어야 할까? 하나의 저장소는 하나의 사용자 권한 설정을 가지고 있다. 그러므로 사용자들의 권한이 구분되어야 할 때 저장소를 여러 개 두는 것이 좋다.

5 /etc/sysconfig/svnserve 생성[ | ]

이 파일을 생성해주어야 service svnserve start/stop이 가능하다.[1]

명령어
echo 'OPTIONS="--threads --root 저장소최상위폴더"' > /etc/sysconfig/svnserve
cat /etc/sysconfig/svnserve
실행예시
[root@zetawiki ~]# echo 'OPTIONS="--threads --root /repos"' > /etc/sysconfig/svnserve
[root@zetawiki ~]# cat /etc/sysconfig/svnserve
OPTIONS="--threads --root /repos"

6 svnserve.conf 수정[ | ]

svnserve.conf 파일을 svnserve.conf.old 로 변경하여 보존해두고 새로 작성한다.

명령어
cd /repos/project1/conf/
cat svnserve.conf
mv svnserve.conf svnserve.conf.old
echo '[general]' > svnserve.conf
echo 'anon-access = none' >> svnserve.conf
echo 'auth-access = write' >> svnserve.conf
echo 'password-db = passwd' >> svnserve.conf
echo 'authz-db = authz' >> svnserve.conf
cat svnserve.conf
실행예시
[root@zetawiki ~]# cd /repos/project1/conf/
[root@zetawiki conf]# cat 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.)
... (생략)
[root@zetawiki conf]# mv svnserve.conf svnserve.conf.old
[root@zetawiki conf]# echo '[general]' > svnserve.conf
[root@zetawiki conf]# echo 'anon-access = none' >> svnserve.conf
[root@zetawiki conf]# echo 'auth-access = write' >> svnserve.conf
[root@zetawiki conf]# echo 'password-db = passwd' >> svnserve.conf
[root@zetawiki conf]# echo 'authz-db = authz' >> svnserve.conf
[root@zetawiki conf]# cat svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
→ 비로그인 접속자는 권한 없음, 로그인하면 쓸 수 있음, passwd와 authz 파일을 사용함.

7 계정 설정[ | ]

  • svn는 OS계정이 아니라 자체 계정을 사용한다.
  • 해당 저장소의 conf 디렉토리에 있는 passwd를 편집하여 계정을 등록한다.
  • 패스워드 분실시에도 이 파일을 열어보면 된다.
  • passwd 파일을 passwd.old 로 이름을 변경하여 보존해두고 새로 작성한다.
[root@zetawiki conf]# mv passwd passwd.old
[root@zetawiki conf]# vi passwd
[users]
testuser1 = P@ssw0rd
testuser2 = P@ssw0rd

8 (optional) 권한 없음 오류시[ | ]

[/]
testuser1 = rw
testuser2 = rw

9 서비스 시작[ | ]

/etc/sysconfig/svnserve 파일을 설정해두었기 때문에 service로 시작/중지를 할 수 있다.

[root@zetawiki repos]# service svnserve start
Starting svnserve:                                         [  OK  ]
[root@zetawiki repos]# ps -ef | grep svnserve | grep -v grep
root      2581     1  0 11:12 ?        00:00:00 /usr/bin/svnserve --daemon --pid-file=/var/run/svnserve.pid --threads --root /repos
[root@zetawiki repos]# netstat -anp | grep svnserve
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      2581/svnserve
→ 기본 포트인 3690 포트로 서비스 중. (다른 포트로 변경하려면 /etc/sysconfig/svnserve를 수정해야 한다.)

여기까지 되었다면 설정이 완료된 것이다. 다른 컴퓨터에서 SVN 클라이언트로 접속하면 된다.[2] 접속 URL은 svn://서버주소/proejct1 이다.

10 재부팅시 자동시작 설정[ | ]

[root@zetawiki repos]# chkconfig --list svnserve
svnserve       	0:off	1:off	2:off	3:off	4:off	5:off	6:off
[root@zetawiki repos]# chkconfig svnserve on
[root@zetawiki repos]# chkconfig --list svnserve
svnserve       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
→ 재부팅시에 svnserve 서비스가 자동으로 시작될 것이다.

11 (저장소 삭제)[ | ]

주의! 저장소를 삭제하고 싶을 때만 이 문단을 참고하시라. 만들 때는 svnadmin으로 하였지만, 지울 때는 그냥 저장소 폴더를 지우면 된다.

명령어
service svnserve stop
rm -rf /repos/project1
ll
실행예시
[root@zetawiki ~]# service svnserve stop
Stopping svnserve:                                         [  OK  ]
[root@zetawiki ~]# rm -rf /repos/project1
[root@zetawiki ~]# ll
total 0
→ 깔끔하게 지워졌다

12 같이 보기[ | ]

13 주석[ | ]

  1. /etc/init.d/svnserve 파일이 이 파일을 참조하기 때문이다.
  2. 물론 방화벽 등 다른 문제가 없다는 가정 하에 그렇다.
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}