GitLab, an open-source platform, provides a robust and feature-rich solution for managing repositories, issues, CI/CD pipelines, and much more. If you’re an Ubuntu 22.04 or 20.04 user and want to set up your own GitLab instance to streamline your DevOps workflow, you’re in the right place.

This step-by-step guide will walk you through the installation process of GitLab on Ubuntu 22.04 or 20.04. GItlab comes with Enterprise edition (Gitlab EE) and Community edition (Gitlab CE). In this post , we will cover the community edition.


  • A virtual or dedicated server running Ubuntu 22.04 or 20.04 with SSH access.
  • Static Hostname (
  • Sudo User with admin rights
  • 2 GB RAM or more
  • 2 vCPUs or more
  • Internet Connectivity

1) Update System Packages

Let’s begin by updating the package lists and upgrading any existing packages to their latest versions.

$ sudo apt update
$ sudo apt upgrade -y

Reboot the system after applying updates,

$ sudo reboot.

2) Install Dependencies

GitLab requires some dependencies to function correctly. Install them using the following commands:

$ sudo apt install -y curl openssh-server ca-certificates postfix

During the postfix installation, a configuration window will appear. Choose “Internet Site” and enter your server’s hostname as the mail server name. This will allow GitLab to send email notifications.


Choose “Internet Site” and then slect OK.


Check system’s hostname and choose OK.

3) Add GitLab Apt Repository

Now, we’ll add the GitLab repository, run the following curl command. It will automatically detect your Ubuntu version and will set the repository accordingly.

$ curl -sS | sudo bash


4) Install Gitlab

Run the beneath command to install and configure gitlab-ce  on your ubuntu system automatically, replace the server’s hostname as your setup,

$ sudo EXTERNAL_URL="" apt install gitlab-ce

Once the above the command is executed successfully, we will get output something like below,



Output above confirms that GitLab has been installed successfully. User name for gitlab web interface is root and password is stored at “/etc/gitlab/initial_root_password

Note : If OS firewall is enabled on your ubuntu system, then allow 80 and 443 ports.

$ sudo ufw allow http
$ sudo ufw allow https

5) Access GitLab Web Interface

With GitLab installed and configured, open your web browser and enter your server’s IP address or hostname.


  • User Name: root
  • Password : <<Get Password from /etc/gitlab/initial_root_password>>


click on “Sign in”


Great, above confirms that we have successfully login to Gitlab Web interface.

As of now our GitLab Server is working on http (80) protocol, if you want to enable https for your GitLab, then refer the below steps,

6) Setup HTTPS for GitLab Web Interface

For added security, you can configure HTTPS for your GitLab instance using self-signed certificate or Let’s Encrypt. We can use Let’s encrypt only for public domain whose A recorded available on internet. But in our case, we are using a private domain, so we will be using self-signed certificate to secure GitLab.

Now, let’s create following folder and generate self-sign certificates using openssl command

$ sudo mkdir -p /etc/gitlab/ssl
$ sudo chmod 755 /etc/gitlab/ssl

Generate the private key using following openssl command,

$ sudo openssl genrsa -des3 -out /etc/gitlab/ssl/ 2048

Enter the passphrase and and remember it

Create the CSR using below command,

$ sudo openssl req -new -key /etc/gitlab/ssl/ -out /etc/gitlab/ssl/


Remove Passphrase from the key, execute the following commands one after the another

$ sudo cp -v /etc/gitlab/ssl/{key,original}
$ sudo openssl rsa -in /etc/gitlab/ssl/ -out /etc/gitlab/ssl/
$ sudo rm -v /etc/gitlab/ssl/

Create the Certificate file

$ sudo openssl x509 -req -days 1460 -in /etc/gitlab/ssl/ -signkey /etc/gitlab/ssl/ -out /etc/gitlab/ssl/

Remove the CSR file using below rm command,

$ sudo rm -v /etc/gitlab/ssl/

Set the permissions on key and certificate file

$ sudo chmod 600 /etc/gitlab/ssl/
$ sudo chmod 600 /etc/gitlab/ssl/

All the important configuration for Gitlab server is controlled by the file “/etc/gitlab/gitlab.rb” So edit this file,  search “external_url” and add the “”

$ sudo vi /etc/gitlab/gitlab.rb
external_url ''

Save and exit the file, reconfigure gitlab using beneath command so that it’s web interface start working https.

$ sudo gitlab-ctl reconfigure


Once above command is executed successfully, then your GitLab interface should be accessible over https protocol, In my case url will be:

When you access it first time, it will say something like your connection is not secure, click on “Accept the Risk and Continue”



Congratulations! You’ve successfully installed GitLab on your Ubuntu 22.04 or 20.04 system. With GitLab up and running, you can now create repositories, collaborate with your team, and enhance your development workflow through GitLab’s impressive features. Enjoy seamless version control, continuous integration, and more, all under your control!

The post How to Install GitLab on Ubuntu 22.04 | 20.04 first appeared on .

Leave a Comment