How to Install GitLab CE on a VPS

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

Browse more articles in Popular Self-Hosted Applications.

  • gitlab, self hosted git, gitlab ce, ci/cd server
  • 0 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

How to Install Nextcloud on a VPS with Docker

Nextcloud is a self-hosted file sync, sharing, and collaboration platform — a...

How to Install Ghost CMS on a VPS

Ghost is a modern, fast, purpose-built platform for blogging and newsletters — a lighter,...

How to Set Up a Minecraft Server on a VPS

Running your own Minecraft server gives you full control over mods, plugins, and world settings....

How to Install n8n for Workflow Automation

n8n is a self-hosted workflow automation tool — connecting apps and APIs through a visual...

How to Install Gitea (Lightweight Git Server)

Gitea is a lightweight, self-hosted Git service — a much lower-resource alternative to...