How To Install GitLab on Ubuntu 22.04

How to install GitLab on Ubuntu 22.04

In this short tutorial, we will learn how to install GitLab on Ubuntu 22.04 operating system.

Introduction

When we work in a team on a project, we will be helped by tools that allow us to share information with other team members. From developers to sysadmins, they will collaborate at every stage of the project. GitLab is one of the tools that can be used for this need.

GitLab is a DevOps software package that combines the ability to develop, secure, and operate software in a single application. GitLab also permits usto perform source code management, monitoring, security, and project planning tasks. On this short tutorial, we will learn how to install GitLab on Ubuntu 22.04 LTS operating system.

GitLab Installation on Ubuntu 22.04

The GitLab installation will be consist of several steps as described below :

  1. Update system packages
  2. Install necessary dependencies
  3. Import GPG key
  4. Add GitLab repository
  5. Update system packages
  6. Install GitLab on Ubuntu 22.04
  7. Configuring GitLab
  8. Verify GitLab installation
  9. Enable required ports
  10. Start GitLab service
  11. Check services status

1. Update System Package

The first step is to update our system package, for this purpose we will submit the command line :

$ sudo apt update

Output :

ramans@bckinfo:~$ sudo apt update
[sudo] password for ramans: 
Get:1 https://download.docker.com/linux/ubuntu jammy InRelease [48,9 kB]
Hit:2 http://id.archive.ubuntu.com/ubuntu jammy InRelease                                       
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]                       
Get:4 http://id.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]    
. . .
Get:22 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [82,3 kB]           
Get:23 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [13,0 kB]    
Get:24 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [288 kB]        
Get:25 http://security.ubuntu.com/ubuntu jammy-security/universe i386 Packages [211 kB]         
Get:26 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [63,8 kB]              
Get:27 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 DEP-11 Metadata [12,4 kB]       
Get:28 http://security.ubuntu.com/ubuntu jammy-security/universe DEP-11 64x64 Icons [9.532 B]          
Fetched 4.194 kB in 14s (309 kB/s)                                                                     
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
265 packages can be upgraded. Run 'apt list --upgradable' to see them.

2. Install Dependencies Packages

To install necessary dependencies with Gitlag, we will do following command line :

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

.Output :

ramans@bckinfo:~$ sudo apt install tzdata curl ca-certificates openssh-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20211016).
curl is already the newest version (7.81.0-1ubuntu1.4).
The following additional packages will be installed:
ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
molly-guard monkeysphere ssh-askpass
The following NEW packages will be installed:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
The following packages will be upgraded:
tzdata
1 upgraded, 4 newly installed, 0 to remove and 264 not upgraded.
Need to get 751 kB/1.086 kB of archives.
After this operation, 5.998 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 openssh-sftp-server amd64 1:8.9p1-3 [38,8 kB]
Get:2 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 openssh-server amd64 1:8.9p1-3 [434 kB]
Get:3 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 ncurses-term all 6.3-2 [267 kB]
Get:4 http://id.archive.ubuntu.com/ubuntu jammy/main amd64 ssh-import-id all 5.11-0ubuntu1 [10,1 kB]
Fetched 751 kB in 3s (221 kB/s)
Preconfiguring packages ...
Selecting previously unselected package openssh-sftp-server.
(Reading database ... 199230 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a8.9p1-3_amd64.deb ...
Unpacking openssh-sftp-server (1:8.9p1-3) ...
Selecting previously unselected package openssh-server.

Setting up openssh-sftp-server (1:8.9p1-3) ...
Setting up openssh-server (1:8.9p1-3) ...

Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...

Current default time zone: 'Asia/Jakarta'
Local time is now: Kam 06 Okt 2022 11:29:41 WIB.
Universal Time is now: Thu Oct 6 16:29:41 UTC 2022.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

Setting up ncurses-term (6.3-2) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for ufw (0.36.1-4build1) ...

3. Import GPG key

In this step we will import GitLab GPG key to be available on the system. To perform this task, we will submit the following command line :

$ gpg_key_url="https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey"

Output :

ramans@bckinfo:~$ gpg_key_url="https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey"curl -fsSL $gpg_key_url| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/gitlab.gpgFile '/etc/apt/trusted.gpg.d/gitlab.gpg' exists. Overwrite? (y/N) y

4. Add GitLab Repository

On this stage, we will import and add the repository of GitLab into the system, to perform this task we will submit command line below :

$ sudo tee /etc/apt/sources.list.d/gitlab_gitlab-ce.list<<EOF
deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
EOF

Output :

ramans@bckinfo:~$ sudo tee /etc/apt/sources.list.d/gitlab_gitlab-ce.list<<EOF
deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
EOF
deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main

5. Update System

After GitLab repository has been imported, then we will update the system, by submitting following command line :

$ sudo apt update

Output :

ramans@bckinfo:~$ sudo apt update
Hit:1 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease                                          
Hit:4 http://id.archive.ubuntu.com/ubuntu jammy InRelease                                                 
Get:5 http://id.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]                                
Get:2 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23,3 kB]                       
Hit:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
. . .
Get:15 http://id.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 DEP-11 Metadata [12,6 kB]
Fetched 1.943 kB in 4s (457 kB/s)                                                                       
Reading package lists... Done
Building dependency tree... Done. 
Reading state information... Done
264 packages can be upgraded. Run 'apt list --upgradable' to see them.\




