1.    설치에 앞서

다음은 리눅스 환경에서 Subversion 설치과정과 Subversion과 연동한 Trac 설치방법에 대한 글이다. 리눅스 환경은 Ubuntu를 기준으로 하며, 설치에 사용된 버전은 Ubuntu 8.04 Server 이다. Subversion Apache 웹 서버로 서비스되도록 설치할 것이며, Trac mod_python을 이용한 Apache로 서비스되도록 설치할 것이다.

Subversion Python Binding, mod_python, Genshi Python을 이용한 패키지들은 바이너리 버전을 사용하여 설치할 것이다. 이 경우 해당 시스템에 설치된 Python 버전에 맞는 바이너리 버전을 설치해야 한다. 아래 기술된 설치과정에서는 Python 2.5.1.을 설치하고 이에 맞는 버전들을 설치하는 것으로 설명한다. 또한, Subversion 저장소, Trac 프로젝트 명은 개발 프로젝트에 알맞게 적용하여 사용하길 바란다.

 

2.    설치에 전 작업

Ubuntu 8.04 LTS Server를 설치한다. 설치는 어렵지 않으며, 중간에 파티션 설정, IP 설정을 한 후 패키지 설치가 시작되며, 15 ~ 20분 정도 걸렸다. 설치 후 시스템 업그레이드, 파티션 추가, 기존 소스 DB 설치 등의 작업을 하였다.

2.1.      시스템 업그레이드

시스템 설치가 완료된 후 시스템을 최신 상태로 업그레이드한다.

$ sudo apt-get update

$ sudo apt-get dist-upgrade

 

2.2.      파티션 추가

OS 30GB 정도의 마스터 HDD에 설치했으며, 소스 DB는 별도의 HDD에 설정할 계획으로 두 번째 HDD를 마운트하는 작업이 필요했다. /etc/fstab에 적는 이유는 재부팅시 자동으로 마운트되도록 하기 위함이다.

$ sudo fdisk /dev/sdb

$ sudo mkfs.ext3 /dev/sdb1

$ sudo nano /etc/fstab

/dev/sdb1       /var/lib/svn    ext3    relatime,errors=remount-ro      0       1

$ sudo mount /dev/sdb1

 

2.3.      7-zip 압축 유틸 설치

소스 DB 7-zip으로 압축하여 백업해왔기 때문에, 리눅스 환경에서 압축을 해제하기 위해 7-zip 유틸을 설치한다.

$ sudo apt-get install p7zip

  

3.    Apache 설치

$ sudo apt-get install apache2

  

4.    Subversion 설치

$ sudo apt-get install subversion libapache2-svn

  

5.    Trac 설치

$ sudo apt-get install trac libapache2-mod-python python-setuptools

  

6.    Subversion 저장소 만들기

Subversion 저장소를 만들 디렉터리를 만든 후, Subversion 저장소를 만든다.

이 설치과정에서는 /var/lib/svn디렉터리를 만들고, 여기에 Subversion 저장소를 만든다. 해당 저장소 경로는 Trac 프로젝트를 만들 때 이용한다.

압축해제 또는 디렉터리 생성 후 아래와 같이 소유자를 변경해 주어야 커밋이 정상적으로 된다.

$ sudo mkdir -p /var/lib/svn

 

6.1.      기존 소스 DB 설치

압축받은 소스 DB 파일을 /var/lib/svn에 옮긴 후 압축을 푼다. p7zip–d 옵션만 주면 된다.

 

6.2.      신규 저장소 생성

다음 예는 myproject 라는 저장소를 만드는 경우를 가정한 경우이다.

$ sudo mkdir /var/lib/svn/myproejct

$ sudo svnadmin create /var/lib/svn/myproejct

  

7.    Trac 설정

Trac 으로 관리할 프로젝트를 만든다. 이 설치과정에서는 “/var/lib/trac” 디렉터리를 만들고, 여기에 Trac 프로젝트를 만든다. DB SQLite를 사용하며, 소스 저장소는 Subversion을 사용하도록 설정한다.

웹브라우저에서 접근 가능하도록 소유권도 바꿔준다.

$ sudo mkdir –p /var/lib/trac

$ cd /var/lib/trac

$ sudo trac-admin myproject initenv

# 프로젝트 입력

Project Name [My Project]> myproejct

# DB 연결 설정

Database connection string [sqlite:db/trac.db]> 엔터

# 소스 저장소 타입 설정

Repository type [svn]> 엔터

# 저장소 경로

Path to repository [/path/to/repos]> /var/lib/svn/myproejct

$ sudo chown -R www-data.www-data /var/lib/svn

