You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

How can I install GitLab on CentOS 8 / RHEL 8?. 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.

A script is provided for this purpose.

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

If the script execution is successful, you’ll get output similar to below.

Complete!
Generating yum cache for gitlab_gitlab-ce...
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <[email protected]>"
 Fingerprint: 1A4C 919D B987 D435 9396 38B9 1421 9A96 E15E 78F4
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Importing GPG key 0xF27EAB47:
 Userid     : "GitLab, Inc. <[email protected]>"
 Fingerprint: DBEF 8977 4DDB 9EB3 7D9F C3A0 3CFC F9BA F27E AB47
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
Generating yum cache for gitlab_gitlab-ce-source...

Do the same for GPG keys.

: NOKEY
gitlab_gitlab-ce                           1.9 kB/s | 1.7 kB     00:00    
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <[email protected]>"
 Fingerprint: 1A4C 919D B987 D435 9396 38B9 1421 9A96 E15E 78F4
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Is this ok [y/N]: y
Key imported successfully
gitlab_gitlab-ce                                                                                                        4.5 kB/s | 3.9 kB     00:00    
Importing GPG key 0xF27EAB47:
 Userid     : "GitLab, Inc. <[email protected]>"
 Fingerprint: DBEF 8977 4DDB 9EB3 7D9F C3A0 3CFC F9BA F27E AB47
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
Is this ok [y/N]: y

Step 3: Install GitLab CE on CentOS 8 / RHEL 8

Install GitLab CE by running the command:

sudo yum install gitlab-ce

Hit the y to begin installation of GitLab CE on CentOS 8 / RHEL 8.

Last metadata expiration check: 0:03:51 ago on Mon 09 Mar 2020 09:02:50 PM EAT.
Dependencies resolved.
========================================================================================================================================================
 Package                          Architecture                  Version                                   Repository                               Size
========================================================================================================================================================
Installing:
 gitlab-ce                        x86_64                        12.8.5-ce.0.el8                           gitlab_gitlab-ce                        733 M

Transaction Summary
========================================================================================================================================================
Install  1 Package

Total download size: 733 M
Installed size: 1.6 G
Is this ok [y/N]: y

Step 4: Configure GitLab CE on CentOS 8 / RHEL 8

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.

More Git related articles.

Install and Configure GitLab CE on Debian

How To Install GitBucket on Ubuntu / Debian Linux

GitLab and Slack Integration for notifications

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF