List of Articles Icon

Knowledge Base

Guides and answers for your VPS, the client area, and billing

How can I install Gitea and host my code on my VPS?

What this is

Gitea is the self-hosted GitHub: private and public repos, issues, pull requests, a web UI, even built-in CI (Gitea Actions, workflow-compatible with GitHub's), in a single lightweight service that runs happily on a small plan. Owning your code hosting is one of the classic good reasons for a VPS, and Gitea is the tool that made it easy.

Install: the Docker-compose way

Docker works out of the box, and compose keeps Gitea and its database tidy in one file, /opt/gitea/docker-compose.yml:

services:
  gitea:
    image: docker.gitea.com/gitea:latest
    restart: unless-stopped
    environment:
      - GITEA__database__DB_TYPE=sqlite3
    volumes:
      - ./data:/data
    ports:
      - "127.0.0.1:3000:3000"
      - "2222:22"
cd /opt/gitea && docker compose up -d

Notes on the choices: SQLite is genuinely fine for a personal/small-team instance (swap in a MariaDB service later if you grow); the web port is published to localhost only because a reverse proxy fronts it (the exposure rule); and container port 22 maps to 2222 so Gitea's SSH cloning doesn't fight your own sshd. The restart: unless-stopped line is what makes it survive reboots.

(Prefer no Docker? Gitea also ships as a single binary with a systemd unit, their install docs cover it, and everything below applies the same.)

Put a real domain and SSL in front

Point a subdomain (git.yourdomain.com) at the VPS (DNS), then reverse-proxy to localhost:3000 with nginx + certbot, or Caddy for the two-line version:

git.yourdomain.com {
    reverse_proxy localhost:3000
}

(That's the entire Caddyfile, HTTPS included.) Browse to the domain and Gitea's first-run page appears.

First-run settings worth getting right

Most defaults are fine; these four aren't cosmetic:

  • Server domain / base URL: set them to your real domain now, clone URLs are generated from these.
  • SSH server port: 2222 (matching the compose mapping), so clone URLs come out right.
  • Create the admin account on this screen, and
  • Disable open registration (or set it to invite-only) unless you want the internet signing up: a public registration page on a code host collects spam accounts within days, same logic as any exposed login. Enable 2FA on your admin account once inside.

Then add your SSH key in your Gitea profile, and cloning works both ways:

git clone ssh://[email protected]:2222/you/repo.git
git clone https://git.yourdomain.com/you/repo.git

Make it durable

Your code is now irreplaceable data on a VPS, and Gitea makes the backup half easy: docker compose exec gitea gitea dump produces a single restorable archive (repos, database, config), drop that into a scheduled job whose output your restic run ships off-site, and the self-hosting trade-off is fully paid. Updates: docker compose pull && docker compose up -d, on a schedule you own, like any internet-facing app.

Still need help?

You can open a support ticket. So we can help on the first reply, it's worth mentioning:

  • the VPS hostname or IP, and the domain you're putting Gitea on,
  • where it stops (compose, the proxy, SSL, first-run), with the log line.
  • "How do I self-host a Git server on my VPS?"
  • "How do I install Gitea with Docker?"
  • "How do I set up SSL and a domain for Gitea?"
  • "Why should registration be disabled on my Gitea?"
  • "How do I back up Gitea?"
Last reviewed: 2026-07-02