GitLab is a free git repository management tool that allows you to create and manage git repositories. It provides tools for everything an open-source developer would need.

Gitlab has everything that allows a developer to manage their project easily. You can create issues, track your bugs or comments related to your project, keep releases organized, and have much more useful features than the ones you find on GitHub. It integrates perfectly with other development tools like CodeShip, which makes deployments easy and fast.

The difference between GitLab and GitHub is: GitHub is a web-based application while GitLab is an open-source application. GitHub is currently the most popular choice among developers.

Both services are popular for hosting projects of any kind. However, GitHub is more popular among open-source projects. If you search on Google with “GitHub” or “GitLab”, GitLab will return almost four times fewer results than GitHub. This doesn’t mean that GitLab is not good. GitLab is the better choice for self-hosted private repositories.

Prerequisites

To install GitLab on Rocky Linux 8.4, you need to have:

  • A server running Rocky Linux 8.4. If you don’t have a server already, you can spin up a cloud server on the web with one of the many providers that provide Rocky Linux VPS’s.
  • Root access to the server to install the software.
  • A fully qualified domain name (FQDN)preferably pointing to your server’s IP address. A sub-domain will work fine as well.
  • System requirements: according to Gitlab, the current version of GitLab requires at least 2 cores and 8GB of memory (RAM). You need at least 15GB of free space for the bootstrap and the dependencies about the hard disk space.

Updating the System

It’s recommended to update your system before installing any new software, especially if you plan to install GitLab. Run the following command to update your system.

sudo dnf check-update
sudo dnf update -y
sudo dnf -y upgrade

Once you have updated your system, you should install the required dependencies. Run the following command to install them.

sudo dnf install -y curl openssh-server policycoreutils perl
sudo systemctl enable --now sshd
sudo dnf -y install postfix
sudo systemctl enable --now postfix
sudo dnf -y install chrony
sudo systemctl enable chronyd

Once the command above finished, run the command below to set your hostname. Because the hostname may be set to localhost by default, and this will create conflicts with other applications that you may install in the future. Remember to replace git.example.com with your desired FQDN.

sudo hostnamectl set-hostname git.example.com

You also need to set the correct timezone on your server. Run the following command to list all available time zones.

sudo timedatectl list-timezones

You will get a list of all time zones available on your system as shown below.

<img alt="list all available time zones" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/list_all_available_time_zones.png61856f22d463c.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="353" loading="lazy" src="data:image/svg xml,” width=”750″>

Choose a time zone that you want to use and run the following command with the corresponding time zone. Remember to replace America/New_York with your time zone. The time-zone configuration parameter will be set in a file under config/gitlab.yml.

sudo timedatectl set-timezone America/New_York

Lastly, configure your chrony as a Network Time Protocol(NTP) server so that you can synchronize the system clock to the servers. Run the following command to do that.

sudo timedatectl set-local-rtc 0
sudo timedatectl set-ntp yes
sudo chronyc sources

Run the timedatectl command without options to check the current status of NTP synchronization.

timedatectl

You will see the status of your NTP synchronization as shown below.

<img alt="NTP synchronization" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/ntp_synchronization.png61856f230e748.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="146" loading="lazy" src="data:image/svg xml,” width=”750″>

Adding GitLab repository

Now it’s time to add the official GitLab repository so that you can install GitLab. GitLab has two versions, Community Edition(CE) and Enterprise Edition(EE). We will use the CE version. The GitLab CE is the open-source version that you can use on your own server that’s free to download and use. In order to add the GitLab CE repository, run the following command.

sudo tee /etc/yum.repos.d/gitlab_gitlab-ce.repo<<EOL[gitlab_gitlab-ce]

name=gitlab_gitlab-ce

baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/8/$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

sslverify=1

sslcacert=/etc/pki/tls/certs/ca-bundle.crt

metadata_expire=300

EOL

Now, run the command below to verify whether the GitLab repository has been added or not.

sudo dnf repolist

You will see the gitlab_gitlab-ce as repository as shown below.

<img alt="gitlab_gitlab-ce as repository" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/gitlab_gitlab-ce_as_repository.png61856f233730c.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="112" loading="lazy" src="data:image/svg xml,” width=”644″>

Next, run the following command to verify if the repository is enabled or not.

sudo dnf repolist enabled

You will see an output as shown below.

