Installing GitLab 2.1 on Centos 6

gitlab logo

Step 1: Install needed packages

you will need remove installed ruby because repo version is 1.8.7 and we need 1.9 at least

yum remove ruby

yum install wget

enable epel repos

wget

rpm -Uvh epel-release-6-5.noarch.rpm

install required libraries

yum install readline-devel  libyaml-devel gdbm-devel  ncurses-devel  redis openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-devel curl-devel expat-devel gettext-devel  tk-devel  libxml2-devel libffi-devel libxslt-devel libicu-devel httpd httpd-devel gitolite git-all python-devel python-pip sqlite-devel sendmail vim mysql-devel

Step 2: Install Ruby 1.9.3

wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz

tar xzvf ruby-1.9.3-p0.tar.gz

cd ruby-1.9.3-p0

./configure

make

make install

Step 3: Install gitolite

Create gitolite-admin user

    useradd -d /home/gitolite-admin gitolite-admin

generate RSA key pair for gitolite-admin user

su gitolite-admin
ssh-keygen
exit

Move generate public key to gitolite home dir

cp /home/gitolite-admin/.ssh/id_rsa.pub /var/lib/gitolite/id_rsa_gitolite_admin.pub
chown gitolite:gitolite /var/lib/gitolite/id_rsa_gitolite_admin.pub

complete gitolite and gitolite-admin users pairing

su gitolite
gl-setup /var/lib/gitolite/id_rsa_gitolite_admin.pub

a editor will opened changue repo permissions to 0007

$REPO_UMASK to 0007
exit
su gitolite-admin
cd
git clone gitolite@localhost:gitolite-admin

in the last command you clone the gitolite-admin repo on gitolite-admin’s home. Gitolite-admin repo is gitolite config

before continue we need configure gitolite-admin git profile

git config –global user.email “gitolite-admin@localhost”
git config –global user.name “gitolite-admin”
exit

add gitolite-admin to gitolite group

usermod -a -G gitolite gitolite-admin

changue gitolite-admin password

passwd gitolite-admin

Step 6 Launch Redis

chkconfig redis on

/etc/init.d/redis start

Step 7 GitLab

Clone GitLab sourcecode

cd /var/www

git clone git://github.com/gitlabhq/gitlabhq.git

chown -R gitolite-admin:gitolite-admin gitlabhq/

cd gitlabhq/

Install phython dependencies

pip-python install pygments

Install required gems

gem install bundler

bundle install

su gitolite-admin

bundle install

Prepare config files

cp config/database.yml.example config/database.yml

cp config/gitlab.yml.example config/gitlab.yml

Prepare production enviroment

RAILS_ENV=production rake db:setup
RAILS_ENV=production rake db:seed_fu

you will get these login data

login………admin@local.host
password……5iveL!fe

Config gitolite gitlab link

vim config/gitlab.yml

your  git_host: section must be like this

# Git Hosting congiguration
git_host:
system: gitolite
admin_uri: gitolite@localhost:gitolite-admin
base_path: /var/lib/gitolite/repositories/
host: localhost
git_user: gitolite
# port: 22

fix gitolite permissions

chmod -R 770 /var/lib/gitolite/repositories/

try your installation launching webrick

bundle exec rails s -e production

open a web broser, write  yourhost:3000 and check if everything is working if you get an error send me a comment

Install passenger for Apache

gem install passenger
passenger-install-apache2-module

follow screen instructions

edit apache config file

vim /etc/httpd/conf/httpd.conf

and append these lines at the end

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
PassengerRuby /usr/local/bin/ruby

enable apache service

/etc/init.d/httpd start

chkconfig httpd on

Sources

http://wasil.org/en/gitlab-installation-on-fedora-16-with-gitolite

http://rickfoosusa.blogspot.com/2011/08/gitolite-tutorial-senawario.html

