작성자 : 김용복 (ruo91@yongbok.net) – 2010/03/24 PM 1:45
원제목 : CentOS – Apache + SVN + Trac 연동
환 경 : CentOS 5.4 Final
설치순 : Apache – > Subversion -> mod_dav_svn -> Trac

svn 설치시 기본 저장소는 /var/www/svn 으로 하며 trac 은 /var/www/trac 로 사용합니다.

1. Apache 설치
아파치가 설치 되어 있는지 확인 합니다. (CentOS 5.4에서는 자동 설치 되어 있는듯..)

[root@ruo91 ~]# rpm -aq | grep httpd
system-config-httpd-1.3.3.3-1.el5
httpd-2.2.3-31.el5.centos

만약 설치가 안된 경우라면 설치를 진행 합니다.

[root@ruo91 ~]# yum install -y httpd
[root@ruo91 ~]# chkconfig httpd on

2. subversion (SVN) 설치
SVN 을 설치하게 되면 의존성 패키지인 neon 과 perl-URI 가 같이 설치 됩니다.

[root@ruo91 ~]# yum install -y subversion

 

subversion 스크립트 생성

[root@ruo91 ~]# touch /etc/init.d/subversion

[root@ruo91 ~]# chmod +x /etc/init.d/subversion

[root@ruo91 ~]# vi /etc/init.d/subversion

#!/bin/bash
. /etc/rc.d/init.d/functions

[ -x /usr/bin/svnserve ] || exit 1

RETVAL=0
prog=”svnserve”
desc=”Subversion server”
OPTIONS=”–threads –root /var/www/svn”

start() {
echo -n $”Starting $desc ($prog): ”
daemon $prog -d $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
echo
}

stop() {
echo -n $”Shutting down $desc ($prog): ”
killproc $prog
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
RETVAL=$?
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|condrestart}”
RETVAL=1
esac

exit $RETVAL
EOF

 

3. Apache + SVN 연동
아파치와 SVN을 연동하기 위해서 mod_dav_svn 을 설치 합니다.

[root@ruo91 ~]# yum install -y mod_dav_svn

설치가 완료 되면 httpd/modules 디렉토리에 두가지의 모듈이 있는걸 확인 할수 있습니다.

[root@ruo91 ~]# find /usr/lib/ | grep svn
/usr/lib/httpd/modules/mod_dav_svn.so
/usr/lib/httpd/modules/mod_authz_svn.so

또한 httpd.conf 에 위 두가지 모듈을 따로 추가 하지 않아도 이미 subversion.conf 에 있기 때문에 몇가지 설정 만 해주시면 됩니다.

svn 디렉토리와 SVN 사용자 계정을 생성하고 아파치 계정이 접근할수 있도록 변경 합니다.

[root@ruo91 ~]# mkdir -p /var/www/svn
[root@ruo91 ~]# cd /var/www/svn
[root@ruo91 ~]# svnadmin create ruo91
[root@ruo91 ~]# chown -R apache.apache ruo91

SVN 사용자의 인증 패스워드 파일을 생성합니다.

[root@ruo91 ~]# htpasswd -cm [패스워드 파일] [사용자]

[root@ruo91 ~]# htpasswd -cm /var/www/svn/user-ruo91-passwd ruo91
New password:
Re-type new password:
Adding password for user ruo91

옵션 설명

-c : 새로운 파일 생성
-m : MD5 로 암호화

다른 새로운 사용자 추가 할때는 아래와 같이 -c 옵션을 빼고 추가 해주면 됩니다.

[root@ruo91 ~]# htpasswd -m /var/www/svn/user-ruo911-passwd ruo911

인증할 사용자를 설정 해주기 위해 authz, passwd, svnserve.conf 파일을 설정 합니다.

[root@ruo91 ~]# vi /var/www/svn/ruo91/conf/authz
[groups]
authz = ruo91
@authz = rw

[root@ruo91 ~]# vi /var/www/svn/ruo91/conf/passwd
[users]
ruo91 = 123456

[root@ruo91 ~]# vi /var/www/svn/ruo91/conf/svnserve.conf
[general]
anon-access = read # 익명접근시 저장소 읽기 권한
auth-access = write # 인증된 사용자의 경우 쓰기 권한
password-db = passwd # 인증에 사용될 사용자의 비밀번호 파일
authz-db = authz # 인증에 사용될 사용자 그룹 파일
realm = My First Repository # 저장소에 표시될 이름(?) 또는 저장소 간략 설명(?)

subversion 설정을 합니다.

[root@ruo91 ~]# vi /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /repos>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “Authorization!!”
AuthUserFile /var/www/svn/user-ruo91-passwd
Require valid-user
</Location>

SVN 을 시작합니다.

[root@ruo91 ~]# /etc/init.d/subversion start

– SVN 기본 디렉토리 만들기
소스 코드를 관리하기 위해서는 trunk , branches, tags 를 만들어 줘야 하므로 임시로 export 걸어 주고 시작합니다.

[root@ruo91 ~]# export SVN_EDITOR=”/bin/vi” ; export SVN_EDITOR