<img alt="verify the repository" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/verifying_the_repository.png61856f236a22a.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="63" loading="lazy" src="data:image/svg xml,” width=”645″>

Do NOT proceed until you see the gitlab_gitlab-ce repository as enabled. Run the command below to set the repository as enabled.Advertisement

sudo dnf config-manager --set-enabled gitlab_gitlab-ce

Installing GitLab on Rocky Linux 8.4

Now it’s time to install GitLab on your system. Run the following command to do so. Replace gitlab.example.com in the command with your FQDN.

sudo EXTERNAL_URL="http://gitlab.example.com" dnf install -y gitlab-ce

The installation might take some time depending on your internet connection speed a the server-loads. You will see the output as shown below after the command finished, don’t close the terminal yet because there are still few things to do.

<img alt="Installing GitLab on Rocky Linux 8.4" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/installing_gitlab_on_rocky_linux_84_3.png61856f23906d2.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="386" loading="lazy" src="data:image/svg xml,” width=”642″>

Configuring Firewall Rules

Now, it’s time to configure the Firewall in Rocky Linux. If you run your server behind a firewall, you need to allow http and https traffic because we will use HTTP/HTTPS protocol to access the GitLab web UI. Run the following command to open HTTP and HTTPS ports on your firewall.

sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https

Run the command below to apply new firewall rules.

sudo systemctl reload firewalld

Accessing the GitLab Web UI

Now that the installation is complete, you can access the web interface using your FQDN.

Open up your favorite browser and enter FQDN in the address bar. You will see a login page as shown below.

<img alt="log in page" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/log_in_page.png61856f23bc56b.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="410" loading="lazy" src="data:image/svg xml,” width=”750″>

To log in, you will need a temporary password, which you can get by running the command below in the terminal. This password was created automatically during the installation process but did not show up. The Gitlab developer does this for security reasons.

sudo cat /etc/gitlab/initial_root_password

You will see a password as shown below. Copy and save this password somewhere safe.

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_3.png61856f23e82e0.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="234" loading="lazy" src="data:image/svg xml,” width=”645″>

Now, return to the login page, where you need to enter the username ‘root’ and the temporary password you copied. Click on Sign In.

<img alt="Sign In" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/sign_in.png61856f2424a71.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="398" loading="lazy" src="data:image/svg xml,” width=”750″>

Once the login is successful, you will be taken to the Gitlab dashboard as shown below.

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_4.png61856f24534c8.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="415" loading="lazy" src="data:image/svg xml,” width=”750″>

To change the temporary password, click on Profile and Edit Profile on the top-right. Then click on the Password link on the left-hand side as shown below.

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_5.png61856f247158b.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="415" loading="lazy" src="data:image/svg xml,” width=”750″>

You will be taken to the Edit Password page. Provide your current password, your new password and confirm it. Then click on Save password as shown below.

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_6.png61856f249e657.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="385" loading="lazy" src="data:image/svg xml,” width=”750″>

You also need to configure the Sign-up restrictions to disable new sign-ups. It’s risky if you allow any new users to be able to sign up because then anyone can access your GitLab server. Click on Menu and then go to the Admin area on the top-left as shown below.

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_7.png61856f24cb2b1.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="316" loading="lazy" src="data:image/svg xml,” width=”750″>

On the next page, click on Sign up under the Features section as shown below.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_8.png61856f2502722.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="260" loading="lazy" src="data:image/svg xml,” width=”750″>

On the next page, you will see all the settings for signup restrictions. You can disable new signups by unchecking the Sign-up enabled checkbox. Then click on the Save changes button at the bottom.

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_9.png61856f252c262.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="197" loading="lazy" src="data:image/svg xml,” width=”750″>

<img alt="Accessing the GitLab Web UI" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/11/echo/accessing_the_gitlab_web_ui_12.png61856f255a45f.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="90" loading="lazy" src="data:image/svg xml,” width=”750″>

Those steps are just basic configurations. You can configure GitLab further by clicking on the Menu or going to the Setting link. Please refer to the GitLab official documentation for more details. The docs have all the tasks you can do from the web UI.

Conclusion

In this tutorial, we have shown you how to install GitLab on a Rocky Linux 8.4 server. We hope that this tutorial has been helping you to get started with GitLab.

For additional help and support, please visit the official GitLab documentation. If you have any questions or feedback, please comment below.