LoginSignup
5
5

More than 5 years have passed since last update.

GitLabをインストールしたメモ

Last updated at Posted at 2015-10-06

2013年ごろからあったみたいだけど、いつものごとく素通ししてて今更ながらテスト的に使ってみる。

サーバが SakruaVPS1G です。GitHubのようなサイトを独自に運用できる「GitLab」や「GitBucket」を使ってみよう by http://knowledge.sakura.ad.jpに書かれていること+αな事。

今の構成上、Redmineが動いているサーバに無理やり突っ込む形になるので、フロント側に Nginx が動いており、ドメインベースで RedmineGitlab か切り分けるようにさせる。

Install

GitLab Community Edition (CE) を参考にしてインストール。

OS は CentOS6なのでそれを見ながら、ただし FireWall は昔ながらの iptables の設定が生きてるので、殺さないようにする。( sudo lokkit -s http -s sshiptables をいじくるコマンドなのを知らず、ssh のポートを変えているのにコマンドを実行してしまってログアウトしてしまいサーバに入れなくなってsakura vpsのモニター画面から入ったもののUSキーボードなので : が打ち込めないのに vim を起動してしまいつんでしまい、lokkitを勉強しなおしたので1日潰れてたのは秘密)

$ sudo yum install curl openssh-server postfix cronie
$ sudo service postfix start
$ sudo chkconfig postfix on
$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
$ sudo yum install gitlab-ce

上記ので gitlab-ce の必要な物は全部入りました。(dockerじゃないけどコンテナで一式入るみたいで、ちょっとおもしろい事になってます。)

Configuration

設定を変更

/var/opt/gitlab/gitlab-shell/config.yml
gitlab_url: "http://<任意のホスト名>/"
  1. /etc/gitlab/gitlab.rb では任意の設定に変更させる。
$ sudo gitlab-ctl reconfigure

フロントの Nginx 側の設定

/etc/nginx/conf.d/virtual.conf
upstream gitlab-git-http-server {
  server unix://var/opt/gitlab/gitlab-git-http-server/socket fail_timeout=0;
}

upstream gitlab {
  server  127.0.0.1:8080 fail_timeout=0;
}

server {
        listen 80;
        server_name <ホスト名>;

        location / {
                root /opt/gitlab/embedded/service/gitlab-rails/public;
                client_max_body_size 250m;

                error_page 502 /502.html;

                proxy_read_timeout      300;
                proxy_connect_timeout   300;
                proxy_redirect          off;

                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Frame-Options   SAMEORIGIN;
                proxy_set_header Host $http_host;
                proxy_pass http://gitlab;
        }

        # http://<ホスト名>/nantoka/test.git で git clone などできるようにする
        location ~ [-\/\w\.]+\.git\/ {
                ## If you use HTTPS make sure you disable gzip compression
                ## to be safe against BREACH attack.
                gzip off;

                ## https://github.com/gitlabhq/gitlabhq/issues/694
                ## Some requests take more than 30 seconds.
                proxy_read_timeout      300;
                proxy_connect_timeout   300;
                proxy_redirect          off;

                # Do not buffer Git HTTP responses
                proxy_buffering off;

                # The following settings only work with NGINX 1.7.11 or newer
                #
                # Pass chunked request bodies to gitlab-git-http-server as-is
                # proxy_request_buffering off;
                # proxy_http_version 1.1;

                proxy_set_header    Host                $http_host;
                proxy_set_header    X-Real-IP           $remote_addr;
                proxy_set_header    X-Forwarded-Ssl     on;
                proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
                proxy_set_header    X-Forwarded-Proto   $scheme;
                proxy_pass http://gitlab-git-http-server;
        }
}

Redmine からの移行

移行箇所など。

  1. Repository

    /var/opt/gitlab/gitlab-shell/config.yml をいじれば行けるらしいけど、使ってない死んでるリポジトリとかあるので、整理目的で今回は使っているもののみ登録した

  2. ユーザ

    人数は少ないので管理者アカウントから人数分を作成した

  3. Issue

    諸事情で別アプリのを使用しているので問題なし

  4. Wiki

    マイグレーションが無い上、タグ互換が無いので、1日二時間をメドにチマチマやっていました。3日ぐらいかかった。

問題っぽいもの

うちだけかもしれないけど、サーバの公開鍵を Deploy Key に設定しても

$ git clone git://git@<host>/hoge/test.git
GitLab: The project you were looking for could not be found.
fatal: The remote end hung up unexpectedly

と言われて終わるのよね…orz

2015/10/07 追記:

Deploy Key に設定してもThe remote end hung up unexpectedlyと言われる問題の対処、できました。

Admin AreaDeploy Keysだけに設定していたのが原因。

ProjectSettingsDeployKeysに表示されている該当のDeployKeysEnabledにするか、Enabled deploy keysを新たに設定すれば使えるようになる。

ただし push をすると

GitLab: Deploy keys are not allowed to push code.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

と言われDeploy専用となる。

参考

  1. GitHubのようなサイトを独自に運用できる「GitLab」や「GitBucket」を使ってみよう by http://knowledge.sakura.ad.jp
  2. Download GitLab Community Edition (CE)

後何か https://github.com/composer/satis を使えば composer で使う時に嬉しいことがありそうだけど気力尽きたのでまた今度。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5