Install and Configure GitLab on AlmaLinux 9

This guide intends to teach you to Install and Configure GitLab CE on AlmaLinux 9.

GitLab is a management platform for Git repositories that provides integrated features like continuous integration, issue tracking, team support, and wiki documentation.

GitLab offers two main editions:

  • GitLab Community Edition (CE): this is a free edition
  • GitLab Enterprise Edition (EE): requires a License to use. It builds on top of Git with advanced features that include LDAP group sync, multiple roles, and audit logs. It also provides authorization integration with deeper authentication.

Steps To Install and Configure GitLab on AlmaLinux 9

To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

Also, you need a domain name that is pointed to your server’s IP address.

Install Required Packages For GitLab

First, you need to update your local package index with the command below:

sudo dnf update -y

Then, use the following command to install dependencies and required packages:

sudo dnf install curl vi policycoreutils python3-policycoreutils git libxcrypt-compat -y

Install GitLab on AlmaLinux 9

The GitLab repository isn’t available in the default AlmaLinux repository. So you need to add it manually to your server.

Add GitLab Repository

Create and open GitLab repo file by using your favorite text editor, here we use vi:

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

Add the following content to the file:

[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

[gitlab_gitlab-ce-source]
name=gitlab_gitlab-ce-source
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/8/SRPMS
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

When you are done, save and close the file.

Verify your GitLab repo has been added to your AlmaLinux server:

dnf repolist
Output
repo id                                 repo name
appstream                               AlmaLinux 9 - AppStream
baseos                                  AlmaLinux 9 - BaseOS
extras                                  AlmaLinux 9 - Extras
gitlab_gitlab-ce                        gitlab_gitlab-ce
gitlab_gitlab-ce-source                 gitlab_gitlab-ce-source

Install GitLab CE

At this point, you can use the following command to install GitLab CE (free edition) on your server:

sudo dnf install gitlab-ce -y

Configure GitLab CE on AlmaLinux 9

At this point, you need to update the GitLab configuration file. To do this, open the file with your favorite text editor, here we use vi:

sudo vi /etc/gitlab/gitlab.rb

Find the external_url configuration line and update it to your domain and make sure to change http to https to automatically redirect users to the site protected by the Let’s Encrypt certificate.

...
external_url 'https://your_domain'
...

Also, find the line below and uncomment it by removing the “#” and setting your email address:

...
letsencrypt['contact_emails'] = ['[email protected]']
...

When you are done, save and close the file.

Now use the command below to reconfigure GitLab on AlmaLinux 9:

sudo gitlab-ctl reconfigure

This will initialize GitLab using the information it can find about your server. The process will also configure a Let’s Encrypt certificate for your domain.

This will take some time to complete.

When you are done, you will get the following output:

Output
gitlab Reconfigured!

Configure Firewall for GitLab

At this point, you need to allow the HTTP/HTTPS and SSH services through the firewall:

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

Reload the firewall to apply the changes:

sudo firewall-cmd --reload

Access GitLab Web Interface

At this point, you can continue your GitLab configuration from the Web interface. To do this, type your domain name in your web browser as shown below:

https://your_domain

You will see the GitLab Community Edition Login page.

Note: GitLab generates an initial secure password for you. It is stored in a folder that you can access as an administrative sudo user:

sudo cat /etc/gitlab/initial_root_password

You should see something similar to this:

Password: Ax5puZGJc2aMA248N5X+QKNUWSft9jI/9wdJYCpgq3c=

Now from your GitLab login page enter root as the username and your initial password as your password and click Sign in.

GitLab login screen
GitLab Login

You will be signed in to the GitLab application and taken to a landing page that prompts you to begin adding projects.

GitLab dashboard
GitLab Dashboard

From here you can update your password, adjust your profile settings, change your account name, add an SSH key to your account, etc.

Renew Let’s Encrypt Certificates for GitLab on AlmaLinux 9

By default, GitLab has a scheduled task set up to renew Let’s Encrypt certificates after midnight every fourth day, with the exact minute based on your external_url.

You can change these settings by modifying the GitLab configuration file:

sudo vi /etc/gitlab/gitlab.rb

Then, find the following lines in the file and remove the # and update it with the following:

letsencrypt['auto_renew'] = true
letsencrypt['auto_renew_hour'] = "12"
letsencrypt['auto_renew_minute'] = "30"
letsencrypt['auto_renew_day_of_month'] = "*/7"
...

This will renew your certificates every 7th day at 12:30. You can change it to your desired date.

Disable auto-renewal Certificate

Also, you can disable auto-renewal by setting the letsencrypt[‘auto_renew’] to false:

...
letsencrypt['auto_renew'] = false
...

When you are done, save and close the file.

Conclusion

At this point, you have learned to Install and Configure GitLab CE on AlmaLinux 9.

Hope you enjoy it. You may be like these guides too:

Install and Configure Apache Maven on Rocky Linux 8

Install FirewallD GUI on AlmaLinux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Stay informed and not overwhelmed, subscribe now!