natbox.io

Guides / Gitea

Run your own Git server with Gitea

About 15 minutes. For Debian and Ubuntu on Box or bigger. Gitea used about 125 MB of memory in our test. Uses port 10002 as an example, so use one of your own forwarded ports.

1. Download Gitea

This guide was tested with version 1.24.6. Check dl.gitea.com for newer versions.

apt update
apt install -y git curl
curl -fsSL -o /usr/local/bin/gitea https://dl.gitea.com/gitea/1.24.6/gitea-1.24.6-linux-amd64
chmod +x /usr/local/bin/gitea
gitea --version

2. Create its user and folders

adduser --system --group --disabled-password --shell /bin/bash --home /home/git git
mkdir -p /var/lib/gitea/custom /var/lib/gitea/data /var/lib/gitea/log /etc/gitea
chown -R git:git /var/lib/gitea /etc/gitea
chmod 750 /var/lib/gitea /etc/gitea

3. Keep it running

Save as /etc/systemd/system/gitea.service, using your own port:

[Unit]
Description=Gitea
After=network.target

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

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now gitea

4. Finish in your browser

Open http://natbox.io:10002, using your own port. If you use a firewall, run ufw allow 10002/tcp first.

5. Close open sign-ups

Turn off public registration on the same setup page, unless you want strangers to create accounts. To use your own domain and HTTPS, link the domain and proxy to Gitea with Caddy.

Your repositories are in /var/lib/gitea. Include that folder in your backups.