6. Install GitLab On Ubuntu 22.04

In this section, we will install GitLab on Ubuntu 22.04 by submitting the following command line :

$ sudo apt install gitlab-ce

Output :

ramans@bckinfo:~$ sudo apt install gitlab-ce
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
gitlab-ce
0 upgraded, 1 newly installed, 0 to remove and 264 not upgraded.
Need to get 1.143 MB of archives.

Unpacking gitlab-ce (15.4.2-ce.0) ...
Setting up gitlab-ce (15.4.2-ce.0) ...
It looks like GitLab has not been configured yet; skipping the upgrade script.

*. *.
*** ***
***** *****
.****** *******#####.........................................................................]
******** ********####.........................................................................]
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,###.........................................................................]
,,,,,,,,,*****,,,,,,,,,.######.........................................................................]
,,,,,,,****,,,,,,##########.........................................................................]
.,,,***,,,,#############.........................................................................]
,*,.################.........................................................................]



_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=15-4
GitLab installation on Ubuntu 22.04

We have installed GitLab on Ubuntu 22.04 successfully, then we will configure it to run properly on our environment.

7. Configuring GitLab

The next step is to configure GitLab to work properly. To configure the GitLab installation, we will be using command line :

$ sudo gitlab-ctl reconfigure

Output :

ramans@bckinfo:~$ sudo gitlab-ctl reconfigure
[sudo] password for ramans:
[2022-10-06T23:57:57+07:00] INFO: Started Chef Infra Zero at chefzero://localhost:1 with repository at /opt/gitlab/embedded (One version per cookbook)
Chef Infra Client, version 17.10.0
Patents: https://www.chef.io/patents
Infra Phase starting
[2022-10-06T23:57:57+07:00] INFO: *** Chef Infra Client 17.10.0 ***
[2022-10-06T23:57:57+07:00] INFO: Platform: x86_64-linux
pes/default.rb in the cache.
[2022-10-06T23:58:01+07:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-workhorse.rb in the cache.
[2022-10-06T23:58:01+07:00] INFO: Storing updated cookbooks/gitlab/recipes/database_reindexing_enable.rb in the cache.

. . .

running handlers:
[2022-10-07T00:01:51+07:00] INFO: Running report handlers
Running handlers complete
[2022-10-07T00:01:52+07:00] INFO: Report handlers complete
Infra Phase complete, 571/1529 resources updated in 03 minutes 54 seconds

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!

8. Verifying GitLab installation

To make sure if our GitLab installation was successfully done, we will verify it by viewing the related information. On this stage, we will retrieve GitLab environment info, by submitting command line :

$ sudo gitlab-rake gitlab:env:info

Output :

ramans@bckinfo:~$ sudo gitlab-rake gitlab:env:info

System information
System:		Ubuntu 22.04
Current User:	git
Using RVM:	no
Ruby Version:	2.7.5p203
Gem Version:	3.1.6
Bundler Version:2.3.15
Rake Version:	13.0.6
Redis Version:	6.2.7
Sidekiq Version:6.4.2
Go Version:	unknown

GitLab information
Version:	15.4.2
Revision:	ef309cf1466
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	13.6
URL:		http://gitlab.example.com
HTTP Clone URL:	http://gitlab.example.com/some-group/some-project.git
SSH Clone URL:	git@gitlab.example.com:some-group/some-project.git
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	14.10.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell

It shown above, if our GitLab installation showing the right information.

9. Enable required Ports

The GitLab service that was provided on our server must be accessible from any other party via http or https. To ensure these services run normally by using the following command line.

$ sudo ufw allow https
$ sudo ufw allow http
$ sudo ufw enable

Output :

ramans@bckinfo:~$ sudo ufw allow https
Rules updated
Rules updated (v6)
ramans@bckinfo:~$ sudo ufw allow http
Rules updated
Rules updated (v6)
ramans@bckinfo:~$ sudo ufw enable
Firewall is active and enabled on system startup
ramans@bckinfo:~$ sudo ufw reload
Firewall reloaded

10. Start GitLab Service

On this start, we will start GitLab service by submitting command line :

$ sudo gitlab-ctl start

Output :

ramans@bckinfo:~$ sudo gitlab-ctl start
ok: run: alertmanager: (pid 24699) 303s
ok: run: gitaly: (pid 24695) 303s
ok: run: gitlab-exporter: (pid 24700) 303s
ok: run: gitlab-kas: (pid 24687) 303s
ok: run: gitlab-workhorse: (pid 24673) 303s
ok: run: logrotate: (pid 24682) 303s
ok: run: nginx: (pid 24696) 303s
ok: run: node-exporter: (pid 24692) 303s
ok: run: postgres-exporter: (pid 24701) 303s
ok: run: postgresql: (pid 24703) 303s
ok: run: prometheus: (pid 24681) 303s
ok: run: puma: (pid 24689) 303s
ok: run: redis: (pid 24671) 303s
ok: run: redis-exporter: (pid 24694) 303s
ok: run: sidekiq: (pid 24669) 303s

11. Check Services Status

When we have started GitLab service, then we will check its service by submitting command line :

$ sudo gitlab-ctl status

Output :

ramans@bckinfo:~$ sudo gitlab-ctl status
[sudo] password for ramans:
run: alertmanager: (pid 1893) 13503s; run: log: (pid 1885) 13503s
run: gitaly: (pid 1895) 13503s; run: log: (pid 1887) 13503s
...
run: redis-exporter: (pid 1879) 13503s; run: log: (pid 1878) 13503s
run: sidekiq: (pid 1867) 13503s; run: log: (pid 1866) 13503s

Until this stage, we have installed GitLab on Ubuntu 22.04 LTS successfully. The next step is we will use GitLab for our purpose.

Using GitLab

On this stage, we will try to use and explore GitLab. We will use web browser to access GitLab. On this tutorial we are using localhost or hostname (bckinfo), so we will hit the http://localhost or http//:bckinfo, as shwon below =.

Login to GitLab using root username
Login to GitLab using root username

We will use root user to login to GitLab where the password is located at /etc/gitlab/initial_root_password file, as shown below.

ramans@bckinfo:~$ sudo more /etc/gitlab/initial_root_password
[sudo] password for ramans: 
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `git
lab_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: LeRxtHqSqnAu97XcNiU1ikW+KCCRuEbLzo4nkG21Vw0=

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

We are recommended to chage the given password.

After successfully logging in, we will find the GitLab main page as below

GitLab mainpage for the first time
GitLab mainpage for the first time

Conclusion

In this tutorial, we have learnt how to install GitLab on Ubuntu 22.04 LTS operating system successfully. I hope this tutorial will be helpful.

Frequently Asked Questions (FAQ) – Installing GitLab on Ubuntu 22.04

1. What is GitLab and why should I install it?

GitLab is a complete DevOps platform that provides Git repository management, CI/CD pipelines, issue tracking, code review, and moreβ€”all in one application. Installing GitLab on your own server lets you host private repositories, automate deployments, and control your development workflow.

2. Can I install GitLab on Ubuntu 22.04?

Yes, GitLab supports installation on Ubuntu 22.04 LTS. The tutorial walks through adding the GitLab repository, installing required dependencies, and configuring the GitLab package for your server.

3. What are the prerequisites before installing GitLab on Ubuntu 22.04?

Before installation, you should:

  • Update your system packages (sudo apt update && sudo apt upgrade)
  • Install required packages such as curl, openssh, ca-certificates, and postfix (for email notifications)
  • Have sufficient system resources (recommended minimum: 4GB RAM)

Proper preparation ensures a smooth installation process.

4. How do I configure GitLab after installation?

After installing GitLab, you must configure the external URL by editing the /etc/gitlab/gitlab.rb file. Then run:

sudo gitlab-ctl reconfigure

This command applies your GitLab configuration and initializes services.

5. How can I access the GitLab web interface?

Once GitLab is installed and configured:

  1. Open a web browser
  2. Navigate to your server’s IP address or domain (e.g., http://your-domain.com)
  3. On first login, GitLab will prompt you to set a root password

From there, you can start creating projects, users, and pipelines.

6. Does GitLab provide built-in CI/CD?

Yes! GitLab includes a powerful CI/CD system. To use it, create a .gitlab-ci.yml file in your repository and configure pipeline stages such as build, test, and deploy. GitLab Runners execute the jobs defined in your pipeline.

7. How do I enable HTTPS for GitLab?

To secure your GitLab server:

  • Obtain an SSL/TLS certificate (via Let’s Encrypt or another provider)
  • Configure the certificate paths in /etc/gitlab/gitlab.rb
  • Reconfigure GitLab with sudo gitlab-ctl reconfigure

This enables HTTPS for encrypted access and better security.

8. Can I use GitLab for team collaboration?

Absolutely. GitLab supports:

  • User and group management
  • Merge requests and code reviews
  • Issue boards and milestones
  • Permissions and role controls
    It’s ideal for small teams and large enterprises alike.

9. How do I update GitLab on Ubuntu 22.04 later?

GitLab can be updated using the standard package manager:

sudo apt update
sudo apt upgrade gitlab-ee

Replace gitlab-ee with gitlab-ce if you’re using the Community Edition.

10. What should I do if I encounter errors during installation?

If you run into issues:

  • Double-check your prerequisites and dependencies
  • Verify your /etc/gitlab/gitlab.rb configuration
  • Use sudo gitlab-ctl status to view service statuses
  • Review logs with sudo gitlab-ctl tail

These steps help identify common configuration or setup problems.

(Visited 330 times, 1 visits today)

You may also like