From Gentoo Wiki
(Redirected from Gitlab)
Jump to: navigation, search
This article is a stub. You can help Gentoo Wiki by expanding it.


This guide is a rough port from the official guide and various internet references.
Some of the steps have been consolidated and obviously customized to the standard Gentoo environment.
If something is missing, please make a point of updating this article, with special attention to dependencies please.

If you don’t like long installation guides likes this, you can use unofficial www-apps/gitlabhq ebuild from Fritteli’s Overlay.

The Layman's Guide

The Gitlab overlay in layman, originally the CVUT overlay, is currently on par with the latest gitlab version (7.12 as of June 2015). It supports gitlab migrations in a post-configure step, for those performing upgrades. You can find the repo and issues here. Fritteli's Gentoo overlay provides an alternative, though the installation instructions are not documented here.

The overlay is added to layman using the command

user $layman -a gitlab

One must then add the following keywords to be accepted by portage

user $nano /etc/portage/package.accept_keywords.
=dev-libs/libgit2-M.m.i ~ARCH
=dev-vcs/gitlab-shell-M.m.i ~ARCH
=www-apps/gitlabhq-M.m.i ~ARCH

where ARCH is your architecture and M.m.i are the Major, minor and intermittent/incremental version numbers.

Next emerge and configure the package using the following commands and adhering to the instructions in the emerge output.

user $emerge -av gitlabhq
user $emerge --config gitlabhq

Note : The unicorn.rb file is not mentioned in these instructions but it too resides in /etc/gitlabhq-M.m/ and must be created and modified from it's corresponding .example file.

Otherwise for a more Gentoo-ish approach to installation read on.


root #echo "dev-lang/tk threads" >> /etc/portage/package.use
root #emerge --ask openssl icu ruby dev-vcs/git dev-db/redis sudo

Optional: if you wish to receive mailing notifications from GitLab, then you should probably install a mail server. The recommended server is Postfix.

root #emerge --ask postfix

Next, we tell gentoo to start redis automagically:

root #rc-update add redis default
root #rc-service redis start

Prepare the Necessary Users

root #eselect ruby set ruby20
root #eselect python set python2.7

Gitlab uses the git user, so add it:

root #useradd -m -s /bin/bash -c 'Git Version Control' -d /home/git git
root #echo 'export PATH=$(ruby -rubygems -e "puts Gem.user_dir")/bin:/usr/local/bin:$PATH' >> /home/git/.bashrc

Gitlab shell

root #cd /home/git
root #sudo -u git -H git clone -b v1.9.3 && cd gitlab-shell
git ~/gitlab-shellcp config.yml.example config.yml
edit config.yml with your own domain information or "localhost"
git ~/gitlab-shellnano config.yml
git ~/gitlab-shell./bin/install
If you don't see commit messages in gitlab or an error message while push your commits to gitlab. If you use the unix socket to connect to redis service then also remeber to set the redis.sock permissions.
remote: GitLab: An unexpected error occurred (redis-cli returned 1).
git ~/gitlab-shellusermod -aG redis git
git ~/gitlab-shellnano /etc/redis.conf
unixsocket /var/run/redis/redis.sock
unixsocketperm 770


root #su git
git $cd
git ~ $git clone gitlab
git ~ $cd gitlab
git ~/gitlab $git checkout 6-3-stable

Prepare the Database


Merge mysql if you have not already.

root #emerge --ask mysql

Setup root mysql password.

your config version will probably be different, read emerge output to get your exact command to run
root #emerge --config =dev-db/mysql-5.1.67

Turn on mysql.

root #rc-service mysql start

Set mysql to start upon reboot.

root #rc-update add mysql default

Create the database and user:

set your own passwords for lines 2 and 3
root #mysql -u root -p
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'changeme aka gitlabdbpass';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost' IDENTIFIED BY 'gitlabdbpass';
mysql> quit

Test connecting to the databases with the new user:

root #mysql -u gitlab -p -D gitlabhq_production
Enter Password:
git /home/git/gitlab $cp config/database.yml.mysql config/database.yml
git /home/git/gitlab $nano config/database.yml
add your database password to this config file
root /home/git/gitlab $chmod o-rwx config/database.yml


Merge postgresql-server, or postgresql-base if you have PostgreSQL on another server.

root #emerge --ask postgresql

For PostgreSQL there are different methods of authentification. For a installation on the local machine I prefer using the local account when connecting trough a socket. By default this is enabled.

Create a database and a new user without a password and give him ownership of it. Remember, when connecting trough the socket the shell user is used for authentification, so its name must be git.

root #su postgres -c "psql -d template1"
template1=# CREATE USER git;
template1=# CREATE DATABASE gitlabhq_production OWNER git;
template1=# \q

The git user will need access to the PostgreSQL socket, so it's required to add him to the postgres group

root #gpasswd -a git postgres

And a little test, just to be sure everything went fine:

git /home/git/gitlab#psql -l

Copy the example database configuration file:

git /home/git/gitlab#cp config/database.yml.postgresql config/database.yml

  • Edit the new configuration file and add the database credentials just created:
git /home/git/gitlab#nano config/database.yml
  adapter: postgresql
  encoding: unicode
  database: gitlabhq_production
  pool: 5
  username: gitlab
  # password:
  # host: localhost
  # port: 5432
  socket: /run/postgresql/.s.PGSQL.5432
root /home/git/gitlab $chmod o-rwx config/database.yml

Configure Gitlab

git ~/gitlab $cp config/gitlab.yml.example config/gitlab.yml
edit this file with your domain name (or localhost) & edit your email sent from settings
git ~/gitlab $nano config/gitlab.yml

Deploy Directories

root /home/git/gitlab $
chown -R git log/
chown -R git tmp/
chmod -R u+rwX  log/
chmod -R u+rwX  tmp/
git ~/gitlab $
mkdir /home/git/gitlab-satellites
mkdir tmp/pids/
mkdir tmp/sockets/
mkdir public/uploads
cp config/unicorn.rb.example config/unicorn.rb
nano config/unicorn.rb
cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
nano config/initializers/rack_attack.rb
git config --global "GitLab"
git config --global "gitlab@localhost"
git config --global core.autocrlf input
add workers for higher loads and higher ram counts 3 for 2gb is default example
root /home/git/gitlab #chmod -R u+rwX tmp/pids/
root /home/git/gitlab #chmod -R u+rwX tmp/sockets/
root /home/git/gitlab #chmod -R u+rwX public/uploads

Install Needed Gems

Note that charlock_holmes has a bug on gentoo, so we have to use this workaround:

git /home/git/gitlab $bundle config build.charlock_holmes --with-ldflags='-L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic'

Note that you might experience an error message about a dropped dependency called "modernizr". This is a frontend gem who has been renamed. This has to be added to the Gemfile:

git /home/git/gitlabnano Gemfile

just search the modernizr (v. 2.6.2) package and rename it to "modernizr-rails", "2.7.1". Also Note that a (maybe failing) command, being issued before, has created a Gemfile.lock. This lock file would need an edit as well (two mentions of modernizr).

Then build the package depending on your database setup, excluding the staging and dev environment (which have not been set up yet) and the not-used database:

  • mysql
git /home/git/gitlab $bundle install --deployment --without development test mysql
  • postgresql
git /home/git/gitlab $bundle install --deployment --without development test postgres
If you are having problems installing because of Github's SSL cert, use export GIT_SSL_NO_VERIFY=true

Initialize Database and Activate Advanced Features

git /home/git/gitlab $bundle exec rake gitlab:setup RAILS_ENV=production
Config files seems to be indentation sensitive, so check your files for typos.

Download and Start the Initscript

At the time of writing, this init script is confirmed to work with Gitlab versions 6, just edit the user and home directory:

root #chmod +x /etc/init.d/gitlab
root #/etc/init.d/gitlab start
root #rc-update add gitlab default

Web Frontend


Download the official template and activate it:

root #wget -O /etc/nginx/sites-available/git.domain.tld
root #ln -s /etc/nginx/sites-available/git.domain.tld /etc/nginx/sites-enabled/

Use your favorite text editor to change the relevant portions:

root #nano /etc/nginx/sites-available/git.domain.tld
  listen default_server;
  server_name git.domain.tld;
root #/etc/init.d/nginx restart


go over to the rails page, and fix up passenger...

You need to deviate on the configuration of /etc/apache2/vhosts.d/00_default_vhost.conf file, to adapt DocumentRoot and <Directory> directives to use /home/gitlab/gitlab/public. Thus, add the following virtual host to manage gitlab :

root #mv /etc/apache2/vhosts.d/00_default_vhost.conf /etc/apache2/vhosts.d/00_default_vhost.conf.example
FILE /etc/apache2/vhosts.d/00_default_vhost.conf
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
        DocumentRoot /home/git/gitlab/public
        <Directory /home/git/gitlab/public>

dont forget to

root #/etc/init.d/apache2 restart


root #rc-update add apache2 default

Finish Installing

root #usermod -s /sbin/nologin git

Use your favorite web browser to navigate to the new host you set up
If everything loads properly, the installer has made an admin account for you.

Fresh combination




Run this command to get your full diagnostic.

git /home/git/gitlab#bundle exec rake gitlab:env:info RAILS_ENV=production
git /home/git/gitlab#bundle exec rake gitlab:check RAILS_ENV=production

Push, Pull, Clone

Users to push, pull, clone generate ssh-rsa key.

Using the GitLab web page interface, add your user key to your user, & create new repository.

Many commands will show up, they need to be run on your users computer.

The command 'git push -u origin master' will activate the repository created and allow cloning.

clone using the url the web interface gives you. (replace localhost with IP address, or fully qualified domain name)

user $git clone git@localhost:user/test.git test


In the file /home/gitlab/gitlab/config/gitlab.yml there's a section that controls login from remote sites such as Google, Twitter, and GitHub. change enabled: false to enabled: true. then scroll down and remove all ## marks from

FILE /home/gitlab/gitlab/config/gitlab.yml
#    - { name: 'google_oauth2', app_id: 'YOUR APP ID',
#        app_secret: 'YOUR APP SECRET',

and ensure to leave the leading - on the first line.