개요

gitorious 는 git 서버 호스팅을 제공하는 업체이다. github.com 에 이어 git 호스팅 2위를 차지하고 있다.(1위 github 와 점유율이 어마어마하게 차이가 나긴한다.)

 

Open Source를 호스팅해주는 http://gitorious.org 과 기업용 상용 서비스인 http://gitorious.com 두 개의 도메인으로 나눠진 서비스가 제공되며 기업 내부에서 git 을 운영하고 싶은 기업을 위해 local installer 버전도 제공하고 있다.

gitorious.org 를 통해 개발되는 유명한 open source project로는 FreeBSD, WebKit, QT 등이 있다.


Enterprise Server 는 기술지원을 제공하지만 너무 비싼 관계로 (견적을 뽑아보니 100 user에 25,000 유로 정도 한다) gitorious .org 에서 제공하는 gitorious  community server 를 설치하여 중앙 집중적인 git 서버를 구축하는 방법을 정리해 본다.

 

Gitorious Community Edition installer 는 아무 보증도 하지 않는다. Gitorious 의 동작에 대해 보증을 하지 않으므로 여력이 있는 회사는 Enterprise Edition 을 사용하시는게 좋을듯 하다.

 

 

설치

Gitorious Community Edition 은 RubyOnRails 로 개발된 app 이다. 따라서 ruby 가 필요하며 속도를 위해 deploy 를 phusion passenger 를 이용해서 한다.

사전 필요 사항

  1. RedHat/CentOS 6 계열의 OS (Ubuntu 계열은 아직 미지원)
  2. root 권한이 있어야 함
  3. 2 - 4GB 의 free memory, 1GB 이상의 hard disk 용량
  4. /etc/httpd/ 의 conf 와 conf.d  폴더 백업 (설치시 설정을 변경하므로 사전에 백업한다)

설치

 

  1. gitorious 소스를 받기 위해서는 git client 가 필요하다. 

    yum -y install git
    BASH
  2. clone 및 폴더 이동 

    git clone git://gitorious.org/gitorious/ce-installer.git && cd ce-installer
    CODE
  3.  설치 시작
    1. ./install
  4. Gitorious 가 설치될 서버의 hostname 을 넣는다. 기본적으로 hostname 이 설정된다. 
    hostname 은 valid 해야 하며 최소 한개이상의 . 이 있어야 한다. 그러므로 localhost 는 안되고 localhost.localdomain 은 가능하다. 
    설치중간에 nslookup 을 하므로 DNS 에 등록되어 있거나 /etc/hosts 에 등록되어야 오류가 발생하지 않는다.
    Starting the Gitorious installation...
    Setting Gitorious hostname...
    What hostname should this server and Gitorious instance have?
    (Just hit enter for current hostname 'centos6.localdomain'):
    NOTE: hostname must contain at least one period (.)
    CODE

         5. 열심히 Ruby 와 RubyGems, 기타 package 등을 설치한후에 다음과 같은 화면이 나온다. 여기서부터는 시간이 매우 오래걸리므로 기다린다.

Updating rubygems-update
Successfully installed rubygems-update-1.4.2
Installing RubyGems 1.4.2
RubyGems 1.4.2 installed
File not found: README
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Successfully installed puppet-2.7.11
1 gem installed
Randomizing db password in puppet recipe...
Db password updated.
Applying Puppet recipe (will take a while, be patient)...
CODE

      6. 다음 화면이 나오고 설치가 완료되면 service httpd restart 를 수행한다. (메시지대로 reboot 를 수행해도 된다.)

 
CODE

       7. 다음 화면이 나오고 설치가 완료되면 service httpd restart 를 수행한다. (메시지대로 reboot 를 수행해도 된다.)

 

 

실행

  • phusion passenger 로 deploy 하므로 apache 나 nginx 를 구동하면 실행된다.
  • 설정은 /etc/httpd/conf.d/gitorious.vhost.conf 에 저장되므로 설정을 변경하려면 이 파일을 변경한다 

관리자 생성

  1. admin 생성을 위해 다음 명령어를 실행한다.

    cd /var/www/gitorious/app && RAILS_ENV=production ruby script/create_admin
    CODE
  2. 다음 화면에서 관리자의 email 과 암호를 넣는다.

확인

  1. 웹브라우저를 구동하고 설치시 설정한 hostname 에 연결한다.
  2. 다음과 같은 화면이 보이면 정상적으로 설치된 것이다. 위에서 만든 admin 암호로 login 한다.
     

 

사용자 생성

  • public mode 가 아닐경우 console 에서 사용자를 생성해야 한다.
  • 다음 명령어를 이용하여 사용자를 생성한다.

    cd /var/www/gitorious/app && RAILS_ENV=production ruby script/create_user
    CODE

git 데이타 저장 장소

  • git repository 는 /var/www/gitorious/repositories 에 저장되며 mysqldump 를 이용하여 gitorious_production  DBMS 를 덤프할 수 있다. 편리하게 하려면 /var/www/gitorious/app/script/snapshot  을 수행한다.

git backup

  • 다음 명령어로 tarball 로 백업할수 있다.

    cd /var/www/gitorious/app/ && script/snapshot ./testsnapshot.tar
    CODE

git backup restore

  • 위에서 백업한 tarball 을 다음 명령어로 복구할 수 있다.

    cd /var/www/gitorious/app/ && script/restore ./testsnapshot.tar
    CODE


SELinux 설정

  • chcon -t httpd_modules_t /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.4/ext/apache2/mod_passenger.so
  • chcon -t httpd_exec_t /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.4/agents/Passenger*
  • conf.d에 내용 추가

    <IfModule !mod_passenger.c>
    LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.4/ext/apache2/mod_passenger.so
    PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.4
    PassengerRuby /usr/bin/ruby
    PassengerTempDir /tmp/passenger_tmp/
    </IfModule>

  • grep PassengerLoggi /var/log/audit/audit.log|audit2allow -m PassengerLoggingAgent

 

다시

  •  chcon -t httpd_log_t /var/log/passenger-analytics
  • cd /usr/share/selinux/devel

    vi httpd-puppet.te

    policy_module(httpd-puppet,1.0.0)
    
    require {
    	type httpd_t;
    	type puppet_var_lib_t;
    	type puppet_var_run_t;
    	type puppet_log_t;
    	type puppet_port_t;
    	type lib_t;
    	type httpd_tmp_t;
    	type port_t;
    }
    
    allow httpd_t puppet_var_lib_t:dir rw_dir_perms;
    allow httpd_t puppet_var_lib_t:file manage_file_perms;
    allow httpd_t puppet_var_run_t:dir {search getattr};
    allow httpd_t puppet_log_t:dir rw_dir_perms;
    allow httpd_t puppet_log_t:file rw_file_perms;
    allow httpd_t puppet_log_t:file create_file_perms;
    allow httpd_t puppet_log_t:file setattr;
    allow httpd_t puppet_port_t:tcp_socket name_bind;
    allow httpd_t lib_t:file execute_no_trans;
    allow httpd_t httpd_tmp_t:sock_file rw_sock_file_perms;
    allow httpd_t httpd_tmp_t:sock_file {create unlink setattr};
    allow httpd_t self:capability { fowner fsetid sys_ptrace };
    allow httpd_t port_t:udp_socket name_bind;
  • make httpd-puppet.pp

    semodule -i httpd-puppet.pp

    mkdir /var/log/passenger-analutics

     chcon -t httpd_log_t /var/log/passenger-analytics

     

ModRails 문서

  • chcon -R -h -t  httpd_sys_content_t /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.4
  • export PASSENGER_TMPDIR=/tmp/passenger_tmp
  • mkdir /tmp/passenger_tmp
  • chcon -u system_u -r object_r -t httpd_sys_content_t /tmp/passenger_tmp/
  • semanage fcontext -a -f "" -t httpd_tmp_t '/tmp/passenger_tmp(/.*)?'     

같이 보기

 

참고 자료

ModRails 

Gitorious