Skip to content

Gitlab 5.2 on RHEL/Centos 6.4 with SCL / Software Collection outdated

  • by

Redhat release software collection¬†January this year. It’s kind of cool as it lets you install newer versions of ruby perl python etc. Gitlab requires version ruby193 which is very easy to install with scl. This install guide is based on the original gitlab install guide which can be found here “” and shows you howto make gitlab work with SCL instead of RVM.

Step 1. Add the SCL repo to your Rhel/Centos installation

name=Ruby 1.9.3 Dynamic Software Collection

Make sure you are also subscribed to the rhel6-server optional channel. Then install the Development tools

# yum -y groupinstall 'Development Tools'

### 'Additional Development'
# yum -y install vim-enhanced httpd readline readline-devel ncurses-devel gdbm-devel glibc-devel \
               tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc \
               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 sudo mysql-server wget \
               mysql-devel crontabs logwatch logrotate sendmail-cf qtwebkit qtwebkit-devel \
               perl-Time-HiRes libicu-devel libxml2-devel libxslt-devel mysql-devel

Step 2. As rhel still ships with git version 1.7.1-3.el6_4.1 we also need to add the rpm forge package

# yum localinstall -y

Enable the rpmforge extras

Step 3. Gitlab also needs redis which is available on epel.

# yum localinstall -y

Step 4. Lets install ruby193 and git httpd mysql-server and start all the servies

# yum install -y ruby193 ruby193-ruby-devel git redis httpd mysql-server
# service mysqld start 
# service redis start 
# service httpd start 
# chkconfig mysqld on
# chkconfig redis on
# chkconfig httpd on

Step 5. Add the user git and set the git globals

# adduser -r -s /bin/bash -c 'Gitlab user' -m -d /home/git git
# su - git
[git@gitlab ~]$ git config --global "GitLab"
[git@gitlab ~]$ git config --global "gitlab@localhost"

Step 6. su to the git user to clone the git repos

# su - git
[git@gitlab ~]$ git clone
[git@gitlab ~]$ git clone gitlab

Step 7. Extend your .bashrc to have the following content which will load our scl environment for us when we login

# .bashrc
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc


export PATH

Step 8. Make sure the paths are right. You can test this by executing env.

Step 9. Logout and login again as user gitlab. If everything went fine you should be able to do this

[git@gitlab ~]$ which ruby
[git@gitlab ~]$ ruby --version
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

Step 10. As git cd into the git-shell dir and checkout version 1.4

[git@gitlab ~]$ cd gitlab-shell/
[git@gitlab gitlab-shell]$ git checkout v1.4.0
Note: checking out 'v1.4.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 8343298... Fix tests and version up to 1.4.0
[git@gitlab gitlab-shell]$ 

Step 11. Copy the file config.yml.example to config.yml and and replace the hostname localhost with your hostname

[git@gitlab gitlab-shell]$ sed -i 's/localhost/' config.yml

Step 12. Install gitshell

git@gitlab gitlab-shell]$ ./bin/install
mkdir -p /home/git/repositories: true
mkdir -p /home/git/.ssh: true
chmod 700 /home/git/.ssh: true
touch /home/git/.ssh/authorized_keys: true
chmod 600 /home/git/.ssh/authorized_keys: true
chmod -R ug+rwX,o-rwx /home/git/repositories: true
find /home/git/repositories -type d -print0 | xargs -0 chmod g+s: true

Step 13. IMPORTANT. Do this still as the git user! checkout gitlab 5.2

[git@gitlab ~]$ cd gitlab
[git@gitlab gitlab]$ ls
app      Gemfile.lock  script
Capfile.example  db               Guardfile     Procfile        spec
CHANGELOG        doc              lib           public          tmp
config           features         LICENSE       Rakefile        vendor        Gemfile          log        VERSION
[git@gitlab gitlab]$ git checkout 5-2-stable
Branch 5-2-stable set up to track remote branch 5-2-stable from origin.
Switched to a new branch '5-2-stable'

Step 14. Lets configure Gitlab and install the gems

[git@gitlab gitlab]$  gem install bundler
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
1 gem installed
Installing ri documentation for bundler-1.3.5...
Installing RDoc documentation for bundler-1.3.5.

[git@gitlab gitlab]$ gem install charlock_holmes --version ''
Building native extensions.  This could take a while...
Successfully installed charlock_holmes-
1 gem installed
Installing ri documentation for charlock_holmes-
Installing RDoc documentation for charlock_holmes-

Step 15. Configure Gitlab
Copy the example GitLab config and edit the necessary fields.

[git@gitlab gitlab]$ cp /home/git/gitlab/config/gitlab.yml{.example,}
[git@gitlab gitlab]$ sed -i 's/localhost/' /home/git/gitlab/config/gitlab.yml
[git@gitlab gitlab]$ chown -R git /home/git/gitlab/log/
[git@gitlab gitlab]$ chown -R git /home/git/gitlab/tmp/
[git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/log/
[git@gitlab gitlab]$ chmod -R u+rwX  /home/git/gitlab/tmp/
[git@gitlab gitlab]$ mkdir /home/git/gitlab-satellites
[git@gitlab gitlab]$ mkdir /home/git/gitlab/tmp/pids/
[git@gitlab gitlab]$ mkdir /home/git/gitlab/tmp/sockets/
[git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/tmp/pids/
[git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/tmp/sockets/
[git@gitlab gitlab]$ mkdir /home/git/gitlab/public/uploads
[git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/public/uploads

Step 16. Copy the puma.rb config and configure it. Change the bind parameter so that it reads: bind ‘tcp://’

Step 17. Confugre Mysql and change the user and password in the database.yml file

  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_production
  pool: 5
  username: gitlab
  password: "iloveopensource"
  # host: localhost
  # socket: /tmp/mysql.sock

Step 18. Create a Mysql User

[git@gitlab gitlab]$ mysql -u root
# Create a user for GitLab. (change supersecret to a real password)
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'iloveopensource';
# Create the GitLab production database
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# Grant the GitLab user necessary permissions on the table.
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

Step 19. Check if you can login as the gitlab user

[git@gitlab gitlab]$ mysql -u gitlab -p -D gitlabhq_production

Step 20. Secure MySQL by entering a root password and say “Yes” to all questions with the next command

# /usr/bin/mysql_secure_installation

Step 21. Add this as your apache config in /etc/httpd/conf.d/gitlab.conf

      ProxyRequests Off
           Order deny,allow
           Allow from all
        ProxyPreserveHost On
        ProxyPass / http://localhost:9292/
        ProxyPassReverse / http://localhost:9292/

Step 22. From the gitlab dir execute

[git@gitlab gitlab]$ bundle install --deployment --without development test postgres
[git@gitlab gitlab]$ bundle exec rake gitlab:setup RAILS_ENV=production

Step 23. If everything went fine you see:

Administrator account created:

Step 24. Get the init script. As we use SCL instead of RVM we need to change some path variables

# cd /etc/init.d/
# wget
# chmod 755 gitlab
# chkconfig gitlab on

Step 25. If you want you can now configure the mail part. Open /etc/mail/ and add or modify the following lines

define(`SMART_HOST', `')dnl
dnl EXPOSED_USER(`root')dnl

Step 26. Restart sendmail

Step 27. forward all email to a centrail mail address

# echo > /root/.forward
# chown root /root/.forward
# chmod 600 /root/.forward
# echo > /home/git/.forward
# chown git /home/git/.forward
# chmod 600 /home/git/.forward

Step 28. Your done. Start up your server

# service gitlab start