LoginSignup
12

More than 5 years have passed since last update.

GitLab8.6 入れてみた

Last updated at Posted at 2016-04-09

WebサーバにGitLabを入れてみた

主に参考したところ:公式,

バージョン等

  • CentOS 7.2
  • GitLab Community Edition 8.6.5

エラーと対処

PostgreSQL

一度GitLabを起動,停止してからsudo gitlab-ctl reconfigureを実行すると

shell
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

と出て失敗していた.

postgresqlのソケットが変に残ってしまっていたらしい.
色々調べたが解決しなかった.参考参考2

妥協策:/etc/gitlab/gitlab.rb内でPostgreSQLのパラメータをなにか変更してからgitlab-ctl reconfigureを実行する.すると,ちゃんとPostgreSQLを終了して設定変更しようと努めてくれるらしい.
もう少しちゃんとした解決方法があったら教えて下さい.

いつまで経っても502 Bad Gateway

sudo gitlab-ctl startとして対象のポートをブラウザで開いても,GitLabの502 Bad Gatewayの画面

解決:ポートが使用中だった.他にも設定に不備があると502 Bad Gatewayで止まる様子.

通知メールの送信

Webサーバであまりメール送信などをさせたくなかった.
Gmailアカウントを作成し,それで送るようにした.参考

リバースプロキシとそれによる問題と対処

apache起動済みのサーバで動かす

gitlabをnginxのサブディレクトリ運用にし,apacheでリバースプロキシする.参考1 参考2
外向きにポートを余分に開きたくないため,external_urlは以下のようにした.

/etc/gitlab/gitlab.rb
external_url 'http://127.0.0.1:8080/gitlab'

表示されるURLやSSH Hostがおかしい

git clone等のために表示されるURLやSSH Hostに,/etc/gitlab/gitlab.rbで設定したexternal_urlがそのまま出てきている.
別の変数として定義し,対応する部分に設定する.参考

SSH

表示は成功

/etc/gitlab/gitlab.rb
gitlab_rails['gitlab_ssh_host'] = 'example.com'
/opt/gitlab/embedded/cookbooks/gitlab/templates/default/gitlab.yml.erb
ssh_host: <%= @gitlab_ssh_host %>

しかし,SSHからのgit cloneなどができない.

shell
GitLab: API is not accessible
fatal: Could not read from remote repository.

解決:サブディレクトリ設定で行っていた,以下の変更点は必要なかった

/opt/gitlab/embedded/cookbooks/gitlab/templates/default/gitlab-shell-config.yml.erb
gitlab_url: "<%= @api_url %>" # こっちが正解
↓
gitlab_url: "<%= @api_url %>/gitlab" # 必要なかった

このせいで,gitlab-shell-congig.ymlを見てみるとexample.com/gitlab/gitlabになっていた.これを修正するとSSH越しのgit cloneなどができた.

おそらくバージョンの違いのせい.

HTTP

以下のように設定してみた.

/etc/gitlab/gitlab.rb
gitlab_rails['gitlab_repo_url'] = 'example.com'
/opt/gitlab/embedded/cookbooks/gitlab/templates/default/gitlab.yml.erb
url: <%= @gitlab_repo_url %>

しかし,表示は変わらず,さらにassets関係やアバター画像も表示できていなかった.どちらも参照しているURLが127.0.0.1:8080となっていたため,それを探す.

解決:色々試してみた結果,/var/opt/gitlab/gitlab-rails/etc/gitlab.ymlのhostportを参照しているらしいことが判明.
今後もgitlab-ctl reconfigureをする可能性はあるので,templateから変更.変更点は以下の通り.
4/28追記:/opt/gitlab/embedded/cookbooks/gitlab/templates/default/gitlab.yml.erbにはここは編集しても消えちゃうよ!って書かれていました.なので,/etc/gitlab/gitlab.rbで指定する名前をgitlab.yml.erbのものに合わせます.

/etc/gitlab/gitlab.rb
gitlab_rails['gitlab_host'] = 'example.com'
gitlab_rails['gitlab_port'] = 80
/opt/gitlab/embedded/cookbooks/gitlab/templates/default/gitlab.yml.erb
# デフォルトのまま
host: <%= gitlab_host %>
port: <%= gitlab_port %>

これでHTTPのURL表示も,アバターの表示もうまくいった.こちらのようにassetsのリバースプロキシも必要なさそう.

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
12