How To Install GitLab CE on Ubuntu 22.04|20.04|18.04

Posted on 158 views

Welcome to our guide on how to install GitLab CE on Ubuntu 22.04|20.04|18.04 Linux system. GitLab is a fully-featured platform for accelerated software development. It provides up to scratch features like integrated CI/CD, Kubernetes integration, Auto DevOps, GitLab Container Registry e.t.c.

In our previous guide, we covered how Install Gitlab CE on CentOS / Fedora. Follow below steps to Install Gitlab CE on Ubuntu 22.04|20.04|18.04. The server can be running in Cloud or your own premise virtualized infrastructure.

Step 1: Update system & install dependencies

Kickoff the installation by ensuring your system is updated:

sudo apt update
sudo apt upgrade -y

Install GitLab dependencies below:

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

Step 2: Configure Postfix Send-Only SMTP Server

GitLab should be able to send emails to you on Git activities. Configure Postfix SMTP Server using the guide below:

Step 3: Add the GitLab CE Repository

Once you have all pre-requisites installed, proceed to add GitLab repository to your Ubuntu 22.04|20.04|18.04 by running the command:

Ubuntu 22.04:

At the time of updating this article, the GitLab APT repository for Ubuntu 22.04 is not ready. What we’ll do is configure repository for Ubuntu 20.04 on 22.04. Once the repository for 22.04 is available this article will be updated.

Install dependency packages required:

sudo apt update
sudo apt install curl debian-archive-keyring lsb-release ca-certificates apt-transport-https software-properties-common -y

Import GitLab repo GPG key

curl -fsSL $gpg_key_url| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/gitlab.gpg

Add repository contents to /etc/apt/sources.list.d/gitlab_gitlab-ce.list file.

sudo tee /etc/apt/sources.list.d/gitlab_gitlab-ce.list<

Confirm configured repository is working by updating APT package index.

$ sudo apt update
Hit:1 jammy-security InRelease
Hit:3 jammy InRelease
Hit:4 jammy-updates InRelease
Get:2 focal InRelease [23.3 kB]
Hit:5 jammy-backports InRelease
Get:6 focal/main amd64 Packages [27.8 kB]
Fetched 51.1 kB in 2s (32.6 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

Ubuntu 20.04|18.04:

curl -sS | sudo bash

Command installation output:

Detected operating system as Ubuntu/focal.
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.

The repository contents are added to:

cat /etc/apt/sources.list.d/gitlab_gitlab-ce.list

Step 4: Install GitLab CE on Ubuntu 22.04|20.04|18.04

Once the repository has been added, install GitLab CE on Ubuntu 22.04|20.04|18.04 using the apt package manager command:

sudo apt update
sudo apt install gitlab-ce

Installation output:

It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********

     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /

Thank you for installing GitLab!

Edit the GitLab configuration file to set hostname and other parameters:

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

Replace with valid domain for GitLab server.

When done, start your GitLab instance by running the following command:

sudo gitlab-ctl reconfigure

All GitLab services should be started after configuration.

$ sudo gitlab-ctl status
run: alertmanager: (pid 92581) 18s; run: log: (pid 92343) 80s
run: gitaly: (pid 92590) 18s; run: log: (pid 91561) 189s
run: gitlab-exporter: (pid 92551) 20s; run: log: (pid 92078) 98s
run: gitlab-kas: (pid 92520) 22s; run: log: (pid 91845) 175s
run: gitlab-workhorse: (pid 92531) 21s; run: log: (pid 91985) 117s
run: grafana: (pid 92610) 17s; run: log: (pid 92471) 38s
run: logrotate: (pid 91486) 202s; run: log: (pid 91494) 201s
run: nginx: (pid 91993) 114s; run: log: (pid 92013) 110s
run: node-exporter: (pid 92540) 21s; run: log: (pid 92049) 104s
run: postgres-exporter: (pid 92601) 18s; run: log: (pid 92367) 76s
run: postgresql: (pid 91693) 184s; run: log: (pid 91704) 183s
run: prometheus: (pid 92560) 20s; run: log: (pid 92297) 88s
run: puma: (pid 91904) 132s; run: log: (pid 91917) 129s
run: redis: (pid 91521) 196s; run: log: (pid 91538) 193s
run: redis-exporter: (pid 92553) 20s; run: log: (pid 92217) 94s
run: sidekiq: (pid 91922) 126s; run: log: (pid 91934) 122s

Step 5: Access GitLab CE Web Interface

Once the installation of GitLab CE on Ubuntu 22.04|20.04|18.04 is done, open the URL on your browser to finish the installation of Gitlab.

A password for root user is randomly generated and stored for 24 hours in /etc/gitlab/initial_root_password. You can check the password with the commands below:

$ 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

Password: kOtOjWp7v70OjkjtadnSJAhcDbCNo9nTNGVC5UoSCyE=

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

Use this password with username root to login.


GitLab Dashboard should look like below.


Reset root user password

Go to root user profile > Preferences


Then Password section


Input the current password, and set new one.


Step 6: Secure Gitlab CE with SSL Certificate

Read our next article below on how to configure your GitLab server to be accessible via HTTPS

GitLab Administrations cheats

Whenever you edit GitLab configuration file – /etc/gitlab/gitlab.rb,reconfigure GitLab service by running:

sudo gitlab-ctl reconfigure
sudo gitlab-rake gitlab:check

To check the status of all GitLab service, use:

sudo gitlab-ctl status

To stop all GitLab services, use:

sudo gitlab-ctl stop

To restart all GitLab services, use:

sudo gitlab-ctl restart

You can restart a specific service by proving service name at the end

$ sudo gitlab-ctl restart logrotate
 ok: run: logrotate: (pid 22824) 0s

If you need LDAP Authentication on your GitLab Server, read:

Enjoy running GitLab on Ubuntu 22.04|20.04|18.04 server and stay connected for more informative and hands-on Linux guides.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.