GitLabをインストールする

Ryuzeeさんのブログで公開されていますが、うまくいかなかったので自分なりの遣り方でインストールした方法を記録します。

http://www.ryuzee.com/contents/blog/5779

 

環境

  • CentOS 6.2
  • Ruby 2.0.0 dev (38962)
  • Gitolite 3.3
  • GitLab 4.1.0

手順

環境設定

  1. epelとremiのリポジトリを追加
    epelはリリース番号が変わっているかもしれないので、実行できない場合は最新のリリース番号を調べてください。
    rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
     
  2. 必要なパッケージの追加
    yum install -y gettext rpm-build httpd-devel libcurl-devel gdbm-devel libyaml-devel mysql-server mysql-devel git python-devel python-pip redis libicu libicu-devel postfix ruby gcc-c++ libxml2 libxml2-devel libxslt libxslt-devel
    pip-python install pygments
  3. サービスの追加
    chkconfig --level 2345 redis on
    chkconfig --level 2345 mysqld on
    chkconfig --level 2345 httpd on
    service redis start
    service mysqld start
    service httpd start
  4. Rubyのインストール
    githubからマスターブランチをインストールしたら2.0RCでした。Rubyのビルドにrubyがいるのであらかじめ1.8.xをインストールしておいて、ビルドが終わったら古いバージョンをアンインストールします。
    git clone https://github.com/ruby/ruby.git
    cd ruby
    autoconf
    ./configure
    make
    make install

    rpm -e --nodeps ruby
    ln -s /usr/local/bin/* /usr/bin
  5. Bundlerのインストール
    これを書いてる時点でBundlerをインストールするとバージョンが1.2.3になりますが、Ruby2.0をインストールした場合は1.3でなければ動かないので、バージョンを指定する必要があります。最新版はgithubなどで調べてください。
    https://github.com/carlhuda/bundler/
    gem install bundler --version '1.3.0.pre.7'
  6. ファイヤーウォールを有効にしている場合は、ポートを有効にする
    vi /etc/sysconfig/iptables
    次の内容を追記する
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT

ユーザ登録

useradd git
useradd gitlab
usermod -G git gitlab
chmod g+rx /home/git

passwd git
passwd gitlab

su - gitlab
vi ~/.ssh/config
以下の内容を記述する
Host localhost
HostName localhost
User git
IdentityFile ~/.ssh/gitadmin

chmod 0600 ~/.ssh/config
git config --global user.email "gitadmin@example.com"
git config --global user.name "gitadmin"

ssh localhost
ssh-keygen -t rsa -P "" -f ~/.ssh/gitadmin
exit
exit

 

Gitoliteのインストール

su - git
git clone git://github.com/sitaramc/gitolite
gitolite/install
gitolite/src/gitolite setup -pk .ssh/gitadmin.pub
vi /home/git/.gitolite.rc
次のように内容を変更する
UMASK => 0007,
exit

 

GitLabのインストール

su - gitlab
git clone https://github.com/gitlabhq/gitlabhq.git
cd gitlabhq/
bundle install --deployment --without development test postgres

cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml

bundle exec rake db:setup RAILS_ENV=production
bundle exec rake db:seed_fu RAILS_ENV=production

起動

bundle exec rails s -e production 

デフォルトのログインIDとパスワードは次の通り。

    login………admin@local.host
password……5iveL!fe