GlitLab是github的一个本地实现,可以把它看做是github的一个山寨版本

它是用Ruby实现的,依赖的库很多,安装起来比较麻烦

主要参考https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md去安装

机器环境是RHEL 5.7

1. 安装依赖包

yum install sqlite
yum install sqlite-devel
#yum安装的sqlite不好使,只好编译源码了
 wget 'http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz'
wget 'http://asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz'
 make install;check install;
yum install  libxml2-devel
yum install libxslt-devel
yum install libicu-devel
yum install mysql-devel
yum install redis
wget "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
./configure

2. 安装ruby

wget "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz"
./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
make;make install

3. 安装gitolite

#安装GitoLite
adduser -r -s /bin/sh -c 'git version control' -m gitolite
usermod -a -G gitolite gitlab
chmod 755 /home/gitolite/ -R
su - gitolite
 git clone http://github.com/gitlabhq/gitolite /home/gitolite/gitolite
 echo -e "PATH=\$PATH:/home/gitolite/bin\nexport PATH" >> /home/gitolite/.profile
 PATH=/home/gitolite/bin:$PATH; /home/gitolite/gitolite/src/gl-system-install
 sed -i 's/0077/0007/g' /home/gitolite/share/gitolite/conf/example.gitolite.rc
 PATH=/home/gitolite/bin:$PATH; gl-setup -q /home/gitolite/gitlab.pub
 chmod -R g+rwX /home/gitolite/repositories/
 chown -R gitolite:gitolite /home/gitolite/repositories/

4. 安装gitlab

useradd gitlab -g git
chmod -R g+rx /home/gitolite/
chmod -R g+rwX /data/gitroot/repositories/
su - git
 sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc
su - gitlab
 ssh-keygen
 mkdir tmp
 git clone gitolite@mtpc.sohu.com:gitolite-admin.git /tmp/gitolite-admin
#需要将gitlab设置成gitolite的管理员
yum install setuptools
/opt/apps/python/bin/easy_install pygments
#由于rubygem被墙,所以使用淘宝的源
gem sources -r http://rubygems.org/
gem sources -a http://ruby.taobao.org/
vi Gemfile
 source 'http://ruby.taobao.org/'
gem install charlock_holmes
 #如果没有安装yaml,则会报错:
 /opt/apps_install/ruby-1.9.3/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
 It seems your ruby installation is missing psych (for YAML output).
 To eliminate this warning, please install libyaml and reinstall your ruby.
gem install bundler
gem install rails
gem install linecache19  --with-ruby-include=/usr/local/include/ruby-1.9.1/ruby/
su - gitlab
 cd /home/gitlab/
 git clone -b stable git://github.com/gitlabhq/gitlabhq.git gitlab
 cd gitlab
 mkdir tmp
 cp config/gitlab.yml.example config/gitlab.yml
 vi config/gitlab.yml
 cp config/database.yml.sqlite config/database.yml
 vi config/database.yml
 bundle install --without development test --deployment 
  #git clone error
  修改Gemfile和Gemfile.lock文件,将https://github.com修改为http://github.com
 #安装DB
 bundle exec rake gitlab:app:setup RAILS_ENV=production
 bundle exec rake gitlab:app:status RAILS_ENV=production
 #启动gitlab
 bundle exec rails s -e production -d
 bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
 ./resque.sh
 cp config/unicorn.rb.orig config/unicorn.rb
 bundle exec unicorn_rails -c config/unicorn.rb -E production -D
 #LDAP
  cp config/initializers/omniauth.rb.sample config/initializers/omniauth.rb

以上成功安装后,按照官方文档,再配置相应的nginx即可访问了