아래처럼 trunk 디렉토리를 만들어 주면 vi 에디터가 자동으로 나오게 됩니다.

[root@ruo91 ~]# svn mkdir http://192.168.0.99/repos/ruo91/trunk

–이 줄 이하는 자동으로 제거됩니다–

A svn://192.168.0.99/ruo91/trunk
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
“svn-commit.tmp” 4L, 75C 1,0-1 모두

이때 :q 를 눌러 에디터에서 빠져 나옵니다.

:q

C 를 눌러 나옵니다.

로그 메시지가 변경되지 않았거나 지정되지 않았습니다
취소 (A), 계속(C), 수정(E)
C

인증 영역을 사용하기 위해 리눅스 root 사용자의 암호와 svn 사용자의 암호를 입력 해줍니다. (암호는 보안상 보이지 않음)

인증 영역(realm): <http://192.168.0.99:80> Authorization!!
‘root’의 암호:
인증 영역(realm): <http://192.168.0.99:80> Authorization!!
사용자명:ruo91
‘ruo91’의 암호:

커밋된 리비전 1.

branches 디렉토리 만들기 (trunk 와 반복..)

[root@ruo91 ~]# svn mkdir http://192.168.0.99/repos/ruo91/branches

로그 메시지가 변경되지 않았거나 지정되지 않았습니다
취소(A), 계속(C), 수정(E)
C

커밋된 리비전 2.

tags 디렉토리 만들기

[root@ruo91 ~]# svn mkdir http://192.168.0.99/repos/ruo91/tags

로그 메시지가 변경되지 않았거나 지정되지 않았습니다
취소(A), 계속(C), 수정(E)
C

커밋된 리비전 3.

위에서 만든 디렉토리를 확인 합니다.

[root@ruo91 ~]# svn list http://192.168.0.99/repos/ruo91
branches/
tags/
trunk/

4. Trac 설치
RPMforge 에서 다운받고 설치 합니다.

[root@ruo91 ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
[root@ruo91 ~]# rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.i386.rpm

[root@ruo91 ~]# yum install -y mod_python trac

trac 프로젝트를 설치 합니다.

[root@ruo91 ~]# trac-admin /var/www/trac/ initenv

Creating a new Trac environment at /var/www/trac

Trac will first ask a few questions about your environment
in order to initialize and prepare the project database.

Please enter the name of your project.
This name will be used in page titles and descriptions.

Project Name [My Project]> Yongbok Project

Please specify the connection string for the database to use.
By default, a local SQLite database is created in the environment
directory. It is also possible to use an already existing
PostgreSQL database (check the Trac documentation for the exact
connection string syntax).

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

Please specify the type of version control system,
By default, it will be svn.

If you don’t want to use Trac with version control integration,
choose the default here and don’t specify a repository directory.
in the next question.

Repository type [svn]>

Please specify the absolute path to the version control
repository, or leave it blank to use Trac without a repository.
You can also set the repository location later.

Path to repository [/path/to/repos]> /var/www/svn/ruo91

Creating and Initializing Project
Installing default wiki pages
PageTemplates imported from /usr/lib/python2.4/site-packages/trac/wiki/default-pages/PageTemplates
TracGuide imported from /usr/lib/python2.4/site-packages/trac/wiki/default-pages/TracGuide
…………………
…………………………..
………………………………….
———————————————————————
Warning: couldn’t index the repository.

This can happen for a variety of reasons: wrong repository type,
no appropriate third party library for this repository type,
no actual repository at the specified repository path…

You can nevertheless start using your Trac environment, but
you’ll need to check again your trac.ini file and the [trac]
repository_type and repository_path settings in order to enable
the Trac repository browser.
———————————————————————
Project environment for ‘Yongbok Project’ created.

You may now configure the environment by editing the file:

/var/www/trac/conf/trac.ini

If you’d like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

tracd –port 8000 /var/www/trac

Then point your browser to http://localhost:8000/trac.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project
website:

http://trac.edgewall.org/

Congratulations!

아파치가 사용할수 있도록 변경합니다.

[root@ruo91 ~]# chown apache:apache /var/www/trac/*
[root@ruo91 ~]# chmod -R 777 /var/www/trac

Trac 인증 패스워드 파일을 생성합니다.

[root@ruo91 ~]# htpasswd -cm /var/www/trac/user-ruo91-trac-passwd ruo91
New password:
Re-type new password:
Adding password for user ruo91

subversion 에 Trac 설정을 추가 해줍니다.

[root@ruo91 ~]# vi /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /repos>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “Authorization!!”
AuthUserFile /var/www/svn/user-ruo91-passwd
Require valid-user
</Location>

<Location /trac>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /var/www/trac
PythonOption TracUriRoot /trac
AuthType Basic
AuthName “Yongbok Trac Environment”
AuthUserFile /var/www/trac/user-ruo91-trac-passwd
Require valid-user
</Location>

연동 확인을 위해 Apache 를 재시작 합니다.

[root@ruo91 ~]# service httpd restart

SVN 저장소 확인

Trac 확인

참고
http://wiki.centos.org/HowTos/Subversion
http://www.brandonchecketts.com/archives/installing-svn-and-trac-on-a-centos-5-server