:date: 2013-03-31 22:57 .. index:: tech, centos, git, gitlab GitLab on CentOS 6.2 ==================== .. image:: /_images/images/gallery/2013/2013-placeholder/logo-gitlab.png :alt: Gitlab :align: right :scale: 100 I've spent yesterdays night with getting more comfortable with `GitLab `__ on `CentOS `__ 6.2. Since :program:`GitLab` is very easy to install on Debian based systems like Ubuntu, it wasn't going to be that easy. But you'll find a complete walk-through to install it on a CentOS 6.2 64Bit system here. *Spoiler*: In case you didn't get it yet: This is gonna be a tech-post. You can stop reading now. From here downwards it's only getting boring. I was already have way through the modifications on my list when I discovered the modified and corrected posts mentioned at the bottom of this post. They are quite similar to this one. After having it installed I want to mention one or two negative points I caught during the procedure: * The number of packages to install to the basic OS installation is quite high. In a production network this can conflict with installation policies when it comes to the installation of compiler and prohibited packages. * The here described method to start and stop the service is not the *fine, english way* of doing it. It clearly needs some improvements to start the service properly. * This procedure hasn't been tested on any other CentOS version than 6.2 64Bit Other than that it worked fine. -------- Environemnt ----------- * CentOS 6.4 on Virtual Box. Requirements ------------ Installing requirement packages, since most of them are missing. .. code:: bash # Adding Epel requirements $ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm $ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm $ rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm # Installing packages $ yum -y groupinstall 'Development Tools' 'Additional Development' $ yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc gitolite 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 Ruby """" Download Ruby, configure and install it. .. code:: bash $ cd ~ $ curl -O 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 --enable-shared --disable-pthread $ make $ make install Gem """ Now the gems GitLab needs: .. code:: bash $ gem install --system $ gem update $ gem install rails User """" Now we finally can start configure the environment for GitLab. First step is to create a user that will run GitLab. As a Admin for the repositories on the server this user also needs some SSH keys. .. code:: bash $ adduser --shell /bin/bash --create-home --home-dir /home/gitlab gitlab $ su gitlab $ ssh-keygen -t rsa $ exit As :program:`GitLab` is only the graphical back-end, we also need to get :program:`gitolite` running and a user for that one as well. The key from :program:`GitLab` will be the master key for :program:`gitolite` as well. .. code:: bash $ adduser --system --shell /bin/sh --comment 'gitolite' --create-home --home-dir /home/git git $ cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub $ su git $ gl-setup ~/gitlab.pub $ exit :program:`GitLab` needs of course access to the repositories as well. .. code:: bash $ usermod -a -G git gitlab $ chmod -R g+rwX /home/git/repositories/ $ chmod g+r /home/git The GitLab user :samp:`gitlab` will need a password later one. Choose it wisely and do not forget it. .. code:: bash $ passwd gitlab :program:`GitLab` needs now to become aware to :program:`Gitolite` by simply connecting locally. The output denies any login, but will output the available repositories. .. code:: $ su gitlab $ ssh git@localhost The authenticity of host 'localhost (::1)' can't be established. RSA key fingerprint is 6f:5d:9b:c5:d5:16:06:49:b4:d6:e0:87:f7:a4:35:0e. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (RSA) to the list of known hosts. PTY allocation request failed on channel 0 hello gitlab, this is gitolite 2.3.1-1.el6 running on git 1.7.1 the gitolite config gives you the following access: R W gitolite-admin @R_ @W_ testing Connection to localhost closed. exit Python / Pip & gem """""""""""""""""" :program:`GitLab` still needs a few gems we haven't installed yet. .. code:: bash $ cd $ curl http://python-distribute.org/distribute_setup.py | python $ easy_install pip $ pip install pygments $ gem install bundler Usermod & gem """"""""""""" :program:`GitLab` will also do some administrative stuff. It needs therefore extended rights via :program:`sudo`. .. code:: bash shell> vi /etc/sudoers root ALL=(ALL) ALL gitlab ALL=(ALL) ALL # Add this line Now we can continue to install two other gems. .. code:: bash $ gem install ruby-debug19 $ gem install charlock_holmes After this we can do the rest from the :program:`GitLab` user. Cloning """"""" First we switch to the :program:`GitLab` user and get the :program:`GitLab` software from `GitHub `__. .. code:: bash $ su gitlab $ cd ~ $ git clone git://github.com/gitlabhq/gitlabhq.git $ cd gitlabhq We bundle the application and disable the firewall. .. code:: bash $ sudo bundle install $ sudo system-config-firewall-tui #disable firewall $ exit MySQL """"" In this configuration we apply a :program:`MySQL` database to :program:`GitLab`. Therefore we need to install that one as well and set it up properly. .. code:: bash $ yum -y install mysql-server $ /etc/init.d/mysqld start $ mysql_secure_installation We also need to create a database user with the appropriate rights to connect to so that :program:`GitLab` can use the database. For connecting to the database as user :samp:`root`, use the password you've chosen in the previous step while securing the database with :command:`mysql_secure_installation`. .. code:: bash $ mysql -u root -p # when prompted enter the root password you've chosen in the previous step. mysql> CREATE DATABASE gitlab CHARACTER SET UTF8; mysql> GRANT ALL PRIVILEGES ON gitlab.* TO 'gitlabusr'@'localhost' IDENTIFIED BY 'supersecret' WITH GRANT OPTION; mysql> quit For the deployment of the database, :program:`GitLab` comes with a script, but we need the :program:`redis` server for this. .. code:: bash $ yum -y install redis $ sudo nohup redis-server > /dev/null GitLab configuration """""""""""""""""""" For :program:`GitLab` being able to start we need to create the basic configuration from the example files. Since we're using a :program:`MySQL` database, we use the example for :program:`MySQL` databases :file:`database.yml.mysql`. .. code:: bash $ su gitlab $ cd $ cp ~/gitlabhq/config/database.yml.mysql ~/gitlabhq/config/database.yml $ cp ~/gitlabhq/config/gitlab.yml.example ~/gitlabhq/config/gitlab.yml Database.yml '''''''''''' Since we've setup a user and a password for the connection to the Database, we should put those credentials in there as well: .. code:: bash $ cat ~/gitlabhq/config/database.yml # # PRODUCTION # production: adapter: mysql2 encoding: utf8 reconnect: false database: gitlab pool: 5 username: gitlabusr password: "supersecret" # host: localhost # socket: /tmp/mysql.sock Setup DB for redis """""""""""""""""" Finally we setup the DB structure with the little help of two scripts (The :program:`redis`-server needs to be running, remember?). .. code:: bash $ RAILS_ENV=production rake db:setup $ RAILS_ENV=production rake db:seed_fu Administrator account created: login.........admin@local.host password......5iveL!fe The password is initially always the same. Start the server """""""""""""""" .. code:: bash $ sudo bundle exec rails s -e production Sources """"""" These pages have helped getting the right commands and tools into place. * `Installing GitLab on CentOS 6.2 (Part 1) `__ * `Installing GitLab on CentOS 6.2 (Part 2) `__ * `Fixed version `__