Trac 프로젝트 생성 작업 완료 후 "Congratulations!" 문구가 나오면 성공적으로 생성된 것이다.

 

7.1.      Trac 관리자 설정

Trac 관리자 계정을 설정할 것을 권장한다. 10장에서 만들 계정 중 관리자 역할을 맡을 계정으로 설정한다.

$ sudo trac-admin testproj permission add usr1 TRAC_ADMIN

  

8.    Trac 프로젝트 수정

Trac 프로젝트를 만든 후 다음 사항들을 수정한다. Trac 프로젝트 별 설정은 프로젝트에 conf 디렉터리의 trac.ini 를 수정해서 조정할 수 있다.

 Ÿ   header_logo

프로젝트 홈 URL을 수정해준다. 첫 페이지의 왼쪽 상단의 이미지를 클릭했을 때 이동할 URL을 설정한다.

link 부분을 수정하면 되고, 이미지도 바꾸려면 src 항목을 수정한다.

[header_logo]

alt =

height = -1

link = http://trac.saerom.co.kr/testproj

src = common/trac_banner.png

width = -1

  

9.    dav_svn_conf 수정

$ sudo nano /etc/apache2/mods-available/dav_svn.conf

 

Subversion을 위한 설정

# dav_svn.conf - Example Subversion/Apache configuration

#

# For details and further options see the Apache user manual and

# the Subversion book.

#

# NOTE: for a setup with multiple vhosts, you will want to do this

# configuration in /etc/apache2/sites-available/*, not here.

 

# <Location URL> ... </Location>

# URL controls how the repository appears to the outside world.

# In this example clients access the repository as http://hostname/svn/

# Note, a literal /svn should NOT exist in your document root.

<Location /svn> <- 주석제거

 

  # Uncomment this to enable the repository

  DAV svn <- 주석제거

 

  # Set this to the path to your repository

  #SVNPath /var/lib/svn

  # Alternatively, use SVNParentPath if you have multiple repositories under

  # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).

  # You need either SVNPath and SVNParentPath, but not both.

  SVNParentPath /var/lib/svn <- 주석제거

  SVNListParentPath on <- 추가

 

  # Access control is done at 3 levels: (1) Apache authentication, via

  # any of several methods.  A "Basic Auth" section is commented out

  # below.  (2) Apache <Limit> and <LimitExcept>, also commented out

  # below.  (3) mod_authz_svn is a svn-specific authorization module

  # which offers fine-grained read/write access control for paths

  # within a repository.  (The first two layers are coarse-grained; you

  # can only enable/disable access to an entire repository.)  Note that

  # mod_authz_svn is noticeably slower than the other two layers, so if

  # you don't need the fine-grained control, don't configure it.

 

  # Basic Authentication is repository-wide.  It is not secure unless

  # you are using https.  See the 'htpasswd' command to create and

  # manage the password file - and the documentation for the

  # 'auth_basic' and 'authn_file' modules, which you will need for this

  # (enable them with 'a2enmod').

  AuthType Basic <- 주석제거

  AuthName "Subversion Repository" <- 주석제거

  AuthUserFile /etc/apache2/dav_svn.passwd <- 주석제거

 

  # To enable authorization via mod_authz_svn

  #AuthzSVNAccessFile /etc/apache2/dav_svn.authz

 

  # The following three lines allow anonymous read, but make

  # committers authenticate themselves.  It requires the 'authz_user'

  # module (enable it with 'a2enmod').

  #<LimitExcept GET PROPFIND OPTIONS REPORT>

    Require valid-user <- 주석제거

  #</LimitExcept>

 </Location>*

 

Trac을 위한 설정

다음 파일의 마지막에 추가한다.

$ sudo nano /etc/apache2/sites-available/default

 

# Trac

<VirtualHost *:80>

    ServerName trac.taekgeun.com

 

    <Location />

        SetHandler mod_python

        PythonHandler trac.web.modpython_frontend

        PythonOption TracEnvParentDir /var/lib/trac

        PythonOption TracUriRoot /

    </Location>

 

    <LocationMatch "[^/]+/login">

        AuthType Basic

        AuthName "Trac Authentication"

        AuthUserFile /etc/apache2/dav_svn.passwd

        Require valid-user

    </LocationMatch>

</VirtualHost>

  

10. htpasswd로 사용자 암호 만들기

htpasswd로 사용자 암호를 만든다. 처음 만들 때만 –c 옵션을 주고 생성한다. 두 번째 사용자 부터는 암호파일명과 사용자 아이디만 입력하면 된다.

$ sudo htpasswd –c /etc/apache2/dav_svn.passwd user1

$ sudo htpasswd /etc/apache2/dav_svn.passwd user2

 

 

+ Recent posts