블로그 이미지
Flying Mr.Cheon youGom

Recent Comment»

Recent Post»

Recent Trackback»

« 2025/8 »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

프로젝트 산출물 관리를 위해 Trac과 svn을 연동하는 작업을 하였다. 처음엔 redhat에 깔았다가, selinux 패키지 문제 등 찾아내지 못한 문제들이 많아 ubuntu로 작업하였고, 한번 깐 다음에 문서를 작성하고, 그 대로 다시 한번 설치하여 보았다. 

이미 많은 trac, svn 연동 글들이 있지만, 해가 지나기도 하고, trac버전이 0.12로 올라오면서 trac에서 svn 지정하는 방식도 달라졌기 때문에 바로 적용하기 힘든 부분이 많았다. 이 글이 최신 버전으로 trac을 설치하는 데 도움이 되길 바란다.





1. Ubuntu 설치 

2. 파이썬 설치
#apt-get install python

3. SVN 패키지 설치
#apt-get install subversion

4. SVN 저장소 생성
#svnadmin create --fs-type fsfs <REPO-DIR>

- 사용자 추가
#htpasswd -c user_passwd admin
패스워드 입력
admin유저에 대한 정보가 user_passwd라는 파일에 기록된다.
나중에 아파치에서 이 파일을 통해 사용자 인증을 한다.

5. Apache 설치 & 실행
#apt-get install apache2 libapache2-svn
#/etc/init.d/apache2 start
웹브라우저에서 ip를 입력하여 초기 페이지가 뜨는지 확인

- Apache Python 모듈 설치
# apt-get install libapache2-mod-python

6. Apache 설정
# vi /etc/apache2/httpd.conf
dav, dav_svn 모듈이 설정되어 있는지 확인 합니다. 
주석처리 되어 있으면 주석을 없애고 없다면 아래 두줄을 추가합니다.

LoadModule dav_module         modules/mod_dav.so
LoadModule dav_svn_module     modules/mod_dav_svn.so

맨 밑에
웹으로 접근할 svn 주소를 명시한다

<Location /svn/REPO-NAME>     // 웹브라우저를 통해 ip/svn/REPO-NAME으로 접근 가능
     DAV svn
     SVNPath <REPO-DIR>     //저장소 주소     
     AuthType Basic
     AuthName "This is your repository"
     AuthUserFile /etc/apache2/pass/user_passwd //위에서 만든 패스워드 파일
     Require valid-user
</Location>

아파치 재시작
#/etc/init.d/apache2 stop
#/etc/init.d/apache2 start

이제 위의 주소를 통해 svn을 사용할 수 있다.

7. Trac 설치

- Trac 설치 필요패키지
Python
setuptools - # apt-get install python-setuptools
genshi - # apt-get install python-genshi
sqlite - # apt-get install python-sqlite

- Trac 설치

Using easy_install

One way to install Trac is using  setuptools. With setuptools you can install Trac from the subversion repository;

A few examples:

  • first install of the latest stable version Trac 0.12.2, with i18n support:
    easy_install Babel==0.9.5
    
    easy_install Trac
    
    It's very important to run the two easy_install commands separately, otherwise the message catalogs won't be generated.
  • Trac에서 Genshi 버전에러가 난다면 easy_install Genshi 로 재설치 해보자
  • upgrade to the latest stable version of Trac:
    easy_install -U Trac
    
  • upgrade to the latest trunk development version (0.13dev):
    easy_install -U Trac==dev
    

For upgrades, reading the TracUpgrade page is mandatory, of course.

8. Trac 환경 설정
1. 프로젝트 생성
# trac-admin /path/to/project initenv (생성 명령어, /path/to/project에 생성한다)
프로젝트 이름과 DB설정을 물어보는데, DB설정의 경우 아무 입력없이 enter를 치면 기본 설정으로 생성이 된다.

2. 웹에서 write 할 수 있도록 프로젝트 폴더의 권한 설정
# chown www-data:www-data -R /path/to/project

관리자 권한 부여
# trac-admin /YOUR/PROJECT/Trac_DIRECTORY/PROJECT_NAME permission add USERID TRAC_ADMIN

