設定した環境
フロントの Nginx は https である。
URL は<ドメイン>/gitlab で受ける.
さくらの VPS
Ruby 1.9, MySQL で Redmine 2.3 が既に動いている。
gitユーザを追加 1 $ sudo adduser --disabled-login --gecos 'GitLab' git
GitLab shell のセットアップ インストール 1 2 3 4 5 6 $ sudo -u git -i $ cd /home/git $ git clone https://github.com/gitlabhq/gitlab-shell.git $ cd gitlab-shell $ git checkout v1.5.0 $ cp config.yml.example config.yml
※バージョンは最新のものにチェックアウト
設定 config.yml config.yml の gitlab_url を外から見えるURLに変更する。
gitlab_url: “https://<ドメイン>/gitlab/“
ライブラリのインストール 1 2 $ sudo apt-get install libicu-dev $ sudo gem install charlock_holmes --version '0.6.9.4'
データベースのセットアップ MySQL を使うhttps://github.com/gitlabhq/gitlabhq/blob/master/doc/install/databases.md に従う。 ※gitlab ユーザのパスワードを控える。
GitLab のセットアップ インストール 1 2 3 4 5 6 $ sudo -u git -i $ cd /home/git $ git clone https://github.com/gitlabhq/gitlabhq.git gitlab $ cd gitlab $ git checkout v5.2.1 $ cp config/gitlab.yml.example config/gitlab.yml
※バージョンは最新のものにチェックアウト
環境整備 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 $ chown -R git log/ $ chown -R git tmp/ $ chmod -R u+rwX log/ $ chmod -R u+rwX tmp/ $ mkdir /home/git/gitlab-satellites $ mkdir tmp/pids/ $ mkdir tmp/sockets/ $ chmod -R u+rwX tmp/pids/ $ chmod -R u+rwX tmp/sockets/ $ mkdir public/uploads $ chmod -R u+rwX public/uploads $ git config --global user.name "GitLab" $ git config --global user.email "gitlab@localhost" $ cp config/puma.rb.example config/puma.rb $ cp config/database.yml.mysql config/database.yml
設定 config 内の各ファイルを変更する。 database.yml の IDとパスワードをセットする。 下記のとおり、gitlab.yml を変更。
1 2 3 4 5 6 production: &base gitlab: host: <ドメイン> port: 443 https: true relative_url_root: /gitlab
puma.rb の下記を有効にする。
1 ENV['RAILS_RELATIVE_URL_ROOT' ] = "/gitlab"
依存ライブラリのインストールと最終セットアップ 1 2 $ bundle install --deployment --without development test postgres $ bundle exec rake gitlab:setup RAILS_ENV=production
出力される Administrator のログインIDとパスワードを控えておく。
起動スクリプトの整備 1 2 3 $ sudo cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab $ sudo chmod +x /etc/init.d/gitlab $ sudo update-rc.d gitlab defaults 21
セットアップ情報の確認 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 $ sudo -u git -i $ cd /home/git $ bundle exec rake gitlab:env:info RAILS_ENV=production System information System: Ubuntu 12.04 Current User: git Using RVM: no Ruby Version: 1.9.3p0 Gem Version: 1.8.11 Bundler Version:1.3.5 Rake Version: 10.0.4 GitLab information Version: 5.2.1 Revision: 6a868a4 Directory: /home/git/gitlab DB Adapter: mysql2 URL: http://localhost HTTP Clone URL: http://localhost/some-project.git SSH Clone URL: git@localhost:some-project.git Using LDAP: no Using Omniauth: no GitLab Shell Version: 1.5.0 Repositories: /home/git/repositories/ Hooks: /home/git/gitlab-shell/hooks/ Git: /usr/bin/git
Nginx の設定 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 upstream gitlab { server unix:/home/git/gitlab/tmp/sockets/gitlab.socket; } server { … location /gitlab { root /home/git/gitlab/public; if ( -f $request_filename ) { break; } proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://gitlab; } … }
GitLab スタート 1 2 $ sudo /etc/init.d/gitlab start $ sudo /etc/init.d/nginx reload
tilfin
freelance software engineer