CLOVER🍀

That was when it all began.

Ubuntu Linux 16.04 LTSに、GitLab Community Editionをインストールする

チームとかで使うGitリポジトリとして、GitLabがいいなぁと最近ちょっと思っていまして。

まずは試してみようということで、GitLabのCommunity Editionを、Ubuntu Linux 16.04 LTSにインストールしてみたいと
思います。

GitLab Installation / Omnibus package installation (recommended) / Ubuntu

curlSSHサーバー、認証局(CA)証明書をインストール。

$ sudo apt-get install curl openssh-server ca-certificates

メールサーバーを使う場合はPostfixをインストールして、SMTPに関する設定をしてね、と。

$ sudo apt-get install postfix

SMTP settings

今回は、Postfixのインストールはパスします。

GitLabのリポジトリ追加。

$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

GitLab Community Editionインストール。

$ sudo apt-get install gitlab-ce

ドキュメントには次のように書いていますが、

$ sudo EXTERNAL_URL="http://gitlab.example.com" apt-get install gitlab-ce

この「EXTERNAL_URL」は本来はGitLabにアクセスする際のドメインを記述するようです。

※この中の、「external_url」がそれに該当するみたいです
Configuration options / Configuring the external URL for GitLab

「gitlab-ce」のインストールが完了すると、「sudo gitlab-ctl reconfigure」を実行してね、と言われるのでそのまま実行。

$ sudo gitlab-ctl reconfigure

なんと、Chefが動きだします…。

ここにあるのが動くんでしょうね。
README.md · master · GitLab.org / cookbook-omnibus-gitlab · GitLab

とかやっていたら、この状態のまま返ってこなくなりまして。

  * ruby_block[supervise_redis_sleep] action run

これですか?
Common installation problems / Reconfigure freezes at ruby_block supervise_redis_sleep action run

Freeze on ruby_block[supervise_redis_sleep] action run (#430) · Issues · GitLab.org / omnibus-gitlab · GitLab

$ sudo cp /opt/gitlab/embedded/cookbooks/runit/files/default/gitlab-runsvdir.conf /etc/init/
$ sudo initctl start gitlab-runsvdir
$ sudo /opt/gitlab/embedded/bin/runsvdir-start &
$ sudo gitlab-ctl reconfigure

これで、なんとかGitLabが起動しました。

起動と停止。
Maintenance commands

起動。

$ sudo gitlab-ctl start

停止。

$ sudo gitlab-ctl stop

再起動。

$ sudo gitlab-ctl restart

ステータス。

$ sudo gitlab-ctl status

その他の設定、ミドルウェアなどについてはこちらのドキュメントを見ていく感じでしょうね。
Configuring omnibus settings

こんな感じで使っていってみましょう。

補足

こんなことを言われた場合は…

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20180122-13648-u44mrg" ----
STDOUT: rake aborted!
TZInfo::DataSourceNotFound: No source of timezone data could be found.
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error.
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:5:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'

Caused by:
TZInfo::ZoneinfoDirectoryNotFound: None of the paths included in TZInfo::ZoneinfoDataSource.search_path are valid zoneinfo directories.
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:5:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure => environment
(See full trace by running task with --trace)
STDERR: 
---- End output of "bash"  "/tmp/chef-script20180122-13648-u44mrg" ----
Ran "bash"  "/tmp/chef-script20180122-13648-u44mrg" returned 1

次のコマンドを実行して、「tzdata」をインストール。

$ sudo apt-get install tzdata