본문 바로가기

study

CentOS 7에 Subversion(SVN) 설치하고 저장소 만들기

https://hellowoori.tistory.com/54

 

CentOS 7에 Subversion(SVN) 설치하고 저장소 만들기

CentOS 7에 Subversion(SVN) 설치하고 저장소 만들기참고사이트https://blog.hanumoka.net/2018/04/30/centOs-20180430-centos-install-subversion/https://okkks.tistory.com/975https://zetawiki.com/wiki/CentOS_서브버전_서버_설치_및_설정_(s

hellowoori.tistory.com

CentOS 7에 Subversion(SVN) 설치하고 저장소 만들기

 

잠깐! 가상머신 사용시, 포트 포워딩 설정이 필요합니다.










1. CentOS 7 Subversion설치

아래 명령어를 입력해서 설치 할 수 있는 Subversion을 확인합니다.

yum list subversion

 

실행결과

 

아래 명령어로 Subversion을 설치합니다.

yum install -y subversion

 

설치확인

또는

 

 

2. Subversion의 저장소들을 저장할 폴더 생성 및 설정

Subversion에서 원격저장소를 저장할 최상위 폴더 생성합니다.

저는 CentOS root 경로에 svn_repos 라는 폴더를 만들었습니다!

 

cd /
cd mkdir svn_repos

 

[root@localhost /]# ls
bin   dev home  lib64 mnt proc  run srv sys  usr
boot  etc lib   media opt root  sbin svn_repos  tmp  var

 

svnserve 파일에 방금 생성한 svn 저장소를 관리할 폴더를 지정합니다.

/etc/sysconfig/svnserve 파일을 vi로 열고 수정합니다.

(이 파일을 생성해주어야 service svnserve start/stop/restart가 가능하다고 합니다)

vi /etc/sysconfig/svnserve

 

# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
OPTIONS="--threads --root /svn_repos"



3. Subversion 서비스 포트 방화벽 해제 설정

아래 명령어를 통해 Subversion의 서비스 포트를 리눅스 방화벽에서 제외합니다.

SVN의 기본 포트는 3960 입니다.

sudo firewall-cmd --permanent --zone=public --add-port=3690/tcp
sudo firewall-cmd --reload



4. Subversion을 실행

Subversion 실행 관련 명령어는 다음과 같습니다.

systemctl start svnserve.service   #실행
systemctl stop svnserve.service    #중지
systemctl restart svnserve.service #재실행

또는

 

SVN 서비스 실행 및 확인

[root@localhost ~]# systemctl start svnserve.service
[root@localhost ~]# ps -ef | grep svn
root      8827 1  0 19:28 ?     00:00:00 /usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid -r /svn_repos
root      9373 7879  0 19:28 pts/2    00:00:00 grep --color=auto svn
[root@localhost ~]# netstat -anp | grep svnserve
tcp        0 0 0.0.0.0:3690            0.0.0.0:* LISTEN   8827/svnserve
[root@localhost ~]

 

  • ps -ef | grep svn : 서브버전의 프로세스의 동작여부를 확인
  • netstat -anp | grep svnserve : 서브버전의 서비스 포트를 확인(기본적으로 3690 포트 사용)



5. Subversion에 테스트 저장소 생성

지금까지 SVN 설치와 실행을 해보았습니다.

이제 실제 프로젝트의 단위가 될 SVN 저장소를 만들어봅시다.

 

/svn_repos 디렉토리 내에 저장소를 만듭니다.

svnadmin create --fs-type fsfs 저장소명

 

 

② 방금 생성한 TestRepo1 저장소의 svnserve.conf 파일을 수정합니다.

이 파일은 SVN 서버를 실행할 때, 해당 저장소에 접근할 수 있는 권한을 관리하는 설정파일 입니다.

svnserve.conf저장소명/conf/svnserve.conf 에 있습니다.

 

기존 파일을 열어 anon-access, auth-access, password-db, authz-db 항목을 찾아 수정합니다.

만약 해당 설정에 주석처리가 되어있다면 주석을 제거합니다.

### 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.)

### Visit http://subversion.apache.org/ for more information.

