2013/04/11 頃の作業。
見ていた資料Webページが古いモノだったのでGitLab5.x系のセットアップとはあわなかったよという体験談。
全く参考にはならないが手順として残しておく。
redisのインストールが後で必要になるぐらいの産物か。
最初はここを参考にしていたが公式手順は違った。
gitolite は gitlab 5.x系では不要である。
ユーザ追加
GitLabのにはgitolite(perlアプリ)が必要なのでそれ用のユーザ、およびGitLabの実行用ユーザを追加します。
さらに/home/git以下の読み込み権限をグループに与えてリポジトリ参照を可能にします。
$ su
# useradd git
# useradd gitlabhq
# usermod -G git gitlabhq
# chmod g+rx /home/git
続いてgitolite への接続用に gitlabhq の公開鍵を作成します。
# su - gitlabhq
$ ssh localhost (キャンセルする)
$ ssh-keygen -t rsa -P "" -f ~/.ssh/gitadmin
$ exit
# mv /home/gitlabhq/.ssh/gitadmin.pub /home/git
gitolite インストール
git の管理ツール gitolite をインストールします。
# su - git
$ git clone git://github.com/gitlabhq/gitolite
$ gitolite/install
Can't locate Time/HiRes.pm in @INC (@INC contains: /home/git/gitolite/src/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /home/git/gitolite/src/lib/Gitolite/Common.pm line 76.
やっぱり依存関係が強いのか。
MySQL関連が手作業インストールなので衝突を確認しながら --skip-broken 対応。
$ exit
# yum groupinstall 'Additional Development'
(中略)
Error: mysql conflicts with MySQL-server-5.6.10-1.el6.x86_64
Error: MySQL-client conflicts with mysql-5.1.67-1.el6_3.x86_64
Error: mysql-devel conflicts with MySQL-devel-5.6.10-1.el6.x86_64
Error: MySQL-server conflicts with mysql-5.1.67-1.el6_3.x86_64
Error: MySQL-devel conflicts with mysql-devel-5.1.67-1.el6_3.x86_64
MySQLだけなので--skip-brokenでえいや!
# yum -y groupinstall 'Additional Development' --skip-broken
# yum install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc gitolite sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel
# su - git
$ gitolite/install
use the following full path for gitolite:
/home/git/gitolite/src/gitolite
$ gitolite/src/gitolite setup -pk /home/git/gitadmin.pub
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/
WARNING: /home/git/.ssh missing; creating a new one
WARNING: /home/git/.ssh/authorized_keys missing; creating a new one
余談だがここにきてruby環境構築は rbenv などを使うのが流行だと知る。まぁ仕方なし。
(後日rbenv環境へ移行しました)
Redisのインストール
redis は結構高速滑軽量なkey-valueストアDB。単純な文字列型以外にも方をサポートしている他レプリケーションやシャーディングといった機能も備えている。
・・・yumで入るのが素晴らしい
$ exit
# yum install -y python-devel python-pip redis libicu-devel
# pip-python install pygments
# chkconfig redis on
# service redis start
GitLabのインストール
後はGitLabだけ。
# su - gitlabhq
$ git clone git://github.com/gitlabhq/gitlabhq.git
$ cd ./gitlabhq/
$ bundle install --deployment --without development test
$ mysql -u root -p
mysql> CREATE USER gitlabhq@localhost IDENTIFIED BY 'gitlabhq';
mysql> CREATE DATABASE gitlabhq_production;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO gitlabhq@localhost;
$ cp config/gitlab.yml.example config/gitlab.yml
$ vi config/gitlab.yml
(localhostをcollieに変更)
$ cp config/database.yml.mysql config/database.yml
$ vi config/database.yml
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: gitlabhq
password: gitlabhq
$ exit
# cd /home/gitlaghq/gitlabhq/
# chown -R git log/
# chown -R git tmp/
# chmod -R u+rwX log/
# chmod -R u+rwX tmp/
# su - gitlabhq
$ cd
$ bundle exec rake gitlab:setup RAILS_ENV=production
Warning
You are running as user gitlabhq, we hope you know what you are doing.
Things may work/fail for the wrong reasons.
For correct results you should run this as user git.
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)? no
ここに来て全く変わっていることに気がつく。
gitlabユーザではなくgitユーザ側に用意しろとか。
汚染されているのは git/gitlabユーザ配下のみなので最初からやりなおすこととする。