wake
4/3/2013 - 7:51 PM

Build GitLab 5.1 on DigitalOcen CentOS 6.3 x64

Build GitLab 5.1 on DigitalOcen CentOS 6.3 x64

GitLab 5.1 Installation (DigitalOcen CentOS 6.3 x64)


Or you are looking for


  1. Packages / Dependencies ==========================
yum groupinstall "Development Tools" -y
yum install kernel-devel \
  kernel-headers \
  zlib-devel \
  libyaml-devel \
  openssl-devel \
  gdbm-devel \
  readline-devel \
  ncurses-devel \
  libffi-devel \
  git \
  curl \
  openssh-server \
  redis \
  postfix \
  libxml2-devel \
  libxslt-devel \
  perl-Time-HiRes \
  curl-devel \
  libicu-devel \
  mysql-devel -y
  1. Ruby (1.9.3-p327) ====================

Download and compile it:

mkdir /tmp/ruby && cd /tmp/ruby
curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xz
cd ruby-1.9.3-p392
./configure
make
sudo make install

Install the Bundler Gem:

sudo gem install bundler

If you get

  1. System Users ===============

Create a git user for ‹Gitlab:

sudo useradd -c 'GitLab' git
  1. GitLab shell ===============

Clone gitlab shell

cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git

Switch to right version for v5.1

cd /home/git/gitlab-shell
sudo -u git -H git checkout v1.3.0
sudo -u git -H cp config.yml.example config.yml

Edit config and replace gitlab_url with something like 'http://domain.com/'

sudo -u git -H vi config.yml

Do setup

sudo -u git -H ./bin/install
  1. Database (MySQL) ===================
yum install mysql mysql-devel mysql-server -y

Start mysql and set a password for root@localhost

service mysqld start
mysqladmin -u root password 'YOUR_PASSWORD'

Connect to MySQL and...

  • Create a user for GitLab
  • Create the production database
  • Grant the necessary permissopns
mysql -u root -p
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'GITLAB_PASSWORD';
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
mysql> \q

Try connecting to the new database with the new user

sudo -u git -H mysql -u gitlab -p -D gitlabhq_production
  1. GitLab =========
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
sudo -u git -H git checkout 5-1-stable

Configure it

cd /home/git/gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

Make sure to change "localhost" to the fully-qualified domain name of your host serving GitLab where necessary

sudo -u git -H vi config/gitlab.yml

Make sure GitLab can write to the log/ and tmp/ directories

sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/

Make directory for satellites

sudo -u git -H mkdir /home/git/gitlab-satellites

Create directory for pids and make sure GitLab can write to it

sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo chmod -R u+rwX  tmp/pids/
sudo chmod -R u+rwX  tmp/sockets/

Create public/uploads directory otherwise backup will fail

sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX  public/uploads

Copy the example Puma config

sudo -u git -H cp config/puma.rb.example config/puma.rb

Configure GitLab DB settings

sudo -u git cp config/database.yml.mysql config/database.yml
sudo -u git -H vi config/database.yml

Install Gems

cd /home/git/gitlab
sudo gem install charlock_holmes --version '0.6.9.4'
sudo -u git -H bundle install --deployment --without development test postgres

Configure git

sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@YOUR_DOMAIN_NAME"

Start Redis service

service redis start

Initialize database

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

Install Init Script

sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab

Make GitLab start on boot:

chkconfig gitlab on

Check Application Status

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

If you get

  1. Start all needed service ===========================
sudo service mysql start
sudo service redis start
sudo service gitlab start
  1. Nginx ========

Installation

yum install nginx -y

Download an example site config

sudo curl --output /etc/nginx/conf.d/gitlab.conf https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/nginx/gitlab

Make sure to edit the config file to match your setup:

Change YOUR_SERVER_IP and YOUR_SERVER_FQDN to the IP address and fully-qualified domain name of your host serving GitLab

sudo vi /etc/nginx/conf.d/gitlab.conf

Start

sudo service nginx start
  1. Enjoy ========

Default account

admin@local.host
5iveL!fe

If the GitLab do not start or you get 502 response from Nginx always, go check:

  • Unicorn is running?
  • Sidekiq is running?
  • Can Nginx access path /home/gitlab/gitlab?
  • Enough memory to use?