[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = read
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.  If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above.  Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none

[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256

 

  • anon-access : 로그인 하지 않은 사용자(비인증 계정)에게 접근권한을 설정하는 부분. read, write, none 세가지 값을 설정 할 수 있다.
  • auth-access :  로그인한 사용자(인증 계정)에 대한 접근 권한을 설정하는 부분. read, write, none 세가지 값을 설정 할 수 있다.
  • passwd-db : 저장소에 접근할 사용자 계정과 비밀번호를 관리할 파일의 이름을 지정하는 설정이다. 기본 파일명은 passwd 이며, 다른 이름을 사용할 수 있다.
  • authz-db : 파일과 디렉토리에 대한 접근 권한을 관리하는 파일의 이름을 지정하는 설정이다. 기본 파일명은 authz 이며, 다른 이름을 사용할 수 있다.
  • realm :  인증할 때 보여주는 간단한 저장소 설명이며, 생략 가능하다.
  • none : 접근 권한 없음, read : 읽기 권한, write : 쓰기 권한

 

저장소를 생성할 때 authz, passwd 파일도 함께 생성되어있는 것을 확인 할 수 있습니다.



6. 저장소에 접근할 계정정보 추가

① passwd 에 저장소에 접근할 계정정보 추가

위의 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]
admin = admin

 

admin 이라는 계정에 admin 이라는 비밀번호를 설정했습니다.

아이디 = 비밀번호의 형태로 사용자명과 비밀번호를 추가할 수 있습니다.

 

② authz(권한) 파일 저장소에 접근할 계정정보 추가

authz 파일을 열어 아래처럼 수정합니다.

[/]
* = r #TestRepo1저장소의 루트경로에 모든 사용자가 read 할수 있는 권한을 부여
root = rw #TestRepo1저장소의 루트경로에 root 계정은 read, write 권한 부여
admin = rw #TestRepo1저장소의 루트경로에 admin 계정은 read, write 권한 부여

 

③ 설정이 끝났다면, svnserve 데몬을 재시작 합니다

혹은 service svnserve restart 로도 재시작할 수 있습니다.



7. SVN 저장소 확인

svn list svn://ip 또는 도메인 주소/저장소명
svn info svn://ip 또는 도메인 주소/저장소명

 

 

! SVN 인증 확인에 실패했다면, svnserve.conf, passwd, authz 설정 부분을 다시 확인해야합니다.

(“6. 저장소에 접근할 계정정보 추가” 참고)

 

! SELinux가 활성화되어있는 경우, SVN 저장소 접근이 안됩니다.

이 경우, CentOS 7 SeLinux 를 disabled 합니다.

sestatus 로 SELinux 의 상태를 확인할 수 있습니다.

 

만약  활성화(enabled)되어있는 경우라면

/etc/selinux/config 파일을 열어 수정합니다.

[root@localhost conf]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted



8. SVN trunk, tags, branches 기본 디렉토리 만들기

svn mkdir svn://127.0.0.1/TestRepo1/trunk

 

svn mkdir 명령어를 사용할 수 없는 경우, 아래와 같은 메시지가 나옵니다.

이를 해결하기 위해서

~/.bash_profile 맨 아래에 내용을 추가해주어야합니다.

cd ~
vi .bash_profile

 

:wq로 저장후

source .bash_profile



CentOS 7 vim 설치 (만약, vim이 없다는 에러가 나올 경우)
yum을 이용하여 vim 설치
 

vim 설정
 

 

:wq로 저장후 source를 이용해 프로필을 적용
 

 

svn mkdir 명령어로 trunk, tags, branches를 각각 만듭니다.

 

디렉토리(trunk, tags, branches)가 잘 만들어졌는지 확인합니다.

 

 

9. SVN 소스 내려받기

SVN에서 소스를 내려받습니다.

svn co svn://ip 또는 도메인 주소/저장소명

또는

svn checkout svn://ip 또는 도메인 주소/저장소명

(co는 checkout의 줄임말....)

 

저는 LocalRepo1 디렉토리를 만들면서 이곳에 체크아웃 해보겠습니다.



추가. 서버동작시 SVN 서비스 자동 실행하기

systemctl enable svnserve.service

 

 

추가. 저장소 삭제

만들 때는 svnadmin 으로 생성했지만, 지울 때는 그냥 저장소 폴더를 지우면 됩니다.

service svnserve stop
rm -rf /svn_repos/TestRepo1



추가. SVN E220001 오류

Error: 220001 (Item is not readable) Description: Unreadable path encountered; access denied

 

SVN E220001 오류가 발생 했을 때 SVN Server 설정 파일중에서

 

svnserve.conf 파일을 아래와 같이 설정해줍니다.

[general]
anon-access = none

 

 

 

'study' 카테고리의 다른 글

php db접속  (0) 2023.03.09
맥북 M1 scss 에러 해결방법  (0) 2023.02.23
CentOS SVN 설치 및 설정  (0) 2022.12.30
[리눅스] 유저(User) 생성 / 삭제 / 수정 방법  (0) 2022.04.04
PHP7 문법적 변경점 정리  (0) 2022.03.03