TutorialsAugust 4, 20264 min read

How to Install Gitea (Self-Hosted Git) on a VPS

Run your own lightweight GitHub alternative: install Gitea on Ubuntu 24.04 with its own user, a database, systemd, and an Nginx reverse proxy.

NBy Nxeon

Gitea is a lightweight, self-hosted Git service — a fast, open-source alternative to GitHub you run on your own VPS. It handles repositories, issues, pull requests, and CI, using very little memory. This guide installs Gitea on Ubuntu 24.04 the proper way: a dedicated system user, a database, a systemd service, and an Nginx reverse proxy with TLS.

Prepare the system

Gitea needs Git installed on the host:

sudo apt update
sudo apt install git -y

Create a dedicated git system user so Gitea does not run as root or your own account:

sudo adduser --system --shell /bin/bash --gecos 'Gitea' \
  --group --disabled-password --home /home/git git

Create the directory layout

sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea/
sudo chmod -R 750 /var/lib/gitea/
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea

The /etc/gitea directory is temporarily group-writable so the web installer can write the config; you tighten it afterwards.

Download the Gitea binary

Grab the latest release binary (check gitea.io for the current version) and install it:

wget -O gitea https://dl.gitea.com/gitea/1.22.3/gitea-1.22.3-linux-amd64
sudo mv gitea /usr/local/bin/gitea
sudo chmod +x /usr/local/bin/gitea
gitea --version

Set up a database

Gitea can use SQLite for small setups, but PostgreSQL or MySQL is better for anything shared. Following our PostgreSQL guide, create a database and role:

sudo -u postgres psql -c "CREATE ROLE gitea WITH LOGIN PASSWORD 'strong-password';"
sudo -u postgres psql -c "CREATE DATABASE gitea OWNER gitea;"

Create the systemd service

Create /etc/systemd/system/gitea.service:

[Unit]
Description=Gitea
After=network.target postgresql.service

[Service]
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Enable and start it:

sudo systemctl daemon-reload
sudo systemctl enable --now gitea
sudo systemctl status gitea

The systemd service guide explains these directives if you want the detail.

The Nxeon game-server control panel — live console, player slots, and TPS
The Nxeon game-server control panel — live console, player slots, and TPS

Run the web installer

Gitea listens on port 3000 by default. Rather than exposing that, put Nginx in front. Create /etc/nginx/sites-available/git.example.com:

server {
    listen 80;
    server_name git.example.com;
    client_max_body_size 512m;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

The generous client_max_body_size matters — Git pushes and large files exceed the 1 MB default. Enable, reload, and add HTTPS:

sudo ln -s /etc/nginx/sites-available/git.example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d git.example.com

Now browse to https://git.example.com and complete the setup form — choose PostgreSQL, enter the database credentials, set the domain and root URL, and create the admin account. After setup, lock down the config directory:

sudo chmod 750 /etc/gitea
sudo chmod 640 /etc/gitea/app.ini

Enable Gitea Actions for CI

Gitea includes a built-in CI system compatible with GitHub Actions workflows. Turn it on by adding to app.ini:

[actions]
ENABLED = true

Restart Gitea, then register a runner (the act_runner binary) against your instance so pushes can trigger builds, tests, and deploys — a lightweight pipeline with no external service. Workflow files live in .gitea/workflows/ in each repo, mirroring the GitHub Actions format closely enough that many existing workflows run with little change.

Create your first repository

Once logged in, click the + in the top right and choose New Repository. Give it a name, decide public or private, and optionally initialise with a README. Add your public key under Settings → SSH Keys, then clone over SSH:

git clone git@git.example.com:youruser/myrepo.git

From here Gitea behaves like any Git host — branches, pull requests, issues, and releases — but entirely on infrastructure you control.

FAQ

How much RAM does Gitea need?

Very little — Gitea comfortably runs in a few hundred MB, which is why it suits small VPS plans. The database and any CI runners are the heavier components.

Gitea vs GitLab — which should I self-host?

Gitea is lightweight and fast to set up, ideal for individuals and small teams. GitLab is far more feature-rich (full DevOps platform) but wants several GB of RAM. For most self-hosters wanting private repos, Gitea wins on simplicity.

Can I push over SSH as well as HTTPS?

Yes. Gitea supports SSH out of the box using the git user. Add your public key in Gitea's settings and clone with the SSH URL — set up keys first with our SSH keys guide.

How do I back up Gitea?

Use the built-in dump: sudo -u git gitea dump -c /etc/gitea/app.ini produces a single archive of repos, database, and config. Schedule it with a cron job.

Nxeon VPS hosting for developers gives you full root and NVMe speed to self-host Gitea and own your code — with free migration help to move repositories across.

#gitea#git#self-hosted#vps#ubuntu#seobatch

Deploy your first server in under a minute

Creating an account is free and takes no card details. You pay when you deploy — choose a billing term and pay from your wallet or by card at checkout.