Thursday 20 March 2014

Install gitlab on CentOS 6.5 / Fedora 19

*** Unfinished / Draft ***


Frustrated by incomplete documentation, wrong tips and hints on multiple boards or blogs and endless trial and errors initiated this page.


I hope this saves some peeps from this Bash Head

Here it goes... ensure you test your steps.
Hint: The font courier and the bold typeface are commands you should run or check ...
Red Highlights: this can be an error and might cause things to break - watch out ...



  1. ensure your OS CentOS or Fedora is up to date.
    I am using CentOS 6.5 and Fedora 19 with MariaDB/MySQL.

  2. run  yum update  and fix all issues, restart the server if a new Kernel has been installed.check the latest kernel is running with ls /boot | grep vmlinuz and uname -r my two examples are:

    CentOS:

    addis [~] > ls /boot | grep vmlinuz
    vmlinuz-2.6.32-431.3.1.el6.centos.plus.x86_64
    vmlinuz-2.6.32-431.el6.x86_64
    addis [~] > uname -r
    2.6.32-431.3.1.el6.centos.plus.x86_64

    Fedora:
    addi
    s [~] > ls /boot | grep vmlinuz
    vmlinuz-0-rescue-addc535f9a442c42bcb0afb2490b80cf
    vmlinuz-3.11.10-100.fc18.x86_64
    vmlinuz-3.12.7-200.fc19.x86_64
    vmlinuz-3.12.8-200.fc19.x86_64
    addis [~] > uname -r
    3.12.7-200.fc19.x86_64

    Gotcha: not the last Kernel is running on Fedora --->>  reboot and fix it !!!
  3. now we need to add another Repository to the already available yum repos
    yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

    your repository listing should look like this:yum repolist
    repo id                       repo name                                          status
    base                          CentOS-6 - Base                                     6,367
    centosplus                    CentOS-6 - Plus                                        24
    contrib                       CentOS-6 - Contrib                                      0
    epel                          Extra Packages for Enterprise Linux 6 - x86_64     10,397
    extras                        CentOS-6 - Extras                                      14
    mariadb                       MariaDB                                                 9
    rpmforge                      RHEL   6 - RPMforge.net - dag                       4,650updates                       CentOS-6 - Updates                                    399repolist: 21,860

    and:

    repo id                       repo name                                          status
    fedora/19/x86_64              Fedora 19 - x86_64                                 36,253updates/19/x86_64             Fedora 19 - x86_64 - Updates                       17,384updates-testing/19/x86_64     Fedora 19 - x86_64 - Test Updates                   6,420repolist: 60,057
  4. next add some packages required for the gitlab install and configure.
    yum -y install vim-enhanced vim-minimal vim-commonyum -y groupinstall "Development Tools"yum --enablerepo=epel -y install libyaml libyaml-devel readline-devel ncurses-devel gdbm-devel tcl-devel openssl-devel db4-devel libffi-devel wgetyum -y install mysql-connector-odbc mysql-connector-javayum -y install python python-docutils git-coreyum -y install MariaDB-shared MariaDB-server MariaDB-devel MariaDB-compat MariaDB-client
  5. now Versions nee to be checked:
    git --version
    Gotcha: need to be 1.7.12 or 1.8.4 or newer.
    ll /usr/share/java/mysql-connector-java.jar
    Gotcha: need to be 5.1.28 or newer.
    rpm -q  MariaDB-server
    Gotcha: need to be 5.5.30 or newer
    ruby --version
    Gotcha: need to be 2.0 or newer.
  6. first fixes:
    there are some strange fixes, well actually these are hacks!
    but we have to ensure all works without breaking any dependencies ...Being confused

    1. git is too old...  lets fix it - remove the wrong version and install the correct one!
        Gotcha: do not use yum erase here !!!
        rm -rf /usr/bin/git* /usr/libexec/git*
        mkdir ~/src; cd ~/src
        curl --progress https://git-core.googlecode.com/files/git-1.8.5.2.tar.gz | tar xz
        cd git-1.8.5.2/
        make prefix=/usr all
        sudo make prefix=/usr install
        This installed git where we deleted it - smart!!!

    2. java-connector too old - get the newer connector
        cd /tmp
        wget http://ftp.jaist.ac.jp/pub/mysql/Downloads/Connector-J/mysql-connector-java-5.1.28.tar.gz
        cd /usr/share/java
        rm /usr/share/java/mysql-connector-java.jar
        tar xfz /tmp/mysql-connector-java-5.1.28.tar.gz
        ln -s mysql-connector-java-5.1.28/mysql-connector-java-5.1.28-bin.jar mysql-connector-java.jar

    3. MySQL / MariaDB too old
        get the latest yum updates from epel or tes/ting.

    4. update ruby
        mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
        wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz -P rpmbuild/SOURCES
        wget https://raw.github.com/hansode/ruby-2.0.0-r      pm/master/ruby200.spec -P rpmbuild/SPECS
    rpmbuild -bb rpmbuild/SPECS/ruby200.spec
    rpm -Uvh rpmbuild/RPMS/x86_64/ruby-2.0.0p353-2.el6.x86_64.rpm
    ruby -v
    gem -v
  7. Create the git user:
    adduser --system --shell /sbin/nologin --comment 'GitLab' --create-home --home-dir /var/lib/git git
  8. Install GitLab-Shell.
    cd /var/lib/git
    sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0
    cd gitlab-shell
    sudo -u git -H cp config.yml.example config.yml
    edit the config.yml and replace domain with a proper domain
    sudo -u git -H /usr/local/bin/ruby ./bin/install
  9. Create the database.
    log into MySQL (on localhost or on db-server)
    CREATE USER 'git'@'localhost(remote host)' IDENTIFIED BY 'supersecret';
    CREATE DATABASE IF NOT EXISTS `gitlab_db` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
    GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlab_db`.* TO 'git'@'localhost (or other hostname)';

    Test the MySQL connection.
  10. Install GitLab
    cd /var/lib/gitsudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-6-stable gitlab
    sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
    edit config/gitlab.yml and configure the
        domain properly
        data path to where you want the repositories to live (i.e.  /data/repos)

    sudo chown -R git log/
    sudo chown -R git tmp/
    sudo chmod -R u+rwX  log/
    sudo chmod -R u+rwX  tmp/
    sudo -u git -H mkdir /home/git/gitlab-satellites
    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/
    sudo -u git -H mkdir public/uploads
    sudo chmod -R u+rwX  public/uploads

    sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
    edit config/unicorn.rb to amend the server/memory settings if required.

    sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

    sudo -u git -H git config --global user.name "GitLab"
    sudo -u git -H git config --global user.email "gitlab@localhost" (set to admin email)
    sudo -u git -H git config --global core.autocrlf input
  11. now add the database to gitlab
    sudo -u git -H cp config/database.yml.mysql  
    config/database.yml
    edit the 
    config/database.yml file with the connection details

    install the gems for MySQL
    sudo -u git -H /usr/local/bin/bundle install --deployment --without development test postgres aws

    populate the database
    sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
    enter "Yes" when prompted.
  12. configure the init script and enable Git.
    wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlabrecipes/raw/master/init/sysvinit/centos/gitlab-unicorn
    chmod +x /etc/init.d/gitlab
    chkconfig --add gitlabchkconfig gitlab on
  13. check - start - set-up assets
    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
    service gitlab start
    sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
  14. add apache or nginx 

No comments: