[http://gitlabhq.com/ Gitlab] is a free git repository management application based on [[Ruby on Rails]] and [[Gitolite]]. It is distributed under the MIT License and its source code can be found on [https://github.com/gitlabhq/gitlabhq Github]. It is a very active project with a monthly release cycle and ideal for businesses that want to keep their code private. Consider it as a self hosted Github but open source. You can try a demo page [http://gitlabhq.com/ here].

+

[http://gitlab.org/ Gitlab] is a free git repository management application based on [[Ruby on Rails]]. It is distributed under the MIT License and its source code can be found on [https://github.com/gitlabhq/gitlabhq Github]. It is a very active project with a monthly release cycle and ideal for businesses that want to keep their code private. Consider it as a self hosted Github but open source. You can try a demo [http://demo.gitlabhq.com/ here].

−

{{Note|Throughout the article, sudo is heavily used, assuming that the user that is running the commands is root or someone with equal privileges. There is no need to edit the sudoers file whatsoever. It is only used to change to the appropriate user. For more info read {{ic|man sudo}}.}}

{{Note|Throughout the article, sudo is heavily used, assuming that the user that is running the commands is root or someone with equal privileges. There is no need to edit the sudoers file whatsoever. It is only used to change to the appropriate user. For more info read {{ic|man sudo}}.}}

{{Note| In order to receive mail notifications, make sure to install a mail server. By default, Archlinux does not ship with one. The recommended mail server is [[postfix]], but you can use others such as [[SSMTP]], [[msmtp]], [[sendmail]], [https://wiki.archlinux.org/index.php/Category:Mail_Server etc].}}

−

Add {{ic|git}} and {{ic|gitlab}} user. {{ic|git}} is a system user that will be used for [[gitolite]]. {{ic|gitlab}} user will be used for Gitlab and is part of group git.

+

== PKGBUILDs for Gitlab and Gitlab-shell ==

+

There are some (not fully working) PKGBUILDs available to create installable packages:

Note that the user ''git'' must have its initial group set to ''git'' (not ''users''). If the initial group is not ''git'', then all files created by the ''git'' user will be owned by git:users which will prevent gitlab from showing you a newly created repo (it will get stucked at the page where it tells you how to push to the new repo). Running ''sudo usermod -g git git'' will set the ''git'' user's initial group.

Clone the gitolite repository from Gitlab's fork. Note that it's version 3.

+

GitLab supports [[ruby]] >= {{ic|1.9.3}} and {{ic|2.0.0}}, but some dependencies gems work better with ruby {{ic|1.9.3}}. Install it from the official repositories and if you bump into any trouble use [[rvm]] with latest ruby {{ic|1.9.3}}.

{{Note| {{ic|git}} user must have its initial group set to {{ic|git}} (not {{ic|users}}). If the initial group is not {{ic|git}}, then all files created by the {{ic|git}} user will be owned by {{ic|git:users}} which will prevent GitLab from showing you a newly created repository (it will get stucked at the page where it tells you how to push to the new repository).}}

+

+

==gitlab-shell==

+

+

GitLab Shell is an ssh access and repository management software developed specially for GitLab.

{{Tip| If you do not want to download any documentation, add {{ic|gem: --no-rdoc --no-ri}} to {{ic|/home/gitlab/.gemrc}}. Be sure to add it as the gitlab user in order to acquire the appropriate permissions.}}

+

Currently GitLab supports [[MySQL]] and [[PostgreSQL]]. [[MariaDB]] has not been officially tested but it works just fine.

[[pacman|Install]] {{Pkg|mariadb}} and {{Pkg|libmariadbclient}} from the [[official repositories]] and start the [[daemon]]. Create the database and do not forget to replace {{ic|your_password_here}} with a real one.

Because systemd requires full path to binaries to launch (the path is not enough), create a symbolic link in /home/gitlab/bin/ that points to the **bundle** executable. We'll also add the folder to gitlab's PATH:

+

mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

If you are still in favor of {{AUR|mysql}}, follow the same commands as MariaDB.

−

from: notify@example.com

−

</nowiki>}}

−

This is how the mail address will be shown for mail notifications. Gitlab needs the sendmail command in order to send emails (for things like lost password recovery, new user addition etc). This command is provided by packages such as [[msmtp]], [[postfix]], [[sendmail]] etc, but you can only have one of them installed. First, check whether you already have the sendmail command:

+

==Gitlab==

−

# ls /usr/sbin/sendmail

+

===Installation===

−

If you get a ‘cannot access /usr/bin/sendmail’ then install one of the above packages.

+

Clone GitLab's repository:

+

# su - git

+

$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab

+

$ cd gitlab

+

$ git checkout 5-2-stable

−

====Application specific settings====

+

{{Note| You can change {{ic|5-2-stable}} to {{ic|master}} if you want the bleeding edge version, but do so with caution! Check github to see what is the latest stable version and replace above accordingly.}}

−

{{hc|/home/gitlab/gitlab/config/gitlab.yml|<nowiki>

+

===Basic configuration===

−

default_projects_limit: 10

−

# backup_path: "/vol/backups" # default: Rails.root + backups/

−

# backup_keep_time: 604800 # default: 0 (forever) (in seconds)

−

</nowiki>}}

−

*{{ic|default_projects_limit}}: As the name suggests, this integer defines the default number of projects new users have. The number can change from within Gitlab by an administrator.

+

First we need to rename the example file.

−

*{{ic|backup_path}}: The path where backups are stored. Default location is {{ic|/home/gitlab/gitlab/backups}}. The {{ic|backups}} folder is created automatically after first backup.

−

*{{ic|backup_keep_time}}: Time to preserve backups. The default option is to never be deleted.

−

Also check [[#Backup_and_restore| Backup and restore]].

+

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

−

====Git Hosting configuration====

+

The options are pretty straightforward. Open {{ic|config/gitlab.yml}} with your favorite editor and edit where needed.

+

Make sure to change {{ic|localhost}} to the fully-qualified domain name of your host serving GitLab where necessary.

−

{{hc|/home/gitlab/gitlab/config/gitlab.yml|<nowiki>

+

Make sure GitLab can write to the {{ic|log/}} and {{ic|tmp/}} directories:

−

admin_uri: git@localhost:gitolite-admin

−

base_path: /home/git/repositories/

−

hooks_path: /home/git/share/gitolite/hooks/

−

# host: localhost

−

git_user: git

−

upload_pack: true

−

receive_pack: true

−

# port: 22

−

</nowiki>}}

−

*{{ic|admin_uri}}: Do not change it. Leave as is.

+

$ chown -R git log/

−

*{{ic|base_path}}: The path where gitolite's repositories reside. If the repositories directory is different than the default one, change it here.

mysql> grant all privileges on gitlabhq_production.* to 'gitlab'@'localhost' with grant option;

−

mysql> exit;

−

Copy the example configuration file and make sure to update username/password in {{ic|config/database.yml}} at production section:

+

Configure GitLab database settings:

−

# sudo -u gitlab cp config/database.yml.mysql config/database.yml

−

===Install gems===

+

* MariaDB:

−

This could take a while as it installs all required libraries.

+

$ cp config/database.yml.mysql config/database.yml

−

# cd /home/gitlab/gitlab

+

* PostgreSQL:

−

# export PATH=/home/gitlab/bin:$PATH

+

$ cp config/database.yml.postgresql config/database.yml

−

# sudo -u gitlab -H bundle install --deployment

−

{{Note|1= Using "--without development test" in bundle command line will ignore required packages for database backup and restore }}

+

Make sure to update {{ic|username}}/{{ic|password}} in {{ic|config/database.yml}}.

−

===Start redis server===

−

Start the [[daemon]]. If you are using {{Pkg| initscripts}} you might want to add {{ic|redis}} to your {{ic|DAEMONS}} array in {{ic|rc.conf}}.

+

===Install gems===

−

{{Note|redis might already be running, causing a FAIL message to appear. Check if it is already running with {{ic|rc.d list redis}}.}}

+

{{Tip| If you do not want to download any gem documentation, add {{ic|gem: --no-rdoc --no-ri}} to {{ic|/home/git/.gemrc}}. Be sure to add it as the {{ic|git}} user in order to acquire the appropriate permissions.}}

+

{{Note|See bug #[https://bugs.archlinux.org/task/33327 33327] for about system-wide gems. As a temporary solution the following packages will be installed as {{ic|git}} user, make sure {{ic|/home/git/.gemrc}} contains {{ic|gem: ... --user-install}}. And then add the {{ic|bin}} path to the {{ic|PATH}} variable like so {{ic|1=export PATH="$PATH:~/.gem/ruby/2.0.0/bin"}}.}}

−

If you have switched to [[systemd]], there is a service file included in the official package. See [[daemon]] how to enable it.

{{Note|When executing the below and you recieve `Could not verify the SSL certificate for https://rubygems.org/` see bug #[https://github.com/gitlabhq/gitlabhq/issues/4095 GitHub-4095] most likely because you're behind a proxy that tries to inject a local certificate for SSL domains in order to verify its content}}

−

# chown git:git /home/git/.gitolite/hooks/common/post-receive

−

===Check status===

+

If you used MariaDB:

−

With the following commands we check if the steps we followed so far are configured properly. Before running the first command you must edit {{ic|/home/gitlab/gitlab/lib/tasks/gitlab/info.rake}}. The script cannot determine OS version; simply replace {{ic|os_name.squish!}} with {{ic|os_name &#61; "Arch Linux"}}.

{{Note|1= Using {{ic|--without group_name}} in bundle command line will ignore required packages for the mentioned groups.}}

−

Version: 4.0.0

−

Revision: 8ef7b9b

−

Directory: /home/gitlab/gitlab

−

DB Adapter: mysql2

−

URL: <nowiki>http://example.com</nowiki>

−

HTTP Clone URL: <nowiki>http://example.com/some-project.git</nowiki>

−

SSH Clone URL: git@example.com:some-project.git

−

Using LDAP: no

−

Using Omniauth: no

−

Gitolite information

+

===Initialize Database===

−

Version: v3.04-4-g4524f01

−

Admin URI: git@example.com:gitolite-admin

−

Admin Key: gitlab

−

Repositories: /home/git/repositories/

−

Hooks: /home/git/.gitolite/hooks/

−

Git: /usr/bin/git

−

}}

+

{{Note| Make sure the redis [[daemon]] is enabled and started, otherwise the following command will fail. To check the status and see if it's running execute {{ic|systemctl status redis}}, if it's dead start it as per usual via {{ic|systemctl start redis}}}}

−

===Server testing and resque process===

+

Initialize database and activate advanced features:

+

$ bundle exec rake gitlab:setup RAILS_ENV=production

−

[http://defunkt.io/resque/ Resque] is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later. For the backstory, philosophy, and history of Resque's beginnings, please see this [https://github.com/blog/542-introducing-resque blog post].

+

{{Note|If you recieve a error {{ic|No such file or directory - /home/git/repositories/root}} then most likely you've changed the default configuration for {{ic|GitLab}} and you'll need to modify all static paths in {{ic|config/gitlab.yml}} and run the above command again to initialize the database!}}

{{Note| Backup folder is set in {{ic|conig.yml}}. Check [[#Application_specific_settings]].}}

+

{{Note| Backup folder is set in {{ic|config/gitlab.yml}}. GitLab backup and restore is documented [https://github.com/gitlabhq/gitlabhq/blob/master/doc/raketasks/backup_restore.md here].}}

===Update Gitlab===

===Update Gitlab===

Line 589:

Line 545:

Finally restore old data.

Finally restore old data.

# sudo -u gitlab bundle exec rake db:data:load RAILS_ENV=production

# sudo -u gitlab bundle exec rake db:data:load RAILS_ENV=production

+

+

===Running GitLab with rvm===

+

+

To run gitlab with rvm first you have to set up an rvm:

+

+

curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3

+

+

{{Note|Version 1.9.3 is currently recommended to avoid some compatibility issues.}}

+

+

For the complete installation you will want to be the final user (e.g. {{ic|git}}) so make sure to switch to this user and activate your rvm:

+

+

su - git

+

source "$HOME/.rvm/scripts/rvm"

+

+

Then continue with the installation instructions from above. However, the systemd scripts will not work this way, because the environment for the rvm is not activated. The recommendation here is to create to separate shell scripts for {{ic|puma}} and {{ic|sidekiq}} to activate the environment and then start the service:

Note: Throughout the article, sudo is heavily used, assuming that the user that is running the commands is root or someone with equal privileges. There is no need to edit the sudoers file whatsoever. It is only used to change to the appropriate user. For more info read man sudo.

Note: In order to receive mail notifications, make sure to install a mail server. By default, Archlinux does not ship with one. The recommended mail server is postfix, but you can use others such as SSMTP, msmtp, sendmail, etc.

PKGBUILDs for Gitlab and Gitlab-shell

There are some (not fully working) PKGBUILDs available to create installable packages:

Ruby

GitLab supports ruby >= 1.9.3 and 2.0.0, but some dependencies gems work better with ruby 1.9.3. Install it from the official repositories and if you bump into any trouble use rvm with latest ruby 1.9.3.

User accounts

Add git user:

# useradd -U -m -d /home/git git

Note:git user must have its initial group set to git (not users). If the initial group is not git, then all files created by the git user will be owned by git:users which will prevent GitLab from showing you a newly created repository (it will get stucked at the page where it tells you how to push to the new repository).

gitlab-shell

GitLab Shell is an ssh access and repository management software developed specially for GitLab.

Gitlab

Installation

Note: You can change 5-2-stable to master if you want the bleeding edge version, but do so with caution! Check github to see what is the latest stable version and replace above accordingly.

Basic configuration

First we need to rename the example file.

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

The options are pretty straightforward. Open config/gitlab.yml with your favorite editor and edit where needed.
Make sure to change localhost to the fully-qualified domain name of your host serving GitLab where necessary.

Install gems

Tip: If you do not want to download any gem documentation, add gem: --no-rdoc --no-ri to /home/git/.gemrc. Be sure to add it as the git user in order to acquire the appropriate permissions.

Note: See bug #33327 for about system-wide gems. As a temporary solution the following packages will be installed as git user, make sure /home/git/.gemrc contains gem: ... --user-install. And then add the bin path to the PATH variable like so export PATH="$PATH:~/.gem/ruby/2.0.0/bin".

Note: When executing the below and you recieve `Could not verify the SSL certificate for https://rubygems.org/` see bug #GitHub-4095 most likely because you're behind a proxy that tries to inject a local certificate for SSL domains in order to verify its content

If you used MariaDB:

$ bundle install --deployment --without development test postgres

If you used PostgreSQL:

$ bundle install --deployment --without development test mysql

Note: Using --without group_name in bundle command line will ignore required packages for the mentioned groups.

Initialize Database

Note: Make sure the redis daemon is enabled and started, otherwise the following command will fail. To check the status and see if it's running execute systemctl status redis, if it's dead start it as per usual via systemctl start redis

Initialize database and activate advanced features:

$ bundle exec rake gitlab:setup RAILS_ENV=production

Note: If you recieve a error No such file or directory - /home/git/repositories/root then most likely you've changed the default configuration for GitLab and you'll need to modify all static paths in config/gitlab.yml and run the above command again to initialize the database!

Check status

With the following commands we check if the steps we followed so far are configured properly.

Edit /etc/nginx/sites-enabled/gitlab and change YOUR_SERVER_IP and YOUR_SERVER_FQDN to the IP address and fully-qualified domain name of the host serving Gitlab. As you can see nginx needs to access /home/gitlab/gitlab/tmp/sockets/gitlab.socket socket file. You have to be able to run sudo -u http ls /home/gitlab/gitlab/tmp/sockets/gitlab.socket successfully. Otherwise setup access to the directory:

# chgrp http /home/gitlab
# chmod u=rwx,g=rx,o= /home/gitlab

Restart gitlab.service, resque.service and nginx.

Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels. First we rename the example file and then we start unicorn:

Now edit config/unicorn.rb and add a listening port by uncommenting the following line:

listen "127.0.0.1:8080"

Tip: You can set a custom port if you want. Just remember to also include it in Apache's virtual host. See below.

Create a virtual host for Gitlab

Create a configuration file for Gitlab’s virtual host and insert the lines below adjusted accordingly. For the ssl section see LAMP#SSL. If you do not need it, remove it. Notice that the SSL virtual host needs a specific IP instead of generic. Also if you set a custom port for Unicorn, do not forget to set it at the BalanceMember line.

Running GitLab with rvm

Note: Version 1.9.3 is currently recommended to avoid some compatibility issues.

For the complete installation you will want to be the final user (e.g. git) so make sure to switch to this user and activate your rvm:

su - git
source "$HOME/.rvm/scripts/rvm"

Then continue with the installation instructions from above. However, the systemd scripts will not work this way, because the environment for the rvm is not activated. The recommendation here is to create to separate shell scripts for puma and sidekiq to activate the environment and then start the service: