티스토리 뷰

Developer

[gitlab] gitlab installation guide

rocksea 2013. 5. 6. 00:56

gitlab installation guide.

요즘 웬만한 OpenSouce는 대부분이 github로 배포됩니다.  github는 유/무료 license가 있지만 유료버전은 비공개로 사용할 수 있지만 소규모 회사입장에 부담이 되고 무료버전은 자료를 개해야되기때문에 회사입장에서 진행하는 Project를 올리기엔 부담스럽습니다. 그래서 Local Repository인 gitlab을 설치하여 사용하는 방법에 대해 알아보도록 하겠습니다.

Download URL : http://gitlabhq.com/


step1. ruby 설치

gitlab은 ruby기반으로 만들어져 있기때문에 ruby부터 설치합니다.

$ sudo wget "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz"

$ sudo ./configure

sudo make

$ sudo make install

$ sudo gem install bundler

$ sudo gem install rake


step2. add user

$ sudo adduser --disabled-login --gecos 'GitLab' git


step3. gitlab shell install

GitLab Shell은 ssh를 제어하고 저장소를 관리하기위해 개발되었습니다.

# Login as git

$ sudo su git


# Go to home directory

$ cd /home/git


# Clone gitlab shell

$ git clone https://github.com/gitlabhq/gitlab-shell.git


$ cd gitlab-shell


# switch to right version

$ git checkout v1.3.0


$ cp config.yml.example config.yml


# Edit config and replace gitlab_url

# with something like 'http://domain.com/'

$ vim config.yml


# Do setup

$ ./bin/install


step4. gitlab source download & settings

$ cd /home/git

$ sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab

$ cd /home/git/gitlab

$ sudo -u git -H git checkout 5-1-stable

$ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

$ sudo -u git -H mkdir /home/git/gitlab-satellites


# Create directories for sockets/pids and make sure GitLab can write to them

$ sudo -u git -H mkdir tmp/pids/

$ sudo -u git -H mkdir tmp/sockets/

$ sudo chmod -R u+rwX  tmp/pids/

$ sudo chmod -R u+rwX  tmp/sockets/

$ sudo -u git -H cp config/puma.rb.example config/puma.rb


step5. MySQL setting

#Mysql

$ cd /home/git/gitlab

$ sudo -u git cp config/database.yml.mysql config/database.yml

$ sudo gem install charlock_holmes --version '0.6.9'

$ sudo apt-get install libmysqlclient-dev

sudo -u git -H bundle install --deployment --without development test mysql

$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

$ sudo -u git -H bundle exec rake sidekiq:start RAILS_ENV=production

$ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

* config/database.yml 설정 확인 ( 설정 안맞으면 진행이 안됨 )

# PRODUCTION

#

production:

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: gitlab

  pool: 5

  username: gitlab

  password: "gitlab"

  # host: localhost

  # socket: /tmp/mysql.sock


#

# Development specific

#

development:

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: gitlab

  pool: 5

  username: gitlab

  password: "gitlab"

  # socket: /tmp/mysql.sock


# Warning: The database defined as "test" will be erased and

# re-generated from your development database when you run "rake".

# Do not set this db to the same as development or production.

test: &test

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: gitlab

  pool: 5

  username: gitlab

  password: "gitlab"

  # socket: /tmp/mysql.sock





step6. start gitlab

unix socket형태의 daemon을 띄운다.

sudo service gitlab start 

# or 

sudo /etc/init.d/gitlab restart


step7. nginx 설치

$ sudo apt-get install nginx

$ sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/nginx/gitlab 

$sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

gitlab unix socket 설정 확인

# GITLAB

# Maintainer: @randx

# App Version: 5.0


upstream gitlab {

  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;

}


server {

  listen 80;         # e.g., listen 192.168.1.1:80 default_server;

  server_name rocksea;     # e.g., server_name source.example.com;

  root /home/git/gitlab/public;


  # individual nginx logs for this gitlab vhost

  access_log  /var/log/nginx/gitlab_access.log;

  error_log   /var/log/nginx/gitlab_error.log;


  location / {

    # serve static files from defined root folder;.

    # @gitlab is a named location for the upstream fallback, see below

    try_files $uri $uri/index.html $uri.html @gitlab;

  }


  # if a file, which is not found in the root folder is requested,

  # then the proxy pass the request to the upsteam (gitlab unicorn)

  location @gitlab {

    proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694

    proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694

    proxy_redirect     off;


    proxy_set_header   X-Forwarded-Proto $scheme;

    proxy_set_header   Host              $http_host;

    proxy_set_header   X-Real-IP         $remote_addr;


    proxy_pass http://gitlab;

  }

}


- modified : 2013.07.17 - gitlab6 설치 URL 추가

gitlab6이 나와서 아래링크의 내용 토시하나 안틀리고 똑같이 실행해서 설치하였습니다.

https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

.by rocksea



댓글