SVN 서버 설정

OS/리눅스 & 유닉스 2014. 11. 3. 15:49


SVN 서버 설정

 
Yes check.svgCentOS 6.3에서 테스트되었습니다.

개요

서브버전 설치 및 설정하기
  • 이 문서에서는 저장소(repository)의 상위 디렉토리를 /svn으로 한 예이다.
  • 해당 디렉토리 아래에 저장소(디렉토리)를 여러 개 둘 수 있다(예: repo1, repo2...).

사전 작업

저장소 생성

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

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

/etc/sysconfig/svnserve 생성

 /etc/sysconfig/svnserve 문서를 참고하십시오.

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

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

svnserve.conf 수정

 svnserve.conf 문서를 참고하십시오.

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

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

계정 설정

 /svn/repo1/conf/passwd 문서를 참고하십시오.
  • svn는 OS계정이 아니라 자체 계정을 사용한다.
  • 해당 저장소의 conf 디렉토리에 있는 passwd를 편집하여 계정을 등록한다.
  • 패스워드 분실시에도 이 파일을 열어보면 된다.
  • passwd 파일을 passwd.old 로 이름을 변경하여 보존해두고 새로 작성한다.
명령어
cat passwd
mv passwd passwd.old
echo '[users]' > passwd
echo 'testuser1 = P@ssw0rd' >> passwd
echo 'testuser2 = P@ssw0rd' >> passwd
cat passwd
실행예시
[root@jmnote conf]# cat 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
[root@jmnote conf]# mv passwd passwd.old
[root@jmnote conf]# echo '[users]' > passwd
[root@jmnote conf]# echo 'testuser1 = P@ssw0rd' >> passwd
[root@jmnote conf]# echo 'testuser2 = P@ssw0rd' >> passwd
[root@jmnote conf]# cat passwd
[users]
testuser1 = P@ssw0rd
testuser2 = P@ssw0rd

서비스 시작

 svnserve 시작/중지 문서를 참고하십시오.

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

[root@jmnote svn]# service svnserve start
Starting svnserve:                                         [  OK  ]
[root@jmnote svn]# 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 /svn
[root@jmnote svn]# 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://서버주소/repo1 이다.

재부팅시 자동시작 설정

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

(저장소 삭제)

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

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

같이 보기

주석

  1. 이동 /etc/init.d/svnserve 파일이 이 파일을 참조하기 때문이다.
  2. 이동 물론 방화벽 등 다른 문제가 없다는 가정 하에 그렇다.


출처 - http://jmnote.com/wiki/SVN_%EC%84%9C%EB%B2%84_%EC%84%A4%EC%A0%95#cite_note-2

'OS > 리눅스 & 유닉스' 카테고리의 다른 글

SVN 명령어  (0) 2014.11.03
SVN 권한 설정  (0) 2014.11.03
방화벽 오픈/해제  (0) 2014.11.03
mail 전송의 원리  (0) 2014.09.18
큐메일  (0) 2014.09.18
: