GitLab is a free git repository management application based on Ruby on Rails. It is an interesting alternative if you want to host your own git repositories, since third-party hosting is not always the best option when writing private or closed-source software.
GitLab provides a .deb package which contains GitLab Community Edition and all its dependencies (Ruby, PostgreSQL, Redis, Nginx, Unicorn and other gems) already compiled. Installing this package is straightforward. But since it will install its own package dependencies (Nginx, PostgreSQL, etc), this installation method is suitable if the server is dedicated only to managing git repositories. If you want GitLab to use your existing resources (i.e: you already have Nginx and PostgreSQL installed), you need to install GitLab manually.
This guide will help you install and configure GitLab on your Ubuntu 14.04 (Trusty Tahr) Linode. We will be using the latest Ruby and GitLab as of this writing, so check for the latest version. We will assume that you want to install GitLab on git.example.com and you have configured the DNS properly. If you are new to Linux system administration, you might want to consider the Introduction to Linux Concepts guide and Linux Administration Basics guide guides.
This guide is written for non-root users. Commands that require elevated privileges are prefixed with sudo. If you are not familiar with the sudo command, you can check out our Users and Groups guide.
System Requirements
GitLab is a large and heavy application. To get the most of GitLab, the recommended hardware is as follows:
CPU: 2 cores to support up to 500 users.Memory: 2 GB to support up to 500 users.Prepare System for Deployment
Before beginning with the GitLab installation, make sure that your system’s package database is up to date and that all installed software is running the latest version.
Update your system by issuing the following commands from your shell:
In order to receive mail notifications, you need to install a mail server. Issue the following command to install Postfix mail server:
1
sudo apt-get install postfix
Select Internet site and enter your hostname to complete the installation. If you need to set up a complete SMTP/IMAP/POP3 server, refer to the Email with Postfix, Dovecot, and MySQL guide.
Install Ruby
While GitLab is a Ruby on Rails application, using ruby version managers such as RVM and rbenvis not supported. For example, GitLab shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Thus GitLab can only work with system-wide Ruby installation. In addition, GitLab requires Ruby 2.0 or higher while the default version on Ubuntu 14.04 is 1.9.3.
Remove the old Ruby if present:
1
sudo apt-get remove ruby
The current stable Ruby version as of this writing is 2.1.2. To install Ruby, download the source code and compile the package:
1
2
3
4
5
6
7
mkdir /tmp/ruby && cd /tmp/ruby
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
tar xvzf ruby-2.1.2.tar.gz
cd ruby-2.1.2
./configure --disable-install-rdoc --prefix=/usr/local
make
sudo make install
Check if the installation succeed by checking the Ruby version:
1
ruby -v
Setup PostgreSQL Database for GitLab
GitLab supports both MySQL and PostgreSQL for the database backend, but the latter is recommended. GitLab requires PostgreSQL version 9.1 or higher since it needs to make use of extensions.
If everything is ok, you should see the PostgreSQL version displayed on the console like this:
1
2
3
4
version
------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-16ubuntu6) 4.8.2, 64-bit
(1 row)
Install GitLab
In this section you will install GitLab and make some configuration changes.
We will install GitLab into home directory of the user git. Change the current working directory:
The command above will download the 6-9-stable branch from the GitLab repository. Feel free to select other stable branches, but never install the master branch on a production server.
You need to change the value of host to the fully-qualified domain of your server. Also set the email_from and support_email to the email addresses intended for GitLab.
If you specified a database name other than gitlabhq_production when creating the PostgreSQL database in the previous section, edit the config/database.yml file to match with your database name.
Save and exit the file.
Make sure GitLab can write to the log/ and tmp/ directories:
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)?
Type yes and press Enter to continue.
Install the init script and make GitLab start on boot:
RAWN Technologies Ltd.
GitLab is a free git repository management application based on Ruby on Rails. It is an interesting alternative if you want to host your own git repositories, since third-party hosting is not always the best option when writing private or closed-source software.
GitLab provides a .deb package which contains GitLab Community Edition and all its dependencies (Ruby, PostgreSQL, Redis, Nginx, Unicorn and other gems) already compiled. Installing this package is straightforward. But since it will install its own package dependencies (Nginx, PostgreSQL, etc), this installation method is suitable if the server is dedicated only to managing git repositories. If you want GitLab to use your existing resources (i.e: you already have Nginx and PostgreSQL installed), you need to install GitLab manually.
This guide will help you install and configure GitLab on your Ubuntu 14.04 (Trusty Tahr) Linode. We will be using the latest Ruby and GitLab as of this writing, so check for the latest version. We will assume that you want to install GitLab on git.example.com and you have configured the DNS properly. If you are new to Linux system administration, you might want to consider the Introduction to Linux Concepts guide and Linux Administration Basics guide guides.
This guide is written for non-root users. Commands that require elevated privileges are prefixed with sudo. If you are not familiar with the sudo command, you can check out our Users and Groups guide.
System Requirements
GitLab is a large and heavy application. To get the most of GitLab, the recommended hardware is as follows:
CPU: 2 cores to support up to 500 users.Memory: 2 GB to support up to 500 users.Prepare System for Deployment
Before beginning with the GitLab installation, make sure that your system’s package database is up to date and that all installed software is running the latest version.
Update your system by issuing the following commands from your shell:
Also create a git user for GitLab:
Install Package Dependencies
In this section you will install the development tools and the required packages for GitLab.
Install the required packages to compile Ruby and native extensions to Ruby gems:
Install Git:
In order to receive mail notifications, you need to install a mail server. Issue the following command to install Postfix mail server:
Select Internet site and enter your hostname to complete the installation. If you need to set up a complete SMTP/IMAP/POP3 server, refer to the Email with Postfix, Dovecot, and MySQL guide.
Install Ruby
While GitLab is a Ruby on Rails application, using ruby version managers such as RVM and rbenvis not supported. For example, GitLab shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Thus GitLab can only work with system-wide Ruby installation. In addition, GitLab requires Ruby 2.0 or higher while the default version on Ubuntu 14.04 is 1.9.3.
Remove the old Ruby if present:
The current stable Ruby version as of this writing is 2.1.2. To install Ruby, download the source code and compile the package:
Check if the installation succeed by checking the Ruby version:
Setup PostgreSQL Database for GitLab
GitLab supports both MySQL and PostgreSQL for the database backend, but the latter is recommended. GitLab requires PostgreSQL version 9.1 or higher since it needs to make use of extensions.
Install PostgreSQL if you haven’t installed it:
Create new database and new user by issuing the following commands:
Try connecting to the new database with the new user and display PostgreSQL version for testing:
If everything is ok, you should see the PostgreSQL version displayed on the console like this:
Install GitLab
In this section you will install GitLab and make some configuration changes.
We will install GitLab into home directory of the user git. Change the current working directory:
Download the GitLab source:
The command above will download the 6-9-stable branch from the GitLab repository. Feel free to select other stable branches, but never install the master branch on a production server.
Create the GitLab config file:
Open the file:
You need to change the value of host to the fully-qualified domain of your server. Also set the email_from and support_email to the email addresses intended for GitLab.
/home/git/gitlab/config/gitlab.yml
If you specified a database name other than gitlabhq_production when creating the PostgreSQL database in the previous section, edit the config/database.yml file to match with your database name.
Save and exit the file.
Make sure GitLab can write to the log/ and tmp/ directories:
Create directory for satellites:
Create the Unicorn, Rack attack, and PostgreSQL configuration files:
Make sure that config/database.yml is readable to git only:
Install the gems:
Install GitLab shell, which is an SSH access and repository management software for GitLab:
Open the GitLab shell configuration file:
Check if the value of gitlab_url matches with the URL of your server.
/home/git/gitlab-shell/config.yml
When you are satisfied with the configuration, save and exit the file.
Initialize database and activate advanced features:
The command will display the following message
Type yes and press Enter to continue.
Install the init script and make GitLab start on boot:
Set up logrotate:
Check application status:
Sample output
Compile assets:
Configure Git global settings for the git user:
Set the value for user.email according to what is set in config/gitlab.yml
Start GitLab:
Set Up Nginx Virtual Host for GitLab
Nginx is the only supported web server for GitLab. In this section, you will create a new virtual host for GitLab and activate the site.
Install Nginx if you haven’t installed it:
Copy the sample site config:
Open the config file:
Modify the value for server_name to the fully-qualified domain name of your server:
/etc/nginx/sites-available/gitlab
Save and exit the file.
Deactivate the default virtual host
Activate the site and restart Nginx to take effect
If Nginx failed to start with the following message
1 person likes this