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
Table of Contents
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.
Prerequisites
System Requirements
To ensure GitLab runs smoothly, make sure your server meets the following minimum specifications:
- CPU: 2 cores or more.
- Memory: At least 4 GB of RAM (8 GB recommended for medium to large projects).
- Disk Space: Minimum 10 GB of available storage, though 50 GB is recommended if you plan to use CI/CD pipelines heavily.
Amazon Fire HD 10 tablet (newest model) built for relaxation, 10.1″ vibrant Full HD screen, octa-core processor, 3 GB RAM, 32 GB, Black
$74.99 (as of November 6, 2024 05:04 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)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.
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
Install GitLab CE by running the following command:
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.
Linux Bible
$33.49 (as of November 6, 2024 05:04 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)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 uses ports 80 (HTTP) and 443 (HTTPS). Open these ports to allow web traffic:
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
Now, you can start creating groups and projects. Manage user roles, permissions, and workflows to fit your team’s needs, making GitLab your collaborative development hub.
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
Configure automatic backups for GitLab to avoid data loss. You can find options for setting up scheduled backups in the configuration file under the backup
settings.
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.
If you are Looking for a reliable Linux system admin? I offer expert management, optimization, and support for all your Linux server needs, ensuring smooth and secure operations. Have a look at my Fiverr Profile.
FAQs
- How do I update GitLab CE on Rocky Linux 9?
To update GitLab, runsudo dnf update gitlab-ce
and reconfigure GitLab if needed. - Can I use GitLab CE without a domain name?
Yes, you can use an IP address, though using a domain makes access easier. - 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. - How to enable SSL on GitLab?
Updateexternal_url
to HTTPS in the configuration file, add SSL details, and reconfigure GitLab. - How to troubleshoot common GitLab startup errors?
Check logs under/var/log/gitlab
for error details, and verify dependencies are properly installed.