46 Replies to “Installing GitLab 2.1 on Centos 6”

  1. Are you sure this guide is not missing anything? Because I followed the guide carefully and in the end I was able to login to gitlab but I can’t create projects or add SSH keys.

    I checked the terminal and looks like it’s prompting for a password when you try to add new project or SSH key:

    git@localhost’s password:

    then it “times out” and I gen an error in the browser.

    Could this mean that gitlab is ignoring my config/gitlab.yml file? It should be gitolite and not git, right?

    1. Tru gitolite-admin@localhost instead git@localhost.
      I will create a virtual machine and retest the process, my personal server was installing using these commands and it’s working
      Thanks for your comment

      1. This is what it looks like in the terminal: http://img854.imageshack.us/img854/4018/screenshotexe.png

        It’s the same with no matter which user you run your rails app.

        Now when it’s waiting for the password, the browser is actually trying to load the page at that point. For example, when you fill in the info for a new project and press “Save”, that’s when this prompt appears. Of course, you can’t notice it unless you’re directly watching the console window.

        So my question is, why does it invoke git@localhost even though I haven’t set it anywhere in the config? Is it supposed to be like this? If yes, then what does “git_user” option in the settings mean? Keep in mind that my config/gitlab.yml config looks EXACTLY like in this guide. There must be something that I’m missing.

        BTW, I checked REPO_UMASK and it’s set to 0007 as it should be.

        1. I’m replying using my phone, really bad enviroment.
          Smells that the problem is gitolite, open a terminal and type
          su gitolite-admin
          git clone “gitolite admin repository”
          Next ensure that gitlab files are owned by gitolite-admin user
          And finally reboot your system.

          Another problem must be that gitolite-admin user hasn’t started session.
          If reboot doesn’t work try
          Su gitolite-admin
          passwd
          exit
          and finaly
          ssh gitolite-admin@localhost

          I hope solve your problem

  2. Hi!

    Where gitlab save they repositories? /var/lib/gitolite/repositories/ ?

    Can i change this path to /home/gitolite directory, who is mounted to bigger partition?

    1. One option is move gitolite user home dir from /var/lib/gitolite to /home/gitolite

      Another option is using gl-setup one parameter is the repo dir.

  3. Hi I followed the steps but I am not able to create projects in the web interface. Everytime it says error check your gitlab.yml file and permission..

    I am wondering which step I am missing.. I am using censtos 6.2

    1. try rebooting your system.
      if not the problem it’s in step3
      basically gitlab can’t access to gitolite.
      try checking my conversation with Edmund on the top of comments.

  4. Thanks.. for your wonderful post. I have passed to next step. Now its asking me to add ssh keys and first do git init and then add project.

  5. so far I have been able to configure it..but still getting some error while adding a new project.

    http://fpaste.org/RqWD/

    Not sure what next to be done. The problem with me is I hardly know about gitolite. After days of researching I found your tutorial is able to get me upto this level, in others I am struggling at earlier stage.

  6. Hola,

    Queria hacerte una pregunta.

    Vengo haciendo una integracion entre gitlab y gitolite; ademas, estoy corriendo nginx como servidor web. Todo esto lo hago en una maquina basada en Debian squeeze.

    Tengo funcionando:

    – git-core y gitolite: puedo gestionar repositorios git.
    – gitlab: solo interfaz Web y cosas no relacionadas con gestion de repositorios.

    Cada vez que intento hacer alguna operacion desde gitlab que necesite alterar gitolite y los accesos en gitolite-admin, el sistema me manda un error:

    <>

    Mientras tanto, en el log/unicorn.stderr.log, aparece el siguiente mensaje:

    <>

    Tengo al menos dos dias tratando de dar con el error. He revisado todo lo que considero necesario: config/gitlab.yml, los permisos en ‘repositories’ y la configuracion de usuarios y grupos.

    ¿Que mas podria revisar? ¿Tuviste un problema similar?

    Agradecido 🙂

    -Joaquin

  7. (Perdoname, compañero. Me parece que utilice unos caracteres que no debi y no se publico completo el comentario. Volvere a publicar. Disculpa)

    Hola,

    Queria hacerte una pregunta.

    Vengo haciendo una integracion entre gitlab y gitolite; ademas, estoy corriendo nginx como servidor web. Todo esto lo hago en una maquina basada en Debian squeeze.

    Tengo funcionando:

    – git-core y gitolite: puedo gestionar repositorios git.
    – gitlab: solo interfaz Web y cosas no relacionadas con gestion de repositorios.

    Cada vez que intento hacer alguna operacion desde gitlab que necesite alterar gitolite y los accesos en gitolite-admin, el sistema me manda un error:


    Gitolite Error
    Application cant get access to your gitolite system.

    Mientras tanto, en el log/unicorn.stderr.log, aparece el siguiente mensaje:


    Host key verification failed.
    fatal: The remote end hung up unexpectedly

    Tengo al menos dos dias tratando de dar con el error. He revisado todo lo que considero necesario: config/gitlab.yml, los permisos en ‘repositories’ y la configuracion de usuarios y grupos.

    ¿Que mas podria revisar? ¿Tuviste un problema similar?

    Agradecido 🙂

    -Joaquin

    1. ¿con que usuario creaste la clave de admin para gitolite y con que usuario estas ejecutando el servidor de ruby?

  8. Thanks it’s working. One important thing about any newbie who is trying this. Before gitlab you need to learn more about gitolite. The gitlab is easy to install and use.but the gitolite which is the actual back bone of gitlab and its key management need to be learned.

    And this article is the best among countless gitlab installation article as they dont stress upon the key item that is gitolite.

    Thanks Luzem!

  9. Worked extremely well and it’s up to date. Thank you.

    The only exception I had was installing mysql-server

  10. after gitlab setup, I wanted to import already git repos into gitlab. The import to gitolite system looks fine, as after doing git add remote gitolite@localhost:test.git

    if I clone the above repo I could see my imported stuff has been pushed into gitolite system. However, gitlab is still crying saying

    ” You should push repository to proceed.
    After push you will be able to browse code, commits etc.”

    Any idea?

    1. Hey it worked. Ensure that user that you’re using the launch gitlab has access to the gitolite repository folder.

  11. I am using centos5.6. I am stuck at step 3. when cloning under gitolite-admin I am getting empty repository. Pls help

  12. Hola, he seguido todos los pasos… pero tengo un problema en este paso:
    gem install bundler OK
    bundle install OK
    su gitolite-admin OK
    bundle install KO

    el problema es que me pide ingresar la contraseña por cada paquete que instalo… lo que hice fue agregar al usuario gitolite-admin usando visudo y dejó de hacerlo… pero al finalizar toda la guía…. no me deja crear repositorios 🙁
    creo que falta especificar en algunos casos con q usuario debo quedarme… o con q usuario ejecutar ciertos pasos…

    Gracias por tu tiempo.

    1. superé ese problema… ya puedo crear sin problemas repositorios en gitlab… pero… cuando veo la carpeta
      /var/lib/gitolite/repositories/
      no veo ningún repositorio creado… veo si carpetas con nombres de usuario… pero no los repositorios… me parece q gitlab no se está comunicando bien con gitolite…
      no entiendo bien lo q pasa… otra cosa que veo es q cuando creo un repositorio en gitlab la url que me muestra es:
      ssh: gitolite@192.168.3.191:root/primerrepo.git
      http:

      cuando intentaba clonar el repositorio usando
      git clone url_ssh, me pedia clave para el usuario gitolite….

      cuando intento entrar por url a la url_http del repositorio… me sale que no existe :S

      espero puedas ayudarme.

      gracias.

      1. voy a rehacer el tutorial, lo de la url tienes que cambiar algo en un archivo de configuración.
        los repos creo que estaban en /var/git prueba a hacer un find / | grep “nombrerepo”

        1. Hola,
          gracias por responder.

          Sí… también intenté buscar el repo… pero igual… no lo ubico en ningún lado… lo raro es que si figura dentro del “gitlab” (en su base de datos y en el listado)… pero fisicamente no existe… 🙁

          ojalá puedas hacer ese tutorial pronto

          gracias.

            1. entonces… eso sería normal ?
              lo que aún no soluciono es el tema ese de la URL y de que me pida clave del usuario “gitolite” :S

  13. logré hacer la instalación… pero cada que intento hacer push o enviar mis cambios… me pide contraseña 😐
    intenté verificar la instalación con este comando:
    sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production

    pero me bota un error:
    bundler: command not found: rake

    me quedo estancado ahí… he probado varios tutoriales… y ninguno parece funcionar… puedo crear proyectos… usuarios… permisos… todo… pero cuando intento hacer el push… me pide contraseña :S
    espero puedas ayudarme.

    gracias.
    +

  14. lo intenté… pero me dice que no hay permisos… lo raro es que el usuario gitlab se encuentra dentro de visudo…

    🙁

    no sé q más hacer… es muy frustrante :S

  15. he intentado hacer de cero todos los pasos de tu tutorial pero ya no funciona…. gitlab se actualizó a la versión 4… y no veo forma de bajar la versión 2.1… intenté con la versión 3.1 pero me quedo en
    RAILS_ENV=production rake db:seed_fu,
    por alguna razón hay muchas cosas que dejaron de funcionar…

    la única instalación que me ha funcionado es la de ubuntu.. pero en CentOS nada… ni CentOS 5, ni CentOS 6 🙁

  16. Hola de nuevo…
    tuve un problema aquí:
    ==================
    Install required gems
    gem install bundler
    bundle install
    su gitolite-admin
    bundle install
    ==================

    luego se supone que seguimos con el usuario gitolite-admin
    y ahi ejecutamos el cp config/……., pero me tiraba error de permisos así que agregué el usuario gitolite-admin al visudo y ejecute esa línea con un “sudo” delante y funcionó bien,

    después ejecuté
    RAILS_ENV=production rake db:setup todo OK

    de ahí esta:
    RAILS_ENV=production rake db:seed_fu
    pero no funcionaba me salía algo de permisos… así que lo que hice fue salir de gitolite-admin,
    y lo ejecuté como root… la instalación la terminé estando como root,

    ya dentro del gitlab (web), intenté crear un repositorio… pero en la consola de mi terminal me salió eso de agregar a host conocidos
    =================
    The authenticity of host ‘localhost (::1)’ can’t be established.
    RSA key fingerprint is 78:50:df:dc:fc:a8:a4:b5:54:75:22:54:e2:0d:4a:99.
    Are you sure you want to continue connecting (yes/no)? yes
    =================

    de ahí siguió pero no pudo crear el repo, me salió esto en la web
    ===================
    Git Error
    GitLab was unable to access your Gitolite system.

    3. Diagnostic tool:

    4.
    bundle exec rake gitlab:app:status RAILS_ENV=production

    5. Permissions:
    sudo chmod -R 770 /var/lib/gitolite/repositories/
    sudo chown -R git:git /var/lib/gitolite/repositories/

    lo raro es lo último “git:git”, no hay ningún usuario “GIT”,

    🙁

    1. otra cosa…
      cuando quiero verificar la instalación (siempre como root)
      usando
      bundle exec rake gitlab:app:status RAILS_ENV=production

      me pide contraseña git@localhost :S
      justo en el momento de verificar si se puede clonar gitlote-admin,
      Can clone gitolite-admin?……….. NO

      hasta ahí llego, quizás hay algún usuario git definido en algún fichero de configuración… aunque dentro de config/gitlab.yml no encuentro nada de eso… donde más puede estar ?

    2. Corregí el fichero gitlab.yml, olvidé cambiar algo… pero ahora me pedía permisos para el usuario gitolite,
      así que ya a la fuerza ejecute:
      passwd gitolite, y le puse un password

      ahora ejecuto el test de nuevo y cuando me pide el password ingreso el q acabo de poner.
      y me sale un error que dice:
      fatal: ‘gitolite-admin’ does not appear to be a git repository
      fatal: The remote end hung up unexpectedly
      Can clone gitolite-admin?…………NO

      🙁

Leave a Reply to Edmund Cancel 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.