Install GitLab CE on Ubuntu 22.04: Step-by-Step Guide

Install GitLab CE on Ubuntu 22.04

Learn how to install GitLab CE on Ubuntu 22.04 with this step-by-step guide. Includes CLI examples, troubleshooting tips, and best practices for a smooth deployment.

Table of Contents

Introduction

GitLab CE (Community Edition) is a robust, self-hosted Git repository management system that provides CI/CD, issue tracking, and more. In this guide, we will walk through the step-by-step process of installing GitLab CE on Ubuntu 22.04. This tutorial is designed to be SEO-optimized, providing clear instructions, tables, and CLI examples to help users successfully deploy GitLab CE.


Prerequisites

Before proceeding with the installation, ensure you have the following:

RequirementDetails
OSUbuntu 22.04 LTS
User PrivilegesRoot or sudo privileges
RAMMinimum 4GB (8GB recommended)
StorageAt least 20GB of available disk space
CPU Cores2 or more
Internet AccessRequired to download dependencies

For this demonstration, we’ve configured our Linux server as follows:

HostnameIP AddressRAM (GB)CoresStorage (GB)OS
gitlab2.dev.naijalabs.net192.168.1.23242150Ubuntu 22.04 LTS Jammy Jellyfish

Install GitLab CE on Ubuntu 22.04: Step-by-Step Instructions

Step 1: Update and Upgrade System Packages

Before installing GitLab, update the package index and upgrade existing packages (then, reboot your machine):

				
					sudo apt update && sudo apt upgrade -y && sudo systemctl reboot
				
			

Step 2: Install Required Dependencies

GitLab requires some dependencies for proper installation. Install them using the command below:

				
					sudo apt install -y curl openssh-server ca-certificates tzdata perl
				
			

For email notifications, install Postfix:

				
					sudo apt install -y postfix
				
			

During installation, select “Internet Site” and configure the system mail name accordingly.

Install GitLab CE on Ubuntu 22.04

Photo by admingeek from Infotechys

Step 3: Add GitLab Repository and Install GitLab CE

To install GitLab CE, follow these steps:

Add the GitLab Package Repository

				
					curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
				
			
				
					Detected operating system as Ubuntu/jammy.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.
				
			

Install GitLab CE

Replace gitlab2.dev.naijalabs.net with your actual domain or IP address:

				
					sudo EXTERNAL_URL="http://gitlab2.dev.naijalabs.net" apt install gitlab-ce -y
				
			
Install GitLab CE on Ubuntu 22.04

Photo by admingeek from Infotechys

Step 4: Configure GitLab

Once installed, configure GitLab using the following command:

				
					sudo gitlab-ctl reconfigure
				
			

This step may take several minutes as it configures all necessary services.

Install GitLab CE on Ubuntu 22.04

Photo by admingeek from Infotechys

Step 5: Adjust Firewall Rules

Allow HTTP and HTTPS traffic:

				
					sudo ufw allow http
				
			
				
					sudo ufw allow https
				
			
				
					sudo ufw allow OpenSSH
				
			
				
					sudo ufw enable
				
			
				
					Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
				
			

Step 6: Access GitLab Web Interface

Now, open a web browser and navigate to [ http://yourdomain.com ]:

Install GitLab CE on Ubuntu 22.04

Photo by admingeek from Infotechys

You will be prompted to set a new root password. Once done, log in using:

UsernamePassword
rootsudo cat /etc/gitlab/initial_root_password

You initial root password is stored in /etc/gitlab/initial_root_password

				
					sudo cat /etc/gitlab/initial_root_password 
				
			
				
					# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: yI3fpcKMS4j62v+6YiYc8NdZbL87MISajFkqn8m9VwE=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
				
			

Note: The root password is temporary and will expire in 24 hours. After your initial login, immediately update your password by navigating to your user settings at [http://yourdomain.com/-/user_settings/password/edit]

Install GitLab CE on Ubuntu 22.04

Photo by admingeek from Infotechys

Step 7: Enable HTTPS (Optional but Recommended)

For security, configure SSL with Let’s Encrypt:

				
					sudo EXTERNAL_URL="https://yourdomain.com" gitlab-ctl reconfigure
				
			

Ensure your domain has a valid DNS record pointing to your server.

Step 8: Start and Enable GitLab Services

Ensure GitLab services are running:

				
					sudo gitlab-ctl status
				
			

If necessary, restart services:

				
					sudo gitlab-ctl restart
				
			

Step 9: Configure GitLab for First Use

Navigate to Admin Area > Settings to:

  • Set up SSH keys

  • Configure CI/CD pipelines

  • Adjust project visibility settings

Troubleshooting Common Issues

IssueSolution
502 Gateway ErrorRestart GitLab with sudo gitlab-ctl restart
Email Not SendingCheck sudo gitlab-ctl tail postfix logs
Web UI Not LoadingEnsure firewall allows HTTP/HTTPS traffic

Conclusion

Congratulations! You have successfully installed and configured GitLab CE on Ubuntu 22.04. You are now ready to create projects, manage repositories, and set up CI/CD pipelines to streamline your development workflow.

Did you find this guide helpful? Your feedback is invaluable to us! Feel free to share this post with those who may benefit!

Related Posts

Leave a Reply

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