Self-host Forgejo on a VPS
Run Forgejo, a community-run Git forge, on your own VPS from its signed LTS binaries, with HTTPS on your domain and Git over SSH.
To self-host Forgejo on a VPS, install its signed release binary as a service running as a git user, keep its web interface on localhost behind a reverse proxy with HTTPS, and let Git over SSH use the server's own SSH. On VPSNine the Forgejo one-click app does that from the long-term-support line, with registration off and an owner account only you know.
Forgejo is a fork of Gitea run by the community, with repositories, issues, pull requests, packages and Actions. It's a single Go program, so it's light on a small server.
What you need
- The Budget plan runs Forgejo for one person or a small team, with SQLite. Choose Standard for large repositories, many users, or a Forgejo Actions runner on the same server; CI jobs are what use the CPU. The plans page has the specs.
- A domain or subdomain, like
git.example.com. - An SSH key on your computer for pushing. SSH keys explains how to make one.
Forgejo Actions needs a separate Forgejo Runner, which the one-click app doesn't install.
Install it with the one-click app
Order a server with the Forgejo app. It downloads the newest v15 LTS binary from Codeberg, checks its signature, and sets it up as Forgejo's binary-install guide describes: a git user, SQLite in /var/lib/forgejo, the configuration in /etc/forgejo/app.ini, the web interface on 127.0.0.1:3000 and Git over the server's own SSH on port 22. The install page is locked, registration is off, and the owner account is made from the command line with a random password.
Log in over SSH and read the owner account's password:
cat /root/forgejo-admin.txtFrom your computer, open a tunnel to the web interface:
ssh -L 3000:127.0.0.1:3000 root@203.0.113.10Open
http://localhost:3000, log in asowner, and set your real email in Settings.Set up HTTPS (next section).
Add your SSH public key in Settings, SSH / GPG keys, create a repository, then push:
git remote add origin git@git.example.com:owner/myproject.git git push -u origin main
On the server, curl http://127.0.0.1:3000/api/healthz reports pass when Forgejo is healthy.
Put it on your domain with HTTPS
Nothing is public until you do this. Point an A record for git.example.com at the server, allow ports 80 and 443 in the panel firewall, then run:
vps9-https git.example.comFirst it sets DOMAIN, ROOT_URL (https://git.example.com/) and SSH_DOMAIN in /etc/forgejo/app.ini and restarts Forgejo, so the clone addresses it shows are right. Then it installs Caddy, which proxies the domain to 127.0.0.1:3000 and gets and renews the certificate. Run it again with another domain to move.
Port 22 is already open for SSH, and Git uses it too, so there's nothing else to open.
Doing it by hand on another server
Follow Forgejo's binary installation guide. In outline:
- Download the binary for your architecture from Forgejo's releases on Codeberg, check its GPG signature as the download page describes, and install it as
/usr/local/bin/forgejowith mode 755. - Install
gitandgit-lfs, and create agitsystem user with/home/gitas its home. - Create
/var/lib/forgejo(owned bygit, mode 750) and/etc/forgejo(owned byroot:git). - Install the systemd unit from Forgejo's repository as
/etc/systemd/system/forgejo.service, thensystemctl enable --now forgejo. - Finish the web installer on port 3000. Reach it through an SSH tunnel rather than opening 3000 to the internet, set the base URL to your
https://domain, and create the admin account there. - Tighten
/etc/forgejoto mode 750 andapp.inito 640 afterwards, and put Caddy or nginx in front for HTTPS.
Updates and backups
Updates are yours to run. Read the release notes, download the next v15 binary from Codeberg, and check its signature against Forgejo's release key:
gpg --keyserver hkps://keys.openpgp.org --recv-keys EB114F5E6C0DC2BCDD183550A4B61A2DC5923710
gpg --verify forgejo-15.x.y-linux-amd64.asc forgejo-15.x.y-linux-amd64Then replace the binary and restart:
install -m 0755 forgejo-15.x.y-linux-amd64 /usr/local/bin/forgejo
systemctl restart forgejov15 is supported until July 2027. The one-click app turns on the operating system's automatic security updates, which don't touch Forgejo.
Back up with forgejo dump, run as the git user from a folder it can write to:
cd /home/git
runuser -u git -- env HOME=/home/git forgejo dump -c /etc/forgejo/app.ini -w /var/lib/forgejoIt writes a zip archive of the repositories, database and configuration to the current folder. Copy it off the server; Backups you should run shows how to schedule it.
When it goes wrong
git cloneorgit pushover SSH saysPermission denied (publickey): Git over SSH logs in as thegituser, never asrootor your own name, and only accepts the keys you added in Forgejo under Settings, SSH / GPG keys. Usegit@git.example.com:owner/repo.gitand check the key you added is the one your computer offers (ssh -T git@git.example.comtells you who Forgejo thinks you are).- Clone addresses show the server's IP address or
localhost:vps9-httpshasn't run yet, soDOMAINandSSH_DOMAINstill hold the defaults. Run it with your domain. - You moved the server's SSH to another port: Git follows it. Set
SSH_PORTin/etc/forgejo/app.inito the new port, runsystemctl restart forgejo, and allow that port in the panel firewall.