3. 웹 주소 매핑
- apache 설정 파일 수정
# vi /etc/apache2/httpd.conf
맨 밑에 로케이션 추가

  <Location /storagetf>     // ip/storagetf 로 접속됨
    SetHandler mod_python
    SetEnv PYTHON_EGG_CACHE /home/repo/storagetf/cache     
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnvParentDir   /home/storagetf/
    PythonOption TracUriRoot /storagetf
     AuthType Basic
     AuthName "This is your repository"
     AuthUserFile /etc/apache2/pass/user_passwd     // svn과 동일한 패스워드 파일 사용
     Require valid-userR
  </Location>

4. 웹 접속 권한 설정
# chown www-data:www-data -R /YOUR/PROJECT/Trac_DIRECTORY/
웹브라우저로 접속해보자


라고 나오면 성공, 프로젝트를 클릭하면



이런식으로 나오면 된다.


4. 웹 로그인 설정
일단 htpasswd 파일을 통한 인증을 하였는데, 관리자 id로 로그인했으면, html폼으로 로그인을 할 수 있도록 설정을 바꾸자
이를 위해 trac account manager plugin 을 깔아야 한다. http://trac-hacks.org/wiki/AccountManagerPlugin 참고
이를 깔고 아파치 재시작
관리자 메뉴에 들어가서 플러그인 목록을 보면 

이런 것들이 보일 것이다.

여기서 다 선택해도 상관이 없으며, email 인증을 하지 않을 거라면 밑에 EmailVerificationModule 은 비활성화 한다.

이를 적용한뒤, Accounts메뉴에 설정을 들어가자
사용자 id/pw를 관리할 방법, 파일 경로를 적는 것이 있는데,
htpasswd를 사용하므로

trac디렉토리/conf/trac.ini에서
password_file = 패스워드 파일 위치 추가


후에 svn도 연동하므로 svnservepasswordstore에도 추가해준다.


적용하면, Accounts->Users에서 유저 리스트 조회, 유저 추가, 패스워드 수정 등이 가능할 것이다.

웹에서 로그인도 가능

trac디렉토리/conf/trac.ini에서

[components]
trac.web.auth.loginmodule = disabled
추가

아파치 재시작




svn 저장소에 trunk, tags, branches 디렉토리를 생성한다. -> 그래야 trac이 인식함

다음 패키지를 설치한다.
apt-get install python-subversion

trac.ini에 다음을 추가한다. 
[repositories]
.alias = project
project.description = This is the ''main'' project repository.
project.dir = /home/repo/project
project.type = svn
project.url = http://your_project

svn 저장소의 hooks 디렉토리의 post-commit, post-revprop-change 실행파일을 생성(실행권한을 주어야 함)한다.
이는 commit후에 trac에 revision을 전송함으로써 trac에서 svn의 최신상태를 유지시켜준다.
post-commit

REPOS="$1"

REV="$2"


#"$REPOS"/hooks/mailer.py commit "$REPOS" $REV "$REPOS"/mailer.conf

export PYTHON_EGG_CACHE="/home/repo/cloud/cache"

/usr/local/bin/trac-admin /YOUR/TRAC/DIR changeset added "$REPOS" "$REV"


post-revprop-change

REPOS="$1"

REV="$2"

USER="$3"

PROPNAME="$4"

ACTION="$5"


#"$REPOS"/hooks/mailer.py propchange2 "$REPOS" $REV \

#  "$USER" "$PROPNAME" "$ACTION" "$REPOS"/hooks/mailer.conf

export PYTHON_EGG_CACHE="/home/repo/cloud/cache"

/usr/local/bin/trac-admin /YOUR/TRAC/DIR changeset modified "$REPOS" "$REV"

PYTHON_EGG_CACHE는 설정되어 있는 경우 해당 디렉토리를 써준다.

아파치 재시작
메뉴에서 '소스 둘러보기'가 활성화 됨



10. SSL 적용하기
을 참고하여 https 프로토콜로 전송하자
: