2013/06/02

Redhat 安裝 Gitlabhq [Old]

這是舊的筆記,請前往:
http://zx-1986.blogspot.com/2012/03/setup-gitlab-in-rhel-6.html

this note was out of date! please check the update version:
http://zx-1986.blogspot.com/2012/03/setup-gitlab-in-rhel-6.html

作業系統:RHEL 6.0 i386

cd /opt 

wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm && rpm -i *.rpm

yum groupinstall "Development Tools" # thanks for http://dejant.blogspot.com
yum install libxml2-devel libxslt-devel # thanks for http://dejant.blogspot.com
yum install git libxml2 libxslt sqlite sqlite-devel openssl zlib mysql++-devel mysql++ readline-devel compat-readline5 readline libcurl libcurl-devel libstdc++ libstdc++-devel libstdc++-docs compat-libstdc++-33

yum install python-pip
pip-python install pygments
# yum install python-setuptools
# easy_install pygments

adduser gitlabhq
passwd gitlabhq
visudo
#  gitlabhq    ALL=(ALL)    NOPASSWD: ALL

sudo bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# using sudo for multi-users installed!
# logout, then login as root again

rvm install 1.9.2  
rvm --default use 1.9.2
ruby --version

echo "gem: --no-rdoc --no-ri" > ~/.gemrc
gem update --system  
gem install bundler

echo $rvm_path/src/$(rvm tools strings) 
rvm @global gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/$(rvm tools strings)
exit

su - gitlabhq
ssh-keygen -t rsa

sudo yum install gitosis

sudo adduser -r -s /bin/sh -c 'git version control' -U -m git
sudo usermod -a -G git gitlabhq
sudo usermod -a -G rvm gitlabhq

sudo -H -u git gitosis-init < /home/gitlabhq/.ssh/id_rsa.pub

sudo chmod 755 /home/git
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

cd ~
git clone https://github.com/gitlabhq/gitlabhq.git

cd gitlabhq
vim Gemfile # :%s/git:/https:/g
vim Gemfile.lock # :%s/git:/https:/g

sudo su -

cd /home/gitlabhq/gitlabhq
bundle install # run the "bundle install" as "root" to avoid the permission issue at first time

cd /usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems
mv ./* /tmp

exit

bundle install # run the "bundle install" as "gitlabhq" to make sure all gems in gitlabhq/ grant to "gitlabhq"
bundle exec rake db:setup RAILS_ENV=production
bundle exec rake db:seed_fu RAILS_ENV=production

vim config/gitosis.yml  # 檢查內容與路徑
rails s -e production # 啟動測試服務器

測試網址
http://localhost:3000

預設的帳號密碼
admin@local.host / 5iveL!fe

# 設定 Nginx

sudo su -
yum remove httpd
gem install passenger
passenger-install-nginx-module

# 選擇 1. Yes: download, compile and install Nginx for me. (recommended)
# passenger-install-nginx-module 會自動下載并編譯安裝 Nginx,預設裝到 /opt/nginx

vim /opt/nginx/conf/nginx.conf

---
user gitlabhq;
 
server {
  listen 80;
  server_name YOUR_IP_ADDRESS;
  root /home/gitlabhq/gitlabhq/public;
  passenger_enabled on;
}
---

/opt/nginx/sbin/nginx # start Nginx server
/opt/nginx/sbin/nginx -s stop # stop Nginx server

Reference:
http://isitruby19.com/linecache19
https://github.com/carlhuda/bundler/issues/1356
https://github.com/mark-moseley/linecache/issues/8
https://github.com/gitlabhq/gitlabhq/issues/66
https://github.com/gitlabhq/gitlabhq/issues/34
https://github.com/gitlabhq/gitlabhq/issues/84
https://github.com/gitlabhq/gitlabhq/issues/141