星期五, 4月 17, 2015

Install GitLab on CentOS 6 32bit

GitLab 只提供 64 位元的安裝套件,沒想到在 32 位元的環境這麼難裝,基本上參考一篇快滿三年的文章,再修改一些步驟以解決問題,紀錄一下:

# add current user to sudoers

# www connected

sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

sudo sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo

sudo yum -y groupinstall 'Development Tools' 'Additional Development'

sudo yum -y 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 redis

curl -O http://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz

tar xzvf ruby-2.2.2.tar.gz

cd ruby-2.2.2

./configure --enable-shared --disable-pthread

sudo make && sudo make install

sudo yum -y install qt-devel qtwebkit-devel

export PATH=$PATH:/usr/lib/qt4/bin

alias sudo="sudo env PATH=$PATH"

sudo gem update --system

sudo gem update

sudo gem install rails

sudo adduser --shell /bin/bash --create-home --home-dir /home/gitlab gitlab

sudo passwd gitlab

su gitlab

ssh-keygen -t rsa

# keep default filename, empty for no passphrase

exit

sudo adduser --system --shell /bin/sh --comment 'gitolite'
--create-home --home-dir /home/git git

sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub

sudo passwd git

su git

gl-setup ~/gitlab.pub

# When the prompt appears edit the provided file (it's in a vi-Editor)
and set $REPO_UMASK to 0007

exit

sudo usermod -a -G git gitlab

sudo chmod -R g+rwX /home/git/repositories/

sudo chmod 770 /home/git

sudo service sshd start

su gitlab

ssh git@localhost

exit

exit

su -

curl https://bootstrap.pypa.io/ez_setup.py | python

exit

sudo easy_install pip

sudo pip install pygments

sudo gem install bundler

sudo visudo

# add: gitlab    ALL=(ALL)    ALL

sudo gem install charlock_holmes

sudo yum -y install cmake

sudo gem install rugged -v '0.21.4'

su gitlab

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

cd gitlabhq

bundle install

sudo yum -y install mysql-server

sudo yum -y install nodejs

sudo /etc/init.d/mysqld start

mysql_secure_installation

mysql -u root -p

mysql> CREATE DATABASE gitlab CHARACTER SET UTF8;

mysql> GRANT ALL PRIVILEGES ON gitlab.* TO 'gitlabusr'@'localhost'
IDENTIFIED BY 'supersecret' WITH GRANT OPTION;

mysql> quit

sudo nohup redis-server > /dev/null

# hit CTRL+Z

bg

cp ~/gitlabhq/config/database.yml.mysql ~/gitlabhq/config/database.yml

cp ~/gitlabhq/config/gitlab.yml.example ~/gitlabhq/config/gitlab.yml

vim ~/gitlabhq/config/database.yml

# In database.yml you have to edit the production settings of your
database (at the very top of the file). You have to change the
database-name, username and password.

RAILS_ENV=production rake db:setup

RAILS_ENV=production rake db:seed_fu

bundle exec rails s -e production

# visit http://localhost:3000 with root / 5iveL!fe

以上。日後要啟動 GitLab 服務的步驟也整理在此:

# Terminal #1

sudo /etc/rc.d/init.d/mysqld start

redis-server

# Terminal #2

su gitlab

cd

cd gitlabhq

bundle exec rails s -e production

4 則留言:

  1. 大大,我想情問你如果我的gitlab 想要設定domain name 要怎麼設定呢?
    主要是想要IP 鏈接

    回覆刪除
    回覆
    1. 若想以名稱連到伺服器(而不是藉由 IP 位址),要設好 DNS,與 gitlab 無關。

      刪除
    2. 如果我是想直接透過IP位址連結呢?
      我現在的狀況是 本機端可以用 localhost:3000 或是我自己設的 hosts name
      皆可以上 gitlab ,如果我是用IP 位址連結 就不行了
      nginx 直接用IP 也可以上 可是為啥 IP:3000 就不行上gitlab

      刪除
    3. 這看來仍是網路問題,而不是 gitlab 的問題,可以試試用 trace route、telnet 確定。另外,所謂「不行上
      gitlab」得到什麼錯誤訊息?來自 gitlab 或是 nginx?

      刪除