ConoHa CentOSにgitlabを導入、そしてサブディレクトリ化

というわけでgitlabをCentOSに導入。


最終目標

1. gitlabを入れる
2. Apacheとnginxを同居(Apache -> nginx転送)
3. サブディレクトリにする。
4. SSL対応

というわけで実施。


まずは
http://d.hatena.ne.jp/toritori0318/20140523/1400863038

ここを見つつgitlabを通常インストール。


というか、ここのDownload > Centos6を見るだけでOKでした。
https://about.gitlab.com/downloads/

yum install openssh-server
yum install postfix
yum install cronie
service postfix start
chkconfig postfix on
lokkit -s http -s ssh
curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.7.2_omnibus.5.4.2.ci-1.el6.x86_64.rpm
sudo rpm -i gitlab-7.7.2_omnibus.5.4.2.ci-1.el6.x86_64.rpm
gitlab-ctl reconfigure


これで目標1はクリア。

次にApache同居とSubdirectory化。



ここを参考に実施。
http://argmax.jp/index.php?gitlab%E3%82%92reverse%20proxy%E4%B8%8B%E3%81%A7%E5%8B%95%E3%81%8B%E3%81%97%E3%81%9F%E3%82%8Asubdirectory%E8%A8%AD%E5%AE%9A%E3%81%97%E3%81%9F%E3%82%8A

まずはgitlab.rbを編集

vim /etc/gitlab/gitlab.rb
external_url "http://xxxx.com" #自分のドメインを入力
external_port "8000"

一旦これを反映。

gitlab-ctl reconfigure

次に色々と置き換えていく

vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
#relative_url_root: /gitlab
↓
relative_url_root: /gitlab
vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

最終行に以下を追加

ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
vim /var/opt/gitlab/gitlab-shell/config.yml
gitlab_url: "http://xxx.com" #恐らく自ドメイン値になっているはず。
↓
gitlab_url: "http://localhost:8080/gitlab"
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
server {
  listen *:8000;  #ポート情報を書き換え
 location ~ ^(assets)/  {
   root /opt/gitlab/embedded/service/gitlab-rails/public;
   gzip_static on; # to serve pre-gzipped version
   expires max;
   add_header Cache-Control public;
 }
↓ 全部コメントアウト(最後のほうにあります。)
 #location ~ ^(assets)/  {
 #  root /opt/gitlab/embedded/service/gitlab-rails/public;
 #  gzip_static on; # to serve pre-gzipped version
 #  expires max;
 #  add_header Cache-Control public;
 #}


これで完了。


あとはgitlabの再起動。

gitlab-ctl stop
gitlab-ctl start


以上。

ここまでで2と3はクリア。

念のため、

service httpd restart

Apacheが動くか(nginxと衝突してないか)を確認しましょう。



あとは4だけ。