# How can I install Gitea and host my code on my VPS?
Source: https://vpsdime.com/knowledgebase/technical-questions/install-gitea
Last reviewed: 2026-07-02
Summary: Gitea gives you a self-hosted GitHub, repos, issues, pull requests, CI, in one lightweight binary. The clean Docker-compose install, the reverse proxy and SSL in front, SSH cloning options, first-run settings worth getting right (disable open registration!), and the backup line that makes it durable.

## What this is

[Gitea](https://about.gitea.com/) 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](https://vpsdime.com/knowledgebase/technical-questions/docker-on-vps), and compose keeps Gitea and its database tidy in one file, `/opt/gitea/docker-compose.yml`:

```yaml
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](https://vpsdime.com/knowledgebase/getting-started/securing-public-services)); and container port 22 maps to **2222** so Gitea's SSH cloning doesn't fight [your own sshd](https://vpsdime.com/knowledgebase/getting-started/setting-up-ssh-keys). The `restart: unless-stopped` line is what makes it [survive reboots](https://vpsdime.com/knowledgebase/troubleshooting/services-not-starting-after-reboot).

(Prefer no Docker? Gitea also ships as a single binary with a systemd unit, their [install docs](https://docs.gitea.com/) 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](https://vpsdime.com/knowledgebase/getting-started/pointing-your-domain)), then reverse-proxy to localhost:3000 with [nginx + certbot, or Caddy for the two-line version](https://vpsdime.com/knowledgebase/getting-started/hosting-a-website):

```
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](https://vpsdime.com/knowledgebase/getting-started/securing-your-vps). Enable 2FA on your admin account once inside.

Then add [your SSH key](https://vpsdime.com/knowledgebase/getting-started/setting-up-ssh-keys) in your Gitea profile, and cloning works both ways:

```
git clone ssh://git@git.yourdomain.com: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](https://vpsdime.com/knowledgebase/getting-started/backing-up-your-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](https://vpsdime.com/knowledgebase/technical-questions/systemd-timers) 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](https://vpsdime.com/knowledgebase/getting-started/securing-your-vps).

## Still need help?

You can [open a support ticket](https://vpsdime.com/open-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.

## Related questions

- "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?"
