Site icon CentLinux

How to install GitLab CE on Rocky Linux 9

Share on Social Media

Learn how to install GitLab CE on Rocky Linux 9 with this step-by-step guide. Set up GitLab Community Edition for efficient code management and team collaboration. #centlinux #linux #gitlab

Introduction

GitLab CE, or Community Edition, is a powerful, open-source platform that allows developers to manage and version control their projects while leveraging CI/CD (Continuous Integration and Continuous Deployment) pipelines. It’s ideal for those wanting to host their Git repositories on their own servers, offering features comparable to platforms like GitHub and Bitbucket but with greater control. Rocky Linux 9, a community-driven enterprise OS, provides a stable and robust environment for hosting GitLab CE, making it a top choice for developers and companies looking for high performance and open-source flexibility.

In this guide, we’ll go through the step-by-step process of installing GitLab CE on Rocky Linux 9, ensuring you get the setup you need for effective project management and CI/CD workflows.

How to install GitLab CE on Rocky Linux 9

Prerequisites

System Requirements

To ensure GitLab runs smoothly, make sure your server meets the following minimum specifications:

Rocky Linux 9 Installation and Update

Start by installing Rocky Linux 9 and updating your system. This ensures you’re working with the latest patches, which is essential for security and compatibility.

Run the following commands to update your system:

sudo dnf update -y
sudo dnf upgrade -y

After the update completes, reboot the server to apply any kernel updates:

sudo reboot

Step 1: Configure the Server for GitLab Installation

Installing Required Dependencies

GitLab CE has some dependencies that need to be installed before proceeding. These include curl, policycoreutils, perl and openssh-server. Install them by running:

sudo dnf install -y curl policycoreutils openssh-server perl

Configuring Hostname and Domain Settings

A static IP and hostname configuration will help with consistent access to GitLab, especially if you plan to access it from other machines. Use the following command to set a hostname:

sudo hostnamectl set-hostname gitlab-01.centlinux.com

Replace gitlab-01.centlinux.com with your preferred domain or subdomain.

Recommended Training: GitLab CI/CD Bootcamp| Zero to Hero| Certification Prep 2024 from Karan Gupta

Step 2: Setting Up the GitLab CE Repository

Adding GitLab CE Repository

GitLab provides its own repository to streamline the installation and update process. Add the GitLab repository with the following command:

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

This script will set up the necessary repository files and GPG keys to authenticate future updates.

Updating Package Lists

Once the repository is added, refresh the package list to recognize the new repository:

sudo dnf makecache

Step 3: Installing GitLab CE

Running the GitLab CE Installation Command

To install GitLab Community Edition (CE), execute the following command in your terminal. This step initiates the installation process, setting up the core components needed to run GitLab CE on your server. Make sure you have the necessary dependencies and system requirements in place before proceeding:

sudo dnf install -y gitlab-ce

This will download and install all necessary components. GitLab CE will then configure itself based on the settings in the configuration file, making it easier to get started without extra setup.

Verifying Installation

Once the installation is complete, verify that GitLab CE was successfully installed:

gitlab-ctl status

This command shows the status of GitLab services, helping you confirm if everything is running as expected.

Step 4: Configuring GitLab CE

Editing GitLab Configuration File

After installation, navigate to the configuration file to set up essential parameters like the external URL. Open the file with the command:

sudo nano /etc/gitlab/gitlab.rb

Locate the line external_url and modify it to include your domain or IP address, such as:

external_url 'http://gitlab.example.com'

Save and close the file when done.

Applying Configuration Changes

To apply the changes you made, run the following reconfiguration command:

sudo gitlab-ctl reconfigure

This command reads the updated configuration and applies it to the GitLab services.

Step 5: Setting Up the GitLab Service

Starting and Enabling GitLab Services

To ensure GitLab starts on boot, enable and start the GitLab service with these commands:

sudo systemctl enable gitlab-runsvdir
sudo systemctl start gitlab-runsvdir

Firewall Configuration

