bitnamiが配布してる仮想マシンイメージを使えば簡単にGitlabサーバが立てられる!と思ったら全然そんなことなかったので導入手順のメモを作った。
結構はまりどころがあってしんどかった。。これは手作業でインストールした方がいいかもわからん。
GitLab Cloud Hosting, GitLab Hosting - Installers and VM
・virtual boxでubuntu64bit仮想マシンを起動する。
ストレージはbitnami-gitlab-6.3.0-0-ubuntu-12.04.vmdk
設定>ネットワークで以下を設定。
割り当て:NAT
ポートフォワーディング:
9090(ホスト):80(ゲスト)
3000(ホスト):3000(ゲスト)
2222(ホスト):22(ゲスト)
・キーボード配列を日本語にする。一度実行するとログアウト・再ログインしても有効になっているが、マシンを再起動すると無効になるので起動スクリプトに仕込む。
sudo loadkeys jp
・sshdを起動する
sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
sudo start ssh
http://wiki.bitnami.com/Virtual_Appliances_Quick_Start_Guide#How_to_enable_sshd.3f
・/etc/ssh/sshd_configの以下を編集
PermitUserEnvironment yes #=>これをnoにする
・ここまでで外部からのSSH接続が可能になるので接続を確認する。
ただし、パスワードに数字が入っているとなぜかPermission deniedになるので注意。
これ以降はCyberDuckとCotEditorを使って設定ファイルを編集すると編集が楽。ただし、ファイルとファイルがあるフォルダのアクセス権はその他ユーザが書き込み可能になっていないとアップロードが出来ない。
・/opt/bitnami/apps/gitlab/htdoc
・プロキシを設定する
~/.bashrcに以下を追記
proxy=http://proxy:9080/
https_proxy=https://proxy:9080/
export http_proxy=$proxy
export HTTP_PROXY=$proxy
export https_proxy=$https_proxy
export HTTPS_PROXY=$https_proxy
~/.gemrcに以下を追記
http_proxy: http://proxy.example.com:8080
・/opt/bitnami/apps/gitlab/htdocs/config/gitlab.ymlの以下の場所を編集
## Web server settings
host:ホストOSのIPアドレス・ドメイン
port:ホストOSのポート
## Email settings
# Email address used in the "From" field in mails sent by GitLab
email_from: GitLab用メールアドレス
# If you use non-standard ssh port you need to specify it
ssh_port: 2222
・Gitlabをリスタート
sudo /opt/bitnami/ctlscript.sh restart
・rakeのupdate
sudo gem update rake
・正常にインストールされているかチェックする
su git
cd /opt/bitnami/apps/gitlab/htdocs/
bundle exec rake gitlab:check RAILS_ENV=production
・チェックNGだったところを修正
sudo cp /opt/bitnami/apps/gitlab/htdocs/lib/support/init.d/gitlab /etc/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "user@example.com"
・ssh keyでログイン出来るようにする(これをやらないとgit pushできない)
chmod 755 /home/git/.ssh
chmod 644 /home/git/.ssh/authorized_keys
・初期Adminユーザ
user mail: user@example.com
password: bitnami
・Adminユーザでログインし、チームメンバーのユーザを登録
・ssh keyの登録
ssh-keygenを実行し、秘密鍵と公開鍵を作成。
Gitlabにログインし、Profile>SSH Keysから公開鍵を登録。
クライアントマシンの~/.ssh/ に秘密鍵ファイルを置く。
・クライアントマシンの~/.ssh/configに以下を追加。
Host gitlab
User git
Hostname GitlabサーバのIP・ドメイン
Port 2222
IdentityFile /Users/uname/.ssh/id_rsa
・SourceTreeからGitlabにアクセス出来るようにする
ブックマークウィンドウでリポジトリの追加をクリック。
リポジトリをクローン>ソースパス/URLにGitlabのプロジェクトページの右上にあるSSHのURIをコピペ。
クローンボタンをクリックする。