Subversion, Trac, SSL 함께 설치하기.

kuh74의 이미지

개요
- 이 문서는 우분투 리눅스 6.06 버전을 기준으로 작성되었다. (http://www.ubuntu.com)
- Subversion은 CVS를 대체하기 위해서 새로 나온 버전관리시스템이다.
- Trac은 위키, 로드맵, 버그추적기능을 통합적으로 제공하며, Subversion와 강력하게 연계되어 있다.
- 이 문서 내용대로 따라하면 Subversion, Trac이 모두 다수의 프로젝트를 지원하고,
사용자 인증을 거치며, SSL암호화를 통해 모든 전송내용이 암호화되므로 대규모 운용에도 손색이 없다.

테스트 환경
- Ubuntu 6.06 LTS

보장은 못 하지만 이 문서의 내용은 다른 버전의 우분투 혹은 데비안에서도
문제 없이 작동할 것으로 예상된다.

참고한 자료들.
Subversion 관련
https://help.ubuntu.com/6.06/ubuntu/serverguide/C/version-control-system.html
http://svnbook.red-bean.com/

Trac 관련
http://trac.edgewall.org/wiki/TracUbuntuMultipleProjects
http://trac.edgewall.org/wiki/TracModPython
http://trac.edgewall.org/wiki/TracOnUbuntu

Apache SSL/TLS 암호화
http://httpd.apache.org/docs/2.0/ssl/ssl_intro.html
http://mario.espaciolinux.com/apache2_ssl.html
http://www.vanemery.com/Linux/Apache/apache-SSL.html
http://httpd.apache.org/docs/2.0/ssl/ssl_howto.html
http://httpd.apache.org/docs/2.0/mod/mod_ssl.html

이 글을 거의 다 작성하고 나서야 발견한 좋은 글 (SSL암호화를 제외한 모든 내용이 들어 있다.)
http://ariejan.net/2006/12/01/how-to-setup-a-ubuntu-development-server-part-1/
http://ariejan.net/2006/12/02/how-to-setup-a-ubuntu-development-server-part-2/

1. 필요한 패키지 설치

Subversion 설치
shell> sudo apt-get install subversion libapache2-svn

Trac 설치
shell> sudo apt-get install trac libapache2-mod-python

2. 디렉토리 구조 설명

이 문서에서 사용할 디렉토리 구조를 설명한다.
이 문서의 끝까지 계속해서 사용될 것이므로 잘 기억해 주시길..

Subversion 저장소의 뿌리
/var/lib/svn

Trac 환경의 뿌리
/var/lib/trac

test1 이라는 이름의 프로젝트가 사용하는 디렉토리
Subversion저장소 : /var/lib/svn/test1
Trac 환경 : /var/lib/trac/test1

Cool_Project 라는 이름의 프로젝트가 사용하는 디렉토리
Subversion저장소 : /var/lib/svn/Cool_Project
Trac 환경 : /var/lib/trac/Cool_Project

<프로젝트이름> 라는 이름의 프로젝트가 사용하는 디렉토리 Subversion저장소 : /var/lib/svn/<프로젝트 이름> Trac 환경 : /var/lib/trac/<프로젝트 이름>

이해가 가시죠??

3. 뿌리 디렉토리 생성
shell> sudo mkdir /var/lib/svn
shell> sudo chown -R www-data:www-data /var/lib/svn

shell> sudo mkdir /var/lib/trac
shell> sudo chown -R www-data:www-data /var/lib/trac

4. SSL암호화에 사용할 서버인증서 생성하기
불특정 다수를 대상으로 SSL서버를 구축할 경우
공인인증기관이 서명한 서버인증서를 구입하는 것이 좋다.
공인인증기관이 서명한 서버인증서 구입하는 방법은
http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html
How do I create a real SSL Certificate? 부분을 참고하면 된다.

이 문서에서는 자기 스스로 서명한 서버인증서 기준으로 진행한다.
자기 스스로 서명한 서버인증서의 사용상 불편한 점은
처음 접속할 때 인증서의 사용을 허가하겠다고
'클릭을 1번 해줘야 한다'는 것이다.

자세한 내용은 다음과 같다.

OpenSSL 설치하기 (대부분의 경우 이미 설치되어 있음)
shell> apt-get install openssl

비밀키파일과 인증서 생성하기
shell> cd ~
shell> openssl req -new -x509 -nodes -out server.crt -keyout server.key
----------------------- 실행화면 시작 ------------------------------
Generating a 1024 bit RSA private key
.......................++++++
....++++++
writing new private key to 'server.key'
-----
...생략...
-----
Country Name (2 letter code) [GB]:KR
(국가코드를 입력한다.)
State or Province Name (full name) [Some-State]:
(주 혹은 도 이름을 입력한다.
글쓴이는 직할시에 거주하므로 엔터키를 눌러서 넘어갔다.)
Locality Name (eg, city) []:Pusan
(거주하는 도시이름을 입력한다. 서울에 거주한다면 Seoul을 입력하면 될 듯하다.)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany
(조직명(혹은 회사명)을 입력한다.)
Organizational Unit Name (eg, section) []:Development
(부서이름을 입력한다.)
Common Name (eg, YOUR name) []:www.hostname.com
(Common Name은 인증서 생성시 입력하는 정보 중에서 가장 중요한 항목이다.
Common Name을 직역하면 '공통이름'이 되며,
메세지에서는 예제로 실제 이름을 입력하라고 하지만,
그것은 개인 인증서 생성할 때나 해당되는 이야기이며,
지금처럼 서버 인증서를 생성할 때에는 '서버 완전한 도메인 이름'을 입력해야 한다.
이 항목을 잘못 입력하면 사용자는 인증서에 심각한 에러가 있다는 메세지를 받게 되고,
대개의 경우 에러메세지에 겁 먹고 인증서를 거부하게 되므로,
Subversion 및 Trac서비스를 제공할 수 없게 된다.
웹서버에 접속할 때 주소창에 http://www.hostname.com 이라고 입력한다면,
Common Name은 www.hostname.com 이 된다.)
Email Address []:xxx@daum.net
(전자우편주소를 입력한다. 글쓴이는 다음메일을 쓴다.)
----------------------- 실행화면 끝 ------------------------------

생성된 인증서 확인하기
shell> ls server*
server.key, server.crt 파일이 생성된 것을 알 수 있다.
server.key -> 비밀키(private key) 파일
server.crt -> 인증서(public key를 포함) 파일

인증서 파일을 적절한 위치로 복사
shell> cp server.key /etc/apache2/ssl/
shell> cp server.crt /etc/apache2/ssl/
shell> chmod 600 /etc/apache2/ssl/server.key
shell> rm ./server.key
shell> rm ./server.crt

5. Apache 웹서버 설정변경
SSL암호화를 지원하기 위해서 mod_ssl 모듈을 활성화 시킨다.
shell> sudo ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/
shell> sudo ln -s /etc/apache2/mods-available/ssl.conf /etc/apache2/mods-enabled/

Apache서버가 https의 기본포트인 443번을 듣도록 한다.
shell> sudo vi /etc/apache2/ports.conf
-------- /etc/apache2/ports.conf 에 추가할 내용 시작 ---------
Listen 443
-------- /etc/apache2/ports.conf 에 추가할 내용 끝 ---------

https서비스를 제공하는 VirtualHost가 사용할 DocumentRoot를 생성한다.
생성한 후에 빈 디렉토리로 놔둬도 된다.
shell> sudo mkdir /var/www-ssl

VirtualHost를 이용해서 https를 설정한다.
shell> sudo vi /etc/apache2/sites-available/ssl

--------- /etc/apache2/sites-available/ssl 내용 시작 --------------
# KLDP게시판에 업로드하면 아파치 설정화일의 태그가 사라지기 때문에
# <> 표시를 ()로 대체했습니다.
# 실제 사용할 때는 <> 로 대체해서 사용하십시오.
# 무슨 의미인지 명확하지 않다면, 
# 이 문서에 텍스트 화일로 첨부한 ssl.txt를 보십시오.
 
NameVirtualHost *:443
(VirtualHost *:443)
  DocumentRoot /var/www-ssl
 
  SSLEngine On
  SSLProtocol -all +TLSv1 +SSLv3
  SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
  SSLOptions +StrictRequire
  SSLVerifyClient none
  SSLCertificateFile    /etc/apache2/ssl/server.crt
  SSLCertificateKeyFile /etc/apache2/ssl/server.key
 
  (Location /svn)    # Subversion 설정
    DAV svn
 
    # any "/svn/foo" URL will map to a repository /var/lib/svn/foo
    SVNParentPath /var/lib/svn
 
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/dev_passwd
    Require valid-user
  (/Location)
 
  (Location /projects) # Trac 설정
    SetHandler mod_python   
    PythonHandler trac.web.modpython_frontend   
    PythonOption TracEnvParentDir /var/lib/trac   
    PythonOption TracUriRoot /projects
 
    AuthType Basic
    AuthName "Trac, Issue Tracking and Documenting"
    AuthUserFile /etc/dev_passwd
    Require valid-user
  (/Location)
(/VirtualHost)
--------- /etc/apache2/sites-available/ssl 내용 끝   --------------

shell> sudo ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/
shell> sudo /etc/init.d/apache2 restart

VirtualHost를 이용해서 http, https를 동시에 지원하며,
Subversion과 Trac의 모든 전송내용이 암호화되며,
하나의 사용자인증화일을 공유한다.

6. 사용자 생성
사용자를 생성하고, 암호를 저장하는 데 htpasswd라는 프로그램을 사용한다.

htpasswd에서 자주 사용하는 옵션은 다음과 같다.
-c : 파일 생성하기. 처음 실행할 때 1번만 주면 된다.
-m : MD5 암호화하기.

예를 들어서, user1, user2, user3 에 대해서
Subversion 및 Trac 공용 사용자 계정을 생성할려면 다음과 같이 한다.
shell> sudo htpasswd -cm /etc/dev_passwd user1
shell> sudo htpasswd -m /etc/dev_passwd user2
shell> sudo htpasswd -m /etc/dev_passwd user3

암호를 물어올 때 2번 입력해 주면 된다.
New password: ***** (암호 입력)
Re-type new password: ***** (암호 다시 입력)
Adding password for user user1

7. Ubuntu서버에 저장소(repository) 생성

Subversion 저장소를 생성한다.
shell> sudo svnadmin create /var/lib/svn/<프로젝트 이름>

Trac은 특정한 구조를 가진 Subversion저장소만 인식할 수 있다.
shell> sudo svn mkdir file://localhost/var/lib/svn/<프로젝트 이름>/branches -m "initial structure1"
shell> sudo svn mkdir file://localhost/var/lib/svn/<프로젝트 이름>/tags -m "initial structure2"
shell> sudo svn mkdir file://localhost/var/lib/svn/<프로젝트 이름>/trunk -m "initial structure3"

Apache웹서버를 재시작 한다.
shell> sudo /etc/init.d/apache2 restart

웹브라우저로 https://<서버주소>/svn/<프로젝트 이름> 에 접속해 본다.
웹브라우저에서 프로젝트 소스가 보여야 정상이다.
(서버주소에 localhost나 127.0.0.1을 입력하면 연결이 안 될 수도 있다.
ifconfig을 실행시키면 나오는 진짜 IP주소를 사용해야 한다.
응답이 없으면, iptable방화벽에서 443번 포트를 막고 있는 지 확인한다.
https://<서버주소>/svn 으로 접속하면 Forbidden에러가 난다.
URL 마지막에 반드시 <프로젝트 이름>을 붙여야 한다.
접속과정에서 인증서 관련해서 팝업창이 뜨면 영구히 허가한다.
인증서 생성과정에서 서버이름을 잘못 입력한 경우
에러메세지가 1번 더 뜨는 데, 무시하면 된다.)

8. Trac 환경 생성 및 초기화

Trac 환경 생성하기 전에 다음 2가지 명령을 실행한다.
shell> sudo chown -R www-data:www-data /usr/share/trac
shell> sudo chown -R www-data:www-data /var/lib/svn
shell> sudo /etc/init.d/apache2 restart

Trac 환경 생성 한다.
shell> sudo trac-admin /var/lib/trac/<프로젝트 이름> initenv
-------------------- 실행화면 시작 ----------------------------------
Creating a new Trac environment at /var/lib/trac/<프로젝트 이름>
(/var/lib/trac/<프로젝트 이름> 디렉토리에 새로운 Trac환경을 생성중임.)

Trac will first ask a few questions about your environment
in order to initalize and prepare the project database.
(Trac은 프로젝트 데이터베이스를 준비하고 초기화시키기 위해서,
당신의 환경에 대해서 몇 가지 질문을 할 것입니다.)

Please enter the name of your project.
This name will be used in page titles and descriptions.
(당신의 프로젝트의 이름을 입력하십시오.
이 이름은 페이지 제목과 비고에 사용될 것입니다.)

Project Name [My Project]> test
(프로젝트 이름. 아무 값도 입력하지 않고 엔터키를 누를 경우 기본값은 My 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).
(데이터베이스 연결문자열을 지정해 주십시오.
기본값으로 로컬에 SQLite 데이터베이스가 생성됩니다.
이미 존재하는 Postgresql 데이터베이스를 사용할 수도 있습니다.
(정확한 연결문자열 구성은 Trac문서를 참조하십시오.)
)

Database connection string [sqlite:db/trac.db]>
(데이터베이스 연결 문자열. 기본값은 'sqlite:db/trac.db' 임
데이터베이스 연결 문자열에 대해서 아는 바 없으므로 엔터키를 눌러서 기본값을 사용함.)

Please specify the absolute path to the project Subversion repository.
Repository must be local, and trac-admin requires read+write
permission to initialize the Trac database.
(프로젝트의 Subversion저장소가 위치한 절대경로를 지정해 주십시오.
그 저장소는 로컬에 위치해야 하고, trac-admin은 Trac 데이터베이스를 위해서
읽기, 쓰기 권한을 가지고 있어야 합니다.)

Path to repository [/var/svn/test]> /var/lib/svn/test
(저장소의 path. 기본값은 '/var/svn/test'
우리는 프로젝트 저장소를 /var/lib/svn/test에 생성해 두었으므로 그것을 입력한다.)

Please enter location of Trac page templates.
Default is the location of the site-wide templates installed with Trac.
(Trac 페이지 템플릿의 위치를 입력하십시오.
기본값은 Trac과 함께 설치된 템플릿의 위치입니다.)

Templates directory [/usr/share/trac/templates]>
(템플릿 디렉토리. 기본값은 '/usr/share/trac/templates'.
이에 대해 아는 바 없으므로 엔터키를 눌러서 기본값을 사용한다.

Creating and Initializing Project
Configuring Project
trac.repository_dir
trac.database
trac.templates_dir
project.name
Installing default wiki pages
/usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields
... 생략 ...
/usr/share/trac/wiki-default/WikiNewPage => WikiNewPage
Indexing repository

Project environment for 'test' created.
(test 프로젝트를 위한 환경이 생성되었습니다.)

You may now configure the environment by editing the file:
(당신은 다음 위치의 파일을 편집해서 환경설정을 바꿀 수 있습니다.)

/var/lib/trac/test/conf/trac.ini

... 생략 ...

Congratulations!
(축하합니다!)
-------------------- 실행화면 끝 ----------------------------------

Apache웹서버에게 읽기, 쓰기 권한을 준다.
shell> sudo chown -R www-data:www-data /var/lib/trac

Apache 웹서버를 재시작해야 새로운 설정화일이 반영된다.
shell> sudo /etc/init.d/apache2 restart

웹브라우저로 https://<서버주소>/projects 에 접속해 본다.
프로젝트 리스트가 보여야 정상이다.
개별 프로젝트로 들어가면 Trac이 설정해 놓은 페이지가 보인다.
(서버주소에 localhost나 127.0.0.1을 입력하면 연결이 안 될 수도 있다.
ifconfig을 실행시키면 나오는 진짜 IP주소를 사용해야 한다.
응답이 없으면, iptable방화벽에서 443번 포트를 막고 있는 지 확인한다.)

이로서 전송내용이 암호화되고 사용자인증을 거치는 Subversion, Trac의 설치를 마쳤다.
이제 사용법만 공부하면 된다. --;

File attachments: 
첨부파일 크기
Plain text icon ssl.txt1.12 KB
Forums: 
세이군의 이미지

Subversion 저장소의 뿌리
/var/lib/svn

Trac 환경의 뿌리
/var/lib/trac

root of trac environment 를 Trac 환경의 뿌리라고 한 것 같습니다.
root를 번역하면 뿌리이기는 하지만 그냥 루트라고 많이 하니까 "루트디렉토리" 라고 하는 것이 좋다고 생각합니다.
한 걸음 더 가까이

irix의 이미지

feisty 에서 apache2-ssl-certificate 가 없던데.. 검색해보니 뭔가 버그로 인해

빠졌다고 그러던데.. (소스에 있다던가...) 그럴경우엔 어떡게 해야하나요 ?

kuh74의 이미지

apache2-ssl-certificate를 사용하지 않고,
openssl을 사용해서 인증서를 생성하도록 글 내용을 고쳤습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.