Log inSign up

GitLab Community Edition on a self-managed server

Add the GitLab CE package repository with its setup script, then run sudo EXTERNAL_URL="https://gitlab.example.net" apt install gitlab-ce. The package brings its own Nginx, PostgreSQL and Redis, and with an https external URL it requests a Let's Encrypt certificate on its own. Sign in as root with the password in /etc/gitlab/initial_root_password. Plan at least 4 GB of memory; the GitLab app image does the install for you.

Topic: Self-hosted apps · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13 · Updated 2026-12-03

How much server does GitLab need?

GitLab is the heaviest application in this category: plan 4 GB of memory as the floor for a few users and 8 GB for a comfortable team setup, with 4 vCPU when CI is busy.

The package runs many services at once (Puma, Sidekiq, Gitaly, PostgreSQL, Redis, Nginx and monitoring), and each takes its share. On 4 GB you will want the memory settings later in this guide plus a swap file. Disk grows with repositories, CI artifacts and container images, so leave headroom. If the server becomes tight, deploy a larger plan and move across with the migration tutorial, since plans do not resize in place.

Supported here: Ubuntu 24.04 and 22.04, Debian 12 and 13 (check the GitLab install page for the current list). Prepare a host name, gitlab.example.net, with A and AAAA records already pointing at the server.

How do you prepare the system and firewall?

Install the few dependencies the package expects, add swap on small plans, and open SSH, HTTP and HTTPS.

sudo apt update && sudo apt full-upgrade -y
sudo apt install -y curl ca-certificates tzdata perl openssh-server
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile && sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
free -h

Port 80 must be reachable during installation, because the certificate request uses an HTTP challenge. More background on rule sets is in the UFW guide.

How do you install the GitLab CE package?

Run the official repository script, then install with the external URL set; the package configures everything on first run.

curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
apt policy gitlab-ce
sudo EXTERNAL_URL="https://gitlab.example.net" apt install -y gitlab-ce

The install takes several minutes while it runs gitlab-ctl reconfigure. When it finishes, check the services and fetch the first password:

sudo gitlab-ctl status
sudo cat /etc/gitlab/initial_root_password

That file is deleted automatically after 24 hours, so sign in at https://gitlab.example.net as root straight away and set a new password under your profile. Then create a normal account for daily work and keep root for administration.

How do you lock down sign-ups and access?

Turn off open registration in the Admin area, require two-factor login, and add SSH keys for Git access.

Go to Admin, Settings, General, Sign-up restrictions and clear "Sign-up enabled", or restrict sign-ups to your email domain with admin approval. Under Sign-in restrictions you can require two-factor authentication for everyone. Each user adds a public key under Preferences, SSH Keys; Git over SSH then uses the server sshd on port 22 as the git user:

ssh -T git@gitlab.example.net
git clone git@gitlab.example.net:deploy/site.git

The first command should greet you by user name. If you moved the server SSH port, set gitlab_rails['gitlab_shell_ssh_port'] in /etc/gitlab/gitlab.rb so the clone URLs shown in the interface match.

How do you reduce memory use on a smaller plan?

Run Puma in single mode, lower Sidekiq concurrency and switch off the bundled monitoring stack; together these save a large share of memory.

sudoedit /etc/gitlab/gitlab.rb
puma['worker_processes'] = 0
sidekiq['concurrency'] = 10
prometheus_monitoring['enable'] = false
gitlab_rails['env'] = {
  'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000'
}
gitaly['env'] = {
  'GITALY_COMMAND_SPAWN_MAX_PARALLEL' => '2'
}
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
free -h

These follow GitLab's own advice for memory-constrained environments. The cost is lower throughput under load, which a small team rarely notices. With 8 GB or more you can leave the defaults.

How do you send mail through an SMTP relay?

Configure the SMTP block in gitlab.rb with a relay on port 587 and STARTTLS, reconfigure, and send a test from the Rails console.

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.example.net"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "gitlab@example.net"
gitlab_rails['smtp_password'] = "change-me"
gitlab_rails['smtp_domain'] = "example.net"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = "gitlab@example.net"
sudo gitlab-ctl reconfigure
sudo gitlab-rails runner "Notify.test_email('you@example.net', 'GitLab test', 'It works').deliver_now"

GitLab sends a lot of mail (pipeline results, mentions, sign-in alerts). Plan on the relay rather than direct delivery: port 25 is not guaranteed on a VPS, so ask support by ticket before considering it. Send app mail through an SMTP relay covers the sender records.

How do you back up and upgrade GitLab?

Use gitlab-backup create for data, copy the two secret config files separately, and upgrade along the documented path one required stop at a time.

sudo gitlab-backup create
sudo ls -lh /var/opt/gitlab/backups/
sudo tar -czf /root/gitlab-config-$(date +%F).tar.gz /etc/gitlab/gitlab.rb /etc/gitlab/gitlab-secrets.json

Without gitlab-secrets.json a restore loses CI variables and two-factor data, so never skip it. For upgrades within a series, sudo apt update && sudo apt install gitlab-ce is enough. Across major versions GitLab defines required upgrade stops; install each stop version in turn (for example sudo apt install gitlab-ce=VERSION-ce.0) and wait for background migrations to finish under Admin, Monitoring before the next step. A pre-upgrade backup plus the daily backup add-on makes rollbacks painless.

How do you check health and troubleshoot?

Use the built-in checks: gitlab-ctl status for services, gitlab-rake gitlab:check for configuration, and gitlab-ctl tail for live logs.

sudo gitlab-ctl status
sudo gitlab-rake gitlab:check SANITIZE=true
sudo gitlab-rake gitlab:env:info
sudo gitlab-ctl tail nginx
  • 502 page for minutes after a restart: Puma is still booting; wait, then check memory with free -h.
  • Certificate not issued: DNS did not point at the server or port 80 was closed during reconfigure. Fix it, then run sudo gitlab-ctl reconfigure again.
  • Random process kills: the kernel OOM killer; add swap, apply the memory settings or move to a bigger plan.

For CI jobs, install GitLab Runner on a separate server so builds do not compete with GitLab itself.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A4-8small team with tuned memory4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months
A4-12team with active CI4 vCPU, 12 GB RAM, 260 GB NVMe$43.20/mo$43.20 for 1 month
A8-16larger groups and registry use8 vCPU, 16 GB RAM, 350 GB NVMe$57.60/mo$57.60 for 1 month

Questions about GitLab Community Edition

Can I skip the install?

Yes. Deploy the GitLab app image on Ubuntu 24.04; the admin details appear on the instance page in the console, and you continue from the domain and HTTPS step.

Does GitLab CE include CI/CD?

Yes. Pipelines are part of the Community Edition; you only need at least one runner to execute jobs.

Can I use my own Nginx or Caddy in front?

Yes, by disabling the bundled Nginx in gitlab.rb and proxying to GitLab Workhorse. It adds moving parts, so most people keep the bundled web server.

Why is the first page so slow after a restart?

GitLab loads a large Rails application on start. On 4 GB this takes a few minutes; later requests are much faster.

Is there a lighter alternative?

If you mostly need repositories, issues and pull requests, Gitea or Forgejo run in about 1 GB.

Should I enable the container registry?

Only if you need it; it adds disk use. Enable it in gitlab.rb with registry_external_url and reconfigure.