On this page
- How much server does GitLab need?
- How do you prepare the system and firewall?
- How do you install the GitLab CE package?
- How do you lock down sign-ups and access?
- How do you reduce memory use on a smaller plan?
- How do you send mail through an SMTP relay?
- How do you back up and upgrade GitLab?
- How do you check health and troubleshoot?
- Questions
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 -hPort 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-ceThe 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_passwordThat 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.gitThe 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.rbpuma['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 -hThese 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.jsonWithout 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 reconfigureagain. - 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.
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?
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.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM