GitLabを利用しよう
最近Github以外のGitソリューションとしてGitlabが注目されています。
GithubクローンなのでGithubに使い慣れたユーザにも優しく、GitLab 6.0からは、有償版の「GitLab Enterprise Edition」が提供されています。有償プランは複数バージョンあるので開発環境に見合うものを選ぶと良いでしょう。
今回は有料版ではなく、Gitlabの無料版 GitLab Community Edition (CE) をインストールします。
これまでGitlabのインストールは複雑で導入が大変でしたが、omnibusバージョンによりインストールも簡単にできます。
インストール準備
公式ドキュメントに則ります。
公式サイト Download GitLab Community Edition (CE) | GitLab
以下のyumで指定しているパッケージで未インストールのもの、アップデートできるものをインストールします。
[html]# sudo yum install openssh-server
# sudo yum install postfix
# sudo yum install cronie
# sudo service postfix start
# sudo chkconfig postfix on
[/html]
以下のコマンドは私は実行せず。iptablesを勝手に変更してしまうので注意を。実施しなくても手動で設定でもOKです。httpsで利用するならそのポートも開けないといけません。
[html]# sudo lokkit -s http -s ssh[/html]
ここでは分かりやすくiptablesを止めておきます。
[html]# /etc/init.d/iptables stop[/html]
GitLabパッケージのダウンロード
[html]# curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.8.2_omnibus.1-1.el6.x86_64.rpm
[/html]
パッケージのインストール
以下を実施します。
[html]# rpm -i gitlab-7.8.2_omnibus.1-1.el6.x86_64.rpm
Thank you for installing GitLab!
Configure and start GitLab by running the following command:
sudo gitlab-ctl reconfigure
GitLab should be reachable at http://gitlab.example.com
Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And running reconfigure again.
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
[/html]
パケージインストールは完了しました。
GitLabの設定
続いてGitLabの設定をして起動をしましょう。GitLabでは、/etc/gitlab/gitlab.rb に詳細設定をしていきます。設定内容の例は、/etc/gitlab/gitlab.rbにデフォルトで色々と記述してあるので参考になります。
シンプルに起動するのであれば、「サイトのURLの設定」だけで良いです。
ちなみにインストール後に設定変更もできるので、今回は「サイトのURLの設定」だけをして起動までしてみます。
バックアップをしておきます。
[html]# cp -rp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak[/html]
サイトのURLの設定をします。
[html]#vi /etc/gitlab/gitlab.rb
変更前 external_url "http://gitlab.example.com/"
変更後 external_url "http://yourdomain.example.com/"
[/html]
既存のnginx、postgresql、redisがある場合は
これを実施することで、nginx、postgresql、redis、sidekiq、unicornがインストールされます。
既存でこれらがインストールされており、それを使うからいらないという場合は、/etc/gitlab/gitlab.rb にて、以下のようにfalseの設定をしておきます。
[html]#nginx[‘enable’] = false
#postgresql[‘enable’] = false
#redis[‘enable’] = false[/html]
ちなみに、インストールしてしまってもインストールパスは、/opt/gitlab/配下になるのでインストールしてしまっても大丈夫です。後でポート変更や、有効・無効を設定してあげます。
他にも以下のような設定が可能です。他の機会に書いておこうと思います。
・外部smtpの利用
・ユーザ認証の連携
・httpsへの変更
インストール
/etc/gitlab/gitlab.rbの設定が完了したら、インストールを実施します。omnibusのGitLabはchefでラップされています。
設定ファイルの読み込みをします。
[html]# sudo gitlab-ctl reconfigure[/html]
起動確認します。
[html]# sudo gitlab-ctl status
run: logrotate: (pid 507) 2096s; run: log: (pid 501) 2096s
run: nginx: (pid 506) 2096s; run: log: (pid 505) 2096s
run: postgresql: (pid 512) 2096s; run: log: (pid 503) 2096s
run: redis: (pid 509) 2096s; run: log: (pid 504) 2096s
run: sidekiq: (pid 4425) 127s; run: log: (pid 502) 2096s
run: unicorn: (pid 4556) 72s; run: log: (pid 510) 2096s
[/html]
サイトに接続します。URL設定で指定したURLをブラウザで表示します。
http://yourdomain.example.com/
Username: root
Password: 5iveL!fe
こちらでログインが出来ればOKです。
設定変更をする場合は
設定変更をした場合は以下のように変更の反映や再起動を実施できます。主だったものだけ書いておきます。
状態確認
[html]# sudo gitlab-ctl status[/html]
設定の反映
[html]# sudo gitlab-ctl reconfigure[/html]
再起動
[html]# sudo gitlab-ctl restart[/html]
[amazonjs asin=”4797380365″ locale=”JP” title=”デザイナーからプログラマーまで 絶対わかるGitバージョン管理”]