Install and Configure GitLab on AlmaLinux 9: Comprehensive Guide
This guide intends to teach you to Install and Configure GitLab 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. Installing GitLab on AlmaLinux 9 will empower your team to manage code, collaborate efficiently, and automate software development workflows.
GitLab offers two main editions:
- GitLab Community Edition (CE): A free, self-managed solution with core features.
- GitLab Enterprise Edition (EE): A paid, self-managed or SaaS solution with advanced features and support.
In this guide on the Orcacore website, we will show you how you can set up GitLab Community Edition on AlmaLinux 9. Successfully installing GitLab on AlmaLinux 9 involves several steps, which we will cover in detail.
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.
1. 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
2. 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

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
3. 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 'http<s>://<your_domain>'
...
Also, find the line below and uncomment it by removing the “#” and setting your email address:
...
letsencrypt['contact_emails'] = ['<daniel@orcacore.com>']
...
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
4. Access GitLab Login Page
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.
You will be signed in to the GitLab application and taken to a landing page that prompts you to begin adding projects.
From here you can update your password, adjust your profile settings, change your account name, add an SSH key to your account, etc.
5. 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. GitLab CE (Community Edition) is a free tool used for managing code, collaborating with teams, and automating software development. It helps developers store, track, and work on projects together using Git. Successfully installing GitLab on AlmaLinux 9 requires careful attention to detail, but the benefits for your development workflow are substantial.
Hope you enjoy it. You may also like these guides:
Install and Configure Apache Maven on Rocky Linux 8
Install FirewallD GUI on AlmaLinux 8
Install OpenSSL on Rocky Linux 9
Installing and removing an RPM package in AlmaLinux
Install Froxlor on RHEL 8
Enable RPM Fusion Repository on Fedora Linux 39
Create RAM Disk on Linux From Command Line
Autojump Advanced Navigation in Linux
Install Spotify on Linux
Alternative Solutions for Installing GitLab on AlmaLinux 9
While the above guide details the standard method of installing GitLab CE using the official GitLab repository, here are two alternative approaches that you might consider, depending on your specific needs and infrastructure.
1. Installing GitLab with Docker
Docker provides a containerization platform that allows you to run applications in isolated environments. Installing GitLab within a Docker container offers several advantages:
- Isolation: Ensures GitLab runs in a consistent environment, regardless of the underlying operating system. This eliminates dependency conflicts.
- Scalability: Docker containers are easily scalable, allowing you to adjust resources based on demand.
- Simplified Management: Docker simplifies the deployment and management of GitLab, as you can use Docker Compose to define and manage the entire GitLab stack.
Steps to Install GitLab with Docker:
-
Install Docker and Docker Compose: If you don’t already have Docker installed, you can install it using the official Docker documentation. Docker Compose is usually included with Docker Desktop installations or can be installed separately.
sudo dnf install docker -y sudo systemctl start docker sudo systemctl enable docker
-
Create a
docker-compose.yml
file: This file will define the services required for GitLab (GitLab itself, PostgreSQL, Redis).version: '3.6' services: gitlab: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' # Replace with your desired hostname environment: GITLAB_OMNIBUS_CONFIG: | external_url 'https://gitlab.example.com' # Replace with your domain gitlab_rails['gitlab_shell_ssh_port'] = 2224 ports: - '80:80' - '443:443' - '2224:22' volumes: - '/srv/gitlab/config:/etc/gitlab' - '/srv/gitlab/logs:/var/log/gitlab' - '/srv/gitlab/data:/var/opt/gitlab' shm_size: '256m'
Explanation:
image
: Specifies the GitLab CE Docker image to use.restart
: Ensures the container restarts automatically if it crashes.hostname
: Sets the hostname for the GitLab instance.GITLAB_OMNIBUS_CONFIG
: Allows you to configure GitLab using the Omnibus configuration system. This is equivalent to modifying/etc/gitlab/gitlab.rb
in the original method.ports
: Maps ports from the host machine to the container. Be careful to avoid port conflicts.volumes
: Mounts host directories to the container, ensuring data persistence.
-
Start GitLab with Docker Compose:
docker-compose up -d
This command will download the GitLab image (if it’s not already present) and start the GitLab container in detached mode.
-
Configure Firewall (if needed): You may need to open ports 80 and 443 on your firewall to allow access to GitLab.
sudo firewall-cmd --permanent --add-service={http,https} sudo firewall-cmd --reload
-
Access GitLab: After the container has started (this may take a few minutes), you can access GitLab by navigating to the hostname you specified in the
docker-compose.yml
file (e.g.,https://gitlab.example.com
).
Note: Using Docker for GitLab requires understanding of Docker concepts and management. However, it can greatly simplify the installation and maintenance process, especially in complex environments.
2. Using a Pre-built Virtual Machine Image
Another alternative is to use a pre-built virtual machine (VM) image that already has GitLab installed and configured. Several providers offer such images, including cloud providers like AWS, Azure, and Google Cloud, as well as specialized VM image providers.
Advantages of using a VM Image:
- Ease of Deployment: VM images can be deployed quickly and easily on various virtualization platforms.
- Pre-configured Environment: The VM image typically comes with all the necessary dependencies and configurations pre-set, reducing the need for manual setup.
- Consistent Environment: Ensures a consistent environment across different deployments.
Steps to Deploy GitLab using a VM Image:
-
Choose a VM Image Provider: Select a provider that offers GitLab VM images. Popular options include Bitnami GitLab stacks.
-
Download the VM Image: Download the VM image in a format compatible with your virtualization platform (e.g., VMware, VirtualBox, KVM).
-
Import the VM Image: Import the VM image into your virtualization platform.
-
Configure the VM: Configure the VM settings, such as network settings (IP address, hostname), memory, and CPU resources.
-
Start the VM: Start the VM.
-
Access GitLab: Access GitLab by navigating to the IP address or hostname of the VM in your web browser. You may need to consult the VM image provider’s documentation for initial login credentials and configuration instructions.
While this method can be significantly faster for initial setup, it requires trusting the VM image provider and may offer less flexibility in terms of customization compared to a manual installation or Docker-based deployment. You also need to ensure that the VM image is regularly updated with the latest security patches.