Guides 11792 Published by

The guide walks readers through installing GitLab Community Edition on Ubuntu 22.04 or 20.04, starting with prerequisites such as root access and a minimum of four gigabytes of RAM before performing system updates and installing essential packages like curl, openssh‑server, ca‑certificates, tzdata, and perl. It then shows how to add GitLab’s official APT repository, set the external URL, configure firewall rules for HTTP, HTTPS, and SSH traffic, run `gitlab‑ctl reconfigure` to pull configuration files, start services, and verify access in a browser using the default admin credentials. An optional section explains deploying GitLab with Docker on machines that have less than four gigabytes of memory, while practical troubleshooting tips address common errors such as missing PostgreSQL or Redis services. By following these steps readers will end up with a fully functional, locally hosted GitLab server ready to host projects and run pipelines while also learning how to secure it promptly by changing the admin password.



How to Install GitLab on Ubuntu 22.04 or 20.04

If you’re looking to spin up a self‑hosted Git platform without the SaaS price tag, installing GitLab on your Ubuntu machine is usually the fastest route. In this guide we’ll walk through the exact steps, explain why each one matters, and flag common hiccups.

What You’ll Get
  • A full‑featured GitLab instance (issues, CI/CD pipelines, etc.) running locally.
  • Clear instructions that work out of the box on Ubuntu 22.04 LTS or 20.04 LTS.
  • Tips to avoid the most common pitfalls (memory limits, package conflicts).
Install prerequisites

Before you even touch a terminal, make sure:

1. You’re logged in as root or have sudo privileges.

GitLab’s omnibus installer needs to modify system services and install packages that affect all users.

2. Your machine has at least 4 GB of RAM. GitLab will refuse to start if it can’t find enough memory, so this is a hard requirement.

Real‑world note: I once tried installing on a 1 GB laptop VM and the installer just froze; the logs were filled with “Cannot allocate memory” errors.

If you’re on a cloud droplet or bare metal server, you’ll be fine. If you only have 2–3 GB, consider running GitLab in Docker instead (see the optional section below).

Update the system
sudo apt update && sudo apt upgrade -y

Keeps your kernel and libraries up to date—GitLab relies on newer packages that may not be present otherwise.

Install required dependencies
sudo apt install curl openssh-server ca-certificates tzdata perl -y
  • curl – pulls the GitLab package.
  • openssh-server – you’ll need SSH access for your repos.
  • ca-certificates and tzdata – prevent SSL and timezone mis‑configurations during installation.
  • perl – required by some of GitLab’s internal scripts.
Add the GitLab package repository
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

This script registers GitLab’s official APT repository, so you get the latest stable CE (Community Edition) release rather than a potentially stale version in Ubuntu’s default repos.

Decide on the installation URL

Pick a fully‑qualified domain or a static IP. If you’re just playing locally, http://localhost works but you’ll still need to set it up for remote access later if you want collaborators.

sudo EXTERNAL_URL="http://your-domain.com" apt install gitlab-ce -y

Replace http://your-domain.com with your real address. GitLab will configure Nginx and SSL (via Let’s Encrypt) automatically on the first run.

Configure firewall

If you’re behind UFW or another firewall, allow HTTP/HTTPS traffic:

sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https

Without this, you won’t be able to reach your new GitLab instance from outside.

Reconfigure and start GitLab

After the package installs, run:

sudo gitlab-ctl reconfigure

This step pulls configuration files, sets up services (nginx, postgresql, redis), and starts everything. You’ll see a progress bar; don’t quit it—GitLab is doing a lot under the hood.

Verify the installation

Open a browser to your domain/IP and you should see GitLab’s welcome page. Log in with the default admin credentials:

  • Username: root
  • Password: the password printed by the installer (you’ll find it in /var/log/gitlab/rails/production.log if you missed it).

Change that password immediately; it’s a security hole otherwise.

Optional – Docker‑based GitLab

If your server only has 2 GB of RAM, install GitLab via Docker:

sudo apt install docker.io -y
docker pull gitlab/gitlab-ce:latest

Then run the container with enough memory and persistent volumes. It’s a bit more involved but saves you from hitting that 4 GB ceiling.

Quick sanity check: If after gitlab-ctl reconfigure you see errors about “cannot find postgresql” or “redis not running,” try:

sudo gitlab-ctl stop
sudo gitlab-ctl start

Sometimes a second run clears transient issues.

That’s it. You now own a fully‑functional GitLab server on Ubuntu 22.04 or 20.04, ready to host your projects, run pipelines, and keep your code safe in your own data center.