Gitlab

1. System

1.1 Packages Install

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y -o Acquire::http::Proxy=none build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev

1.2 Python Install

Install python 2.7

sudo apt-get install python2.7

1.3 MySQL Install

Install mysql

apt-get install -y mysql-server mysql-client libmysqlclient-dev
enter password: *****

1.4 Git User Account

Create a user named git

adduser --disabled-login --gecos 'GitLab' git

switch to git account

su - git

added git to sudoer

adduser git sudo

1.5 Install RVM on user git account

install rvm

\curl -sSL https://get.rvm.io | bash -s stable

check the package by

rvm requirements
rvm install 2.0.0

1.6 Setup git alias and command

git config --global alias.st status
git config --global alias.ci 'commit -a'
git config --global alias.co checkout
git config --global color.ui auto

1.7 upgrade git

gitlab 6.4 branch requires git version higher than 1.7.10

[email protected]:~# git --version
git version 1.7.9.5

So download the latest git from git-core repo

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

After:

[email protected]:~# git --version
git version 1.8.5.2

2. Gitlab-Shell

gitlab-shell is similar to gitolite. key and repository management tool

2.1 Install Gitlab-Shell

let’s download gitlab-shell from github git clone https://github.com/gitlabhq/gitlab-shell.git And set to the stable branch git checkout v1.8.0

2.2 Configuring Gitlab-Shell

gem install bundle bundle cp config.yml.example config.yml nano config.yml edit: gitlab_url: “http://gitlab.bardel.ca/” repos_path: “/home/git/repositories” auth_file: “/home/git/.ssh/authorized_keys”

