Gitlab 6.0 (6.x) installation instructions with SCL for Rhel 6.4 and Centos 6.4

Step 1a. If you have a rhel subscription subscribe to the base, optional and redhat software collection beta channel. You will also need the official nginx repository (http://wiki.nginx.org/Install#Official_Red_Hat.2FCentOS_packages).

Step 1. If your on Centos add the SCL repo to your Rhel/Centos installation and bring in the official nginx repository (http://wiki.nginx.org/Install#Official_Red_Hat.2FCentOS_packages ).

# yum install -y centos-release-SCL

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 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/centos still did not update the git version 1.7.1-3.el6_4.1 and we need at least 1.7.10 we also need to add the rpm forge package.

# yum localinstall -y http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Enable the rpmforge extras

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

# yum localinstall -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

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

# yum install -y ruby193 ruby193-ruby-devel ruby193-libyaml ruby193-libyaml-devel git redis nginx python-docutils mysql-server
# service mysqld start 
# service redis start 
# service nginx start 
# chkconfig mysqld on
# chkconfig redis on
# chkconfig nginx 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
# chmod o+x /home/git
# su - git
[git@gitlab ~]$ git config --global user.name "GitLab"
[git@gitlab ~]$ git config --global user.email "gitlab@localhost"
[git@gitlab ~]$ git config --global core.autocrlf input

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

# su - git
[git@gitlab ~]$ git clone https://github.com/gitlabhq/gitlab-shell.git
[git@gitlab ~]$ git clone https://github.com/gitlabhq/gitlabhq.git 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
fi

source /opt/rh/ruby193/enable

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
/opt/rh/ruby193/root/usr/bin/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.7.1

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

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 2c237b7... Fix tests and version up to 1.7.1
[git@gitlab gitlab-shell]$

Step 11. Copy the file config.yml.example to config.yml in the git-shell directory
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 6

[git@gitlab ~]$ cd gitlab
[git@gitlab gitlab]$ ls
app              CONTRIBUTING.md  Gemfile.lock  MAINTENANCE.md  script
Capfile.example  db               Guardfile     Procfile        spec
CHANGELOG        doc              lib           public          tmp
config           features         LICENSE       Rakefile        vendor
config.ru        Gemfile          log           README.md       VERSION

In the community edition
[git@gitlab gitlab]$ git checkout 6-0-stable 

Branch 6-0-stable set up to track remote branch 6-0-stable from origin.
Switched to a new branch '6-0-stable' or master

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 json
1 gem installed
Installing ri documentation for json-1.8.0...
Installing RDoc documentation for json-1.8.0...

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

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/gitlab.local.domb.com/g' /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 /home/git/gitlab/config/unicorn.rb.example to /home/git/gitlab/config/unicorn.rb and configure it. Uncomment lines

72    old_pid = "#{server.config[:pid]}.oldbin"
 73    if old_pid != server.pid
 74      begin
 75        sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
 76        Process.kill(sig, File.read(old_pid).to_i)
 77      rescue Errno::ENOENT, Errno::ESRCH
 78      end
 79    end

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

production:
  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 nginx config in /etc/nginx/conf.d/gitlab.conf

 

upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
  listen *:80 default_server;         # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
  server_name gitlab.local.domb.com;     # e.g., server_name source.example.com;
  server_tokens off;     # don't show the version number, a security best practice
  root /home/git/gitlab/public;

  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;

  location / {
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below
    try_files $uri $uri/index.html $uri.html @gitlab;
  }

  # if a file, which is not found in the root folder is requested,
  # then the proxy pass the request to the upsteam (gitlab unicorn)
  location @gitlab {
    proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    proxy_redirect     off;

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;

    proxy_pass http://gitlab;
  }
}

Step 22. From the gitlab dir execute if installing with mysql support

[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:
login.........admin@local.host
password......5iveL!fe

Step 24. As root Get the init script.

# cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab
# chmod +x /etc/init.d/gitlab

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

Add:
define(`SMART_HOST', `smtp.example.com')dnl
Comment
dnl EXPOSED_USER(`root')dnl

Step 26. Restart sendmail

Step 27. forward all email to a centrail mail address

# echo adminlogs@example.com > /root/.forward
# chown root /root/.forward
# chmod 600 /root/.forward
# echo adminlogs@example.com > /home/git/.forward
# chown git /home/git/.forward
# chmod 600 /home/git/.forward

Step 28. Your done. Start up your server

# service gitlab start

2 thoughts on “Gitlab 6.0 (6.x) installation instructions with SCL for Rhel 6.4 and Centos 6.4”

  1. dear sir:

    in the step 22, i was not able to install the modernizr-2.6.2. i’ve manually installed it. but, i still can not complete the step 22. wish you could give me some hints. thank you.

    best, sam

    bundle install –deployment –without development test postgres
    Fetching source index from https://rubygems.org/
    Could not find modernizr-2.6.2 in any of the sources
    [git@git gitlab]$ bundle exec rake gitlab:setup RAILS_ENV=production
    Could not find rake-10.1.0 in any of the sources
    Run `bundle install` to install missing gems.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.