By default, GitLab is configured to use port 80 for HTTP and port 443 for secure HTTPS connections. These ports are essential for accessing the GitLab web interface and enabling communication over the web.

To ensure that users can reach your GitLab instance through a browser and interact with it properly, you need to open these ports in your system’s firewall or security group settings. Use the following commands to allow incoming web traffic on these standard ports:

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

Test connectivity to ensure your GitLab instance is accessible.

Step 6: Accessing GitLab Web Interface

First-Time Setup on GitLab Web Interface

Open a browser and navigate to your GitLab instance’s URL, such as http://gitlab-01.centlinux.com. You’ll be prompted to set a new password for the root account, which will serve as your GitLab administrator account.

Configuring SSL (Optional)

For enhanced security, consider adding an SSL certificate. GitLab supports Let’s Encrypt, or you can use a custom SSL certificate if you have one. Simply update the external_url line in your configuration file to use HTTPS, then reconfigure GitLab as before.

Step 7: Post-Installation Configuration

Setting Up Email Notifications

Email notifications help users stay updated with project activities. Configure SMTP settings in the GitLab configuration file under the gitlab_rails['smtp_…'] section, specifying your SMTP server details.

Customizing GitLab for Users

At this stage, you’re ready to begin creating groups and projects within your GitLab instance. Start by organizing your work into groups to represent teams, departments, or specific initiatives. Within each group, you can create individual projects to house your repositories, CI/CD pipelines, issues, and documentation.

Additionally, take advantage of GitLab’s robust user management features by assigning appropriate roles and permissions to team members, ensuring secure and efficient collaboration. Customize workflows, enforce branch protection rules, and implement merge request approvals to align GitLab with your team’s development processes—transforming it into a powerful, centralized hub for all your collaborative software development activities.

Securing Your GitLab Installation

Enabling 2FA for Admin Accounts

Two-factor authentication adds an extra layer of security. In GitLab, admins can require 2FA for added protection, which you can enable from the admin area.

Configuring GitLab Backups

To safeguard your GitLab instance against unexpected data loss, it’s crucial to configure automatic backups. This ensures that your repositories, configurations, and critical data are regularly saved and can be restored in the event of system failure, accidental deletion, or other issues.

GitLab provides flexible options for setting up scheduled backups, allowing you to define backup frequency, retention policies, and storage paths. These settings can be customized in the GitLab configuration file, typically located at /etc/gitlab/gitlab.rb, under the backup section.

By enabling and fine-tuning these backup options, you can maintain business continuity and ensure that your development environment remains secure and recoverable at all times.

Troubleshooting Common Issues

Installation and Configuration Issues

If you encounter errors during installation, check the logs at /var/log/gitlab for insights. Common issues often relate to missing dependencies or misconfigured settings.

Connectivity and Firewall Troubles

If GitLab isn’t accessible, double-check your firewall rules and ensure all necessary ports are open. Sometimes, adjusting SELinux settings can also resolve access issues.

Video Tutorial of GitLab Installation

Conclusion

Installing GitLab CE on Rocky Linux 9 provides a powerful, self-hosted alternative to cloud-based Git services. With the stability of Rocky Linux and the collaborative power of GitLab, you’re set to streamline version control and CI/CD processes for your development projects.

Searching for a skilled Linux admin? From server management to security, I ensure seamless operations for your Linux systems. Find out more on my Fiverr profile!

Frequently Asked Questions (FAQs)

1. How do I update GitLab CE on Rocky Linux 9?
To update GitLab, run sudo dnf update gitlab-ce and reconfigure GitLab if needed.

2. Can I use GitLab CE without a domain name?
Yes, you can use an IP address, though using a domain makes access easier.

3. What are the minimum system requirements for GitLab CE?
GitLab requires at least 4 GB of RAM, 2 CPU cores, and 10 GB of storage.

4. How to enable SSL on GitLab?
Update external_url to HTTPS in the configuration file, add SSL details, and reconfigure GitLab.

5. How to troubleshoot common GitLab startup errors?
Check logs under /var/log/gitlab for error details, and verify dependencies are properly installed.

Exit mobile version