GitLab Community Edition is a full-featured, self-hosted DevOps platform — Git repository hosting, CI/CD pipelines, issue tracking, and more, all in one application.
Prerequisites
- A dedicated VPS: 4 vCPU, 8 GB RAM minimum (GitLab is resource-intensive)
- A domain name pointing to your VPS
- Root or sudo access
Step 1 — Install Required Dependencies
sudo apt update
sudo apt install curl openssh-server ca-certificates tzdata perl -y
Step 2 — Add the GitLab Repository
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Step 3 — Install GitLab
sudo EXTERNAL_URL="https://gitlab.yourdomain.com" apt install gitlab-ce -y
This automatically configures GitLab, including requesting a Let's Encrypt certificate for the specified domain.
Step 4 — Allow Required Ports
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 22/tcp
Step 5 — Retrieve the Initial Root Password
sudo cat /etc/gitlab/initial_root_password
This file is automatically deleted after 24 hours — log in and change the password promptly.
Step 6 — Log In
https://gitlab.yourdomain.com
Username: root, password from Step 5.
Step 7 — Change the Root Password Immediately
Under User Settings → Password.
Reducing Resource Usage on a Smaller VPS
GitLab bundles many optional services (Prometheus monitoring, Grafana, extra workers). Disable unnecessary components:
sudo nano /etc/gitlab/gitlab.rb
prometheus_monitoring['enable'] = false
grafana['enable'] = false
puma['worker_processes'] = 2
sudo gitlab-ctl reconfigure
Creating Your First Project
From the dashboard, click New project and follow the setup wizard.
Setting Up a CI/CD Runner
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install gitlab-runner -y
Register it against your GitLab instance using a registration token from your project's CI/CD settings.
Backing Up GitLab
sudo gitlab-backup create
Backups are stored in /var/opt/gitlab/backups by default — sync this off-server as part of your regular backup routine (see How to Set Up Automated VPS Backups).
Restoring from a Backup
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
sudo gitlab-backup restore BACKUP=TIMESTAMP_FILENAME
sudo gitlab-ctl start
Common Errors
GitLab is extremely slow or unresponsive — almost always insufficient RAM; GitLab genuinely needs 8 GB+ RAM for reasonable performance, even for a single-user instance.
502 error immediately after install — GitLab takes several minutes to fully initialize after installation; wait and check sudo gitlab-ctl status.
Best Practices
- Change the root password immediately after first login
- Disable unused bundled components on smaller VPS plans
- Schedule regular backups and store them off-server
Continue Reading
- How to Install Gitea (Lightweight Git Server)
- How to Choose the Right VPS Plan for Your Workload
- How to Set Up Automated VPS Backups
Browse more articles in Popular Self-Hosted Applications.
