Install and Configure GitLab on CentOS 8 / RHEL 8

Posted on 132 views

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 0x51312F3F:
 Userid     : "GitLab B.V. (package repository signing key) "
 Fingerprint: F640 3F65 44A3 8863 DAA0 B6E0 3F01 618A 5131 2F3F
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Importing GPG key 0xF27EAB47:
 Userid     : "GitLab, Inc. "
 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...

The repository is setup! You can now install packages.

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

Install GitLab CE by running the command:

sudo yum install gitlab-ce

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

Dependencies resolved.
======================================================================================================================================================================================================
 Package                                      Architecture                              Version                                             Repository                                           Size
======================================================================================================================================================================================================
Installing:
 gitlab-ce                                    x86_64                                    15.0.3-ce.0.el8                                     gitlab_gitlab-ce                                    1.0 G

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

Total download size: 1.0 G
Installed size: 16 E
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'

Don’t forget to replace gitlab.example.com with your actual domain or sub-domain for GitLab CE.

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.

reconfigure-gitlab-1024x353

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.

install-gitlab-centos-7-fedora-29-set-root-password-1024x514

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

gitlab-login-as-root

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:

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.

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.

Visit Gitlab Documentation page for more learning on GitLab administration.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.