Githubのような環境を自作してみたく調べたところGitLabが良さそうだったので構築してみた。
ネットの情報ではすぐできると書かれていたけれど意外と詰まったので覚書
環境
- KAGOYA VPS
- CentOS 7(初期化済み)
手順
- 基本的には以下の本家サイトに沿って構築
必要なパッケージを事前に導入
sudo yum install openssh-server
sudo systemctl enable sushi
sudo systemctl start sushi
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo yum install firewalld
sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
GitLabのパッケージを取得、インストール
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce
設定ファイルを更新
- 設定ファイルの更新については触れていないとこが多い
- すでにあるWebサーバとかと連携するケースとか色々あるため書いてない?
- 今回はpostgresもnginxも入れたいので、両方設定が必要かと思いきやpostgresの設定だけコメントを外すことで動く
vim /etc/gitlab/gitlab.rb
#####################
# GitLab PostgreSQL #
#####################
postgresql['enable'] = true
postgresql['listen_address'] = nil
postgresql['port'] = 5432
postgresql['data_dir'] = "/var/opt/gitlab/postgresql/data"
postgresql['shared_buffers'] = "256MB" # recommend value is 1/4 of total RAM, up to 14GB.
上の5項目をコメントインする。
ちなみにこれをやらないと設定読み込み時以下のエラー発生
* execute[create gitlab database user] action run
[execute] psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
[execute] psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
[execute] psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
設定ファイルを読み込み、起動
sudo gitlab-ctl reconfigure
通常はこれだけで管理画面へアクセスできるはずだが一つだけ引っかかった
SELinux関係のパッケージ
Error executing action `run` on resource 'execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp]'
調べるとメモリ不足とか、Swap領域がないためのエラーとか出てくるけれど、単にモジュールが入っていないだけだった
sudo yum install policycoreutils-python
再度実行でインストール完了