then run the install script in bin/install It will set up the repos and keys: [email protected]:~/gitlab-shell$ bin/install mkdir -p /home/git/repositories: OK mkdir -p /home/git/.ssh: OK chmod 700 /home/git/.ssh: OK touch /home/git/.ssh/authorized_keys: OK chmod 600 /home/git/.ssh/authorized_keys: OK chmod -R ug+rwX,o-rwx /home/git/repositories: OK find /home/git/repositories -type d -print0 | xargs -0 chmod g+s: OK 2.3 hiccups had an error. git push or2 master /home/git/gitlab-shell/bin/gitlab-shell:8: undefined method `require_relative’ for main:Object (NoMethodError) fatal: Could not read from remote repository.

was caused by git-shell trying to use system ruby. Solution for this was

Adding this in /home/git/.bashrc file before

[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm” # Load RVM into a shell session as a function PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

If not running interactively, don’t do anything

[ -z “$PS1” ] && return

  1. Gitlab 3.1 Installing Gitlab download gitlab repo cd /home/git git clone https://github.com/gitlabhq/gitlabhq.git gitlab switch to stable branch git co -b 6-4-stable bundle
    • I had a problem with installing pg gem.. commented out in Gemfile. 3.2 Configuring Gitlab cp config/gitlab.yml.example config/gitlab.yml nano gitlab.yml edit: gitlab: host: gitlab.bardel.ca email_from: [email protected] support_email: [email protected]

There is a setup for hooking with redmine and ldap wonder how they are suppose to work. connect with LDAP and redmine 3.3 Setting up Database cp config/database.yml.mysql config/database.yml nano config/database.yml RAILS_ENV=production rake db:create RAILS_ENV=production rake db:migrate

3.4 Setting up LDAP auth edit the file in /home/git/gitlab/config/gitlab.yml go to section 2. Auth settings

# 2. Auth settings # ==========================

## LDAP settings # You can inspect the first 100 LDAP users with login access by running: # bundle exec rake gitlab:ldap:check[100] RAILS_ENV=production ldap: enabled: true host: ‘ldap.bardel.ca’ base: ‘ou=Users,dc=bardel,dc=ca’ port: 389 # uid: ‘uid’ method: ‘plain’ # “ssl” or “plain” # Anonymous binding bind_dn: ‘’ # ‘_the_full_dn_of_the_user_you_will_bind_with’ password: ‘’ # ‘_the_password_of_the_bind_user’ allow_username_or_email_login: true

To test bundle exec rake gitlab:ldap:check[100] RAILS_ENV=production

3.4.2 Setting up AD auth edit the file in /home/git/gitlab/config/gitlab.yml go to section 2. Auth settings

# # 2. Auth settings # ==========================

## LDAP settings # You can inspect the first 100 LDAP users with login access by running: # bundle exec rake gitlab:ldap:check[100] RAILS_ENV=production ldap: enabled: true host: ‘dc01.corp.bardel.ca’ base: ‘DC=corp,DC=bardel,DC=ca’ port: 389 uid: ‘sAMAccountName’ password: ‘B1ndus3r’ method: ‘plain’ # “ssl” or “plain” bind_dn: ‘CN=binduser,DC=corp,DC=bardel,DC=ca’ #_the_full_dn_of_the_user_you_will_bind_with’ allow_username_or_email_login: true

To test bundle exec rake gitlab:ldap:check RAILS_ENV=production 3.5 Install Init script Download the init script sudo sp lib/support/init.d/gitlab /etc/init.d/gitlab

To make gitlab start on boot sudo update-rc.d gitlab defaults 21

[email protected]:~/gitlab/lib/support/init.d$ sudo update-rc.d gitlab defaults 21 Adding system startup for /etc/init.d/gitlab … /etc/rc0.d/K21gitlab -> ../init.d/gitlab /etc/rc1.d/K21gitlab -> ../init.d/gitlab /etc/rc6.d/K21gitlab -> ../init.d/gitlab /etc/rc2.d/S21gitlab -> ../init.d/gitlab /etc/rc3.d/S21gitlab -> ../init.d/gitlab /etc/rc4.d/S21gitlab -> ../init.d/gitlab /etc/rc5.d/S21gitlab -> ../init.d/gitlab

3.6 Unicorn setup or Puma setup? copy the example unicorn config cp config/unicorn.rb.example config/unicorn.rb edit: nano config/unicorn.rb 3.7 Sidekiq setup 3.8 Checking the settings run these commands to verify the settings: check system, gitlab and gitlab-Shell bundle exec rake gitlab:env:info RAILS_ENV=production

[email protected]:~/gitlab$ be rake gitlab:env:info

System information System: Ubuntu 12.04 Current User: git Using RVM: yes RVM Version: 1.25.6 Ruby Version: 2.0.0p353 Gem Version: 2.1.11 Bundler Version:1.3.5 Rake Version: 10.1.0

GitLab information Version: 6.4.3 Revision: eef1d9c Directory: /home/git/gitlab DB Adapter: mysql2 URL: http://gitlab.bardel.ca HTTP Clone URL: http://gitlab.bardel.ca/some-project.git SSH Clone URL: [email protected]:some-project.git Using LDAP: yes Using Omniauth: no

GitLab Shell Version: 1.8.0 Repositories: /home/git/repositories/ Hooks: /home/git/gitlab-shell/hooks/ Git: /usr/bin/git

3.9 Gitlab self check check gitlab configure information bundle exec rake gitlab:check RAILS_ENV=production

Many errors: 5 errors and how to fix them: [email protected]:~/gitlab$ be rake gitlab:check RAILS_ENV=production Checking Environment …

Git configured for git user? … no Try fixing it: sudo -u git -H git config –global user.name “GitLab” sudo -u git -H git config –global user.email “[email protected]” For more information see: doc/install/installation.md in section “GitLab” Please fix the error above and rerun the checks. Has python2? … yes python2 is supported version? … yes

Checking Environment … Finished

Checking GitLab Shell …

GitLab Shell version >= 1.7.9 ? … OK (1.8.0) Repo base directory exists? … yes Repo base directory is a symlink? … no Repo base owned by git:git? … yes Repo base access is drwxrws—? … yes update hook up-to-date? … yes update hooks in repos are links: … can’t check, you have no projects Running /home/git/gitlab-shell/bin/check Check GitLab API access: /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in initialize': getaddrinfo: Name or service not known (SocketError) from /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in open’ from /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in block in connect' from /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/timeout.rb:52:in timeout’ from /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:877:in connect' from /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:862:in do_start’ from /home/git/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:851:in start' from /home/git/gitlab-shell/lib/gitlab_net.rb:62:in get’ from /home/git/gitlab-shell/lib/gitlab_net.rb:29:in check' from /home/git/gitlab-shell/bin/check:11:in <main>’ gitlab-shell self-check failed Try fixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u git -H editor /home/git/gitlab-shell/config.yml Please fix the error above and rerun the checks.

Checking GitLab Shell … Finished

Checking Sidekiq …

Running? … no Try fixing it: sudo -u git -H RAILS_ENV=production script/background_jobs start For more information see: doc/install/installation.md in section “Install Init Script” see log/sidekiq.log for possible errors Please fix the error above and rerun the checks.

Checking Sidekiq … Finished

Checking LDAP …

LDAP is disabled in config/gitlab.yml

Checking LDAP … Finished

Checking GitLab …

Database config exists? … yes Database is SQLite … no All migrations up? … yes GitLab config exists? … yes GitLab config outdated? … no Log directory writable? … yes Tmp directory writable? … yes Init script exists? … no Try fixing it: Install the init script For more information see: doc/install/installation.md in section “Install Init Script” Please fix the error above and rerun the checks. Init script up-to-date? … can’t check because of previous errors projects have namespace: … can’t check, you have no projects Projects have satellites? … can’t check, you have no projects Redis version >= 2.0.0? … yes Your git bin path is “/usr/bin/git” Git version >= 1.7.10 ? … no Try fixing it: Update your git to a version >= 1.7.10 from 1.7.9 Please fix the error above and rerun the checks.

Checking GitLab … Finished

3.9.1 Problems

  1. git version -> updated to 1.8.5.2
  2. gitlab-shell config => can’t find the hostname. weird
  3. init script -> copied the file to /etc/init.d folder and run sudo update-rc.d
  4. sidekiq ->
  5. have no projects -> install one more projects

3.9.2 Current problem

  1. gitlab-shell hostname issue
  2. no project issue

3.10 Start gitlab service sudo service gitlab start This will start unicorn web-server and sidekiq

3.11 Precompile Assets sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

3.12 Test rails server be rails s Error: Update 6.3 -> 6.4: uninitialized constant Unicorn (NameError) Fix: added “require(‘unicorn’) before require ‘unicorn/worker_killer”

  1. Nginx 4.1 Install Nginx sudo apt-get install -y nginx

4.2 copy the configuration cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

4.3 edit the config nano /etc/nginx/sites-available/gitlab

4.4 restart nginx sudo service nginx restart

4.5 hiccups: nginx wouldn’t start problem: [email protected]:/etc/nginx# service nginx start Starting nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32 nginx: configuration file /etc/nginx/nginx.conf test failed

Solution: found /etc/nginx/nginx.conf & the ‘server_names_hash_bucket_size: 32 ‘ has a value of 64 although it appears commented out… uncommenting ‘server_names_hash_bucket_size: 32 ‘ did the trick & she’s now running… 4.6 more hiccups: fork didn’t work there was a problem with forking. -> when user fork on the website, it didn’t work problem: each repo needs a satellites which is a git repo. to create a satellites run the following command: [email protected]:~/gitlab$ be rake gitlab:satellites:create RAILS_ENV=production Creating satellites for … Michael Kang / bardelweb … rake aborted! No such file or directory - chdir /home/git/gitlab/lib/gitlab/popen.rb:9:in popen' /home/git/gitlab/lib/gitlab/satellite/satellite.rb:36:in create’ /home/git/gitlab/lib/tasks/gitlab/enable_automerge.rake:31:in block in create_satellites' /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.2/lib/active_record/relation/batches.rb:26:in block (2 levels) in find_each’ /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.2/lib/active_record/relation/batches.rb:26:in each' /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.2/lib/active_record/relation/batches.rb:26:in block in find_each’ /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.2/lib/active_record/relation/batches.rb:75:in find_in_batches' /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-deprecated_finders-1.0.3/lib/active_record/deprecated_finders/relation.rb:70:in find_in_batches’ /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.2/lib/active_record/relation/batches.rb:25:in find_each' /home/git/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.2/lib/active_record/querying.rb:8:in find_each’ /home/git/gitlab/lib/tasks/gitlab/enable_automerge.rake:19:in create_satellites' /home/git/gitlab/lib/tasks/gitlab/enable_automerge.rake:5:in block (3 levels) in <top (required)>’ /home/git/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in eval' /home/git/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in <main>’ Tasks: TOP => gitlab:satellites:create (See full trace by running task with –trace)

solution: mkdir /home/git/gitlab-satellites

then it worked: [email protected]:~/gitlab$ be rake gitlab:satellites:create RAILS_ENV=production Creating satellites for … Michael Kang / bardelweb … … created web / bardelweb … … created pipeline / bpt-maya … … created pipeline / bpt-nuke … … created pipeline / bpt-aftereffects … … created

4.7 more hiccups: merge request didn’t work problem: when user click on merge request, it didn’t work the log says January 07, 2014 14:56 -> ERROR -> Command failed [1]: /usr/bin/git –git-dir=/home/git/gitlab-satellites/pipeline/bpt-maya/.git push origin master

remote: /home/git/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/shared_helpers.rb:2:in require': no such file to load -- rubygems (LoadError) remote: from /home/git/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/shared_helpers.rb:2 remote: from /home/git/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/setup.rb:1:in require’ remote: from /home/git/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/setup.rb:1 remote: error: hook declined to update refs/heads/master To /home/git/repositories/pipeline/bpt-maya.git ! [remote rejected] master -> master (hook declined) error: failed to push some refs to ‘/home/git/repositories/pipeline/bpt-maya.git’

solution: remove default system ruby 1.8 I can confirm that removing ruby1.8 worked for me as well with the very same problem - ssh worked but not http gitlab-shell/hooks/update Running on Ubuntu 12, the git-shell update had this line: #!/usr/bin/env ruby

I am running ruby 2.0.0 and resolved this issue by running: sudo apt-get remove ruby1.8

9.References

http://insanehong.kr/post/gitlab5.1-install-guide/ https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

COMMENTS
Related Post
Docker