(Last Updated On: May 7, 2019)

GitLab is a powerful and Open source git-based platform for accelerated software development and collaboration. It provides up to scratch features like integrated CI/CD, Auto DevOps, Kubernetes integration, GitLab Container Registry e.t.c. In this article, we will delve into the installation of GitLab CE on CentOS 8 / RHEL 8 and the basics of configuring/using it.

The notable advantage of GitLab over other platforms is the myriad of features and integrations available with the open source license. Other platforms will for sure bill you for some features available on GitLab. With that said, let’s see how to Install and Configure GitLab on CentOS / RHEL 8.

Across all operating systems, GitLab has two distinct products:

  • GitLab Community Edition (CE) – Free to use
  • GitLab Enterprise Edition (EE) – Requires purchased license to use.

It’s worth noting that more features can be unlocked by moving to subscription(EE). Check the GitLab subscriptions for details.

Step 1: Update system and Install Dependencies

Update your system and install the required dependencies:

sudo yum -y update
sudo yum -y install curl vim policycoreutils python3-policycoreutils

If you want to install and use local mail server for sending notifications, then install Postfix:

sudo yum -y install postfix

Start and enable Postfix service after the installation.

sudo systemctl enable postfix && sudo systemctl start postfix

For configuration of external email relay service after setting up Gitlab, skip this step and check how to configure an external SMTP server.

Step 2: Add the Gitlab CE Repository

GitLab provides omnibus packages from a repository. These packages are compiled specifically for CentOS/RHEL.

Create a new repository file for GitLab:

sudo vi /etc/yum.repos.d/gitlab-ce.repo

Then add the following lines:

[gitlab-ce]
name=gitlab-ce
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
       https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
metadata_expire=300

Save the file and update your RPM packages index.

sudo yum makecache

Step 3: Install Gitlab CE on CentOS / RHEL 8

Install GitLab CE by running the command:

# EXTERNAL_URL="http://git.example.com" yum install -y gitlab-ce

Step 4: Configure GitLab CE

Our installation is done, we can then do the GitLab configuration that works for our environment. The main configuration file for GitLab is located under /etc/gitlab/gitlab.rb.

sudo vi /etc/gitlab/gitlab.rb

E.g, Set URL on which GitLab will be reachable:

external_url 'http://gitlab.example.com'

Scroll through the configuration file and make changes accordingly. Once done, save the file and run Gitlab reconfiguration script.

sudo gitlab-ctl reconfigure

This will start a Chef local execution to configure GitLab. A successful reconfiguration shows an output like below.

If you have an active firewall, allow http, https and ssh services.

sudo firewall-cmd --permanent --add-service={ssh,http,https} --permanent
sudo firewall-cmd --reload

Step 4: Access GitLab Web Console

Open your browser and go to URL http://gitlab.example.com to finish the installation of Gitlab.

You’re asked to create a new password for your account. Set a new password for root user then click “Change your password“.

You can then login with the root username and password set above. You should be redirected to the GitLab administration dashboard after logging in.

Step 5: Disable User Sign Up ( Recommended)

By default, GitLab allows new users to sign up, this is not usually the case as users are created manually by SysAdmin or user information pulled from external authentication systems such as LDAP.

You can disable this setting to have a secure access management. See:

How to disable GitLab User registration on Login page

Step 6: Secure GitLab with SSL Certificate (Recommended)

SSL is the defacto protocol for securely accessing services in the internet. You can make use of free SSL certificates such as Let’s Encrypt to secure your GitLab server. Refer to our previous guide below.

How to Secure GitLab server with SSL certificate

Step 7: Enable LDAP Authentication (Optional)

For those who use LDAP as a primary method of authentication, GitLab can be configured to use an LDAP server such as FreeIPA to authenticate users.

Configure GitLab FreeIPA LDAP Authentication

Visit Gitlab Documentation page for more learning on GitLab administration.