On this page
- What do you need before installing Gitea?
- How do you download and verify the binary?
- How do you create the git user and folders?
- How do you set up the PostgreSQL database?
- How do you run Gitea as a systemd service?
- How do you publish Gitea with Nginx and HTTPS?
- How do you finish the installer and secure the config?
- How do you back up, upgrade and troubleshoot Gitea?
- Questions
What do you need before installing Gitea?
Gitea is a single Go binary that needs Git, a database and a reverse proxy. It runs comfortably on 1 GB of memory for a few people; give it more if you plan to enable Actions runners or mirror many repositories.
- Ubuntu 24.04/22.04, Debian 12/13, Rocky Linux 9 or AlmaLinux 9 with a sudo user.
- DNS records for
git.example.netpointing at the server. - SSH already hardened as in SSH keys and hardening, because Git over SSH uses the same daemon.
# Ubuntu, Debian
sudo apt update && sudo apt install -y git wget
# Rocky, Alma
sudo dnf install -y git wget
git --versionHow do you download and verify the binary?
Fetch the release file and its checksum from the official download site, verify it, and install it as /usr/local/bin/gitea.
VER=1.25.2 # set to the current stable release from the Gitea releases page
cd /tmp
wget https://dl.gitea.com/gitea/$VER/gitea-$VER-linux-amd64
wget https://dl.gitea.com/gitea/$VER/gitea-$VER-linux-amd64.sha256
sha256sum -c gitea-$VER-linux-amd64.sha256
sudo install -m 755 gitea-$VER-linux-amd64 /usr/local/bin/gitea
gitea --versionThe version shown above is only an example; check the releases page and use the newest stable number. On an Arm server use the linux-arm64 file instead.
How do you create the git user and folders?
Gitea runs as an unprivileged git user whose home holds the SSH authorized_keys file Gitea manages.
# Ubuntu, Debian
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' \
--group --disabled-password --home /home/git git
# Rocky, Alma
sudo groupadd --system git
sudo useradd --system --shell /bin/bash --comment 'Git Version Control' \
--gid git --create-home --home-dir /home/git git
sudo mkdir -p /var/lib/gitea/custom /var/lib/gitea/data /var/lib/gitea/log
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
sudo mkdir -p /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/giteaThe config folder stays writable for the web installer; you lock it down after setup.
How do you set up the PostgreSQL database?
Install PostgreSQL, create a login role and a UTF-8 database owned by it. SQLite also works for one or two users, but PostgreSQL handles concurrent pushes and larger instances better.
# Ubuntu, Debian
sudo apt install -y postgresql
# Rocky, Alma
sudo dnf install -y postgresql-server
sudo postgresql-setup --initdb
sudo systemctl enable --now postgresql
sudo -u postgres psql -c "CREATE ROLE gitea WITH LOGIN PASSWORD 'Long-Random-Secret';"
sudo -u postgres psql -c "CREATE DATABASE giteadb OWNER gitea ENCODING 'UTF8' TEMPLATE template0;"
psql -h 127.0.0.1 -U gitea -d giteadb -c 'SELECT version();'On Rocky and Alma the default pg_hba.conf uses ident for TCP connections from 127.0.0.1, so the test fails until you change that line to scram-sha-256 in /var/lib/pgsql/data/pg_hba.conf and restart PostgreSQL. More on this in Install PostgreSQL.
How do you run Gitea as a systemd service?
Create a unit that starts the web process as the git user with the config file in /etc/gitea.
sudo tee /etc/systemd/system/gitea.service >/dev/null <<'EOF'
[Unit]
Description=Gitea
After=network.target postgresql.service
[Service]
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
RestartSec=2s
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now gitea
sudo ss -ltnp | grep 3000Do not open port 3000 in the firewall. You will reach the installer through Nginx in the next step.
How do you publish Gitea with Nginx and HTTPS?
Proxy the host name to 127.0.0.1:3000, open web ports and request a certificate with Certbot.
server {
listen 80;
listen [::]:80;
server_name git.example.net;
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;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
}
}Save it as /etc/nginx/sites-available/gitea and link it into sites-enabled on Ubuntu and Debian, or as /etc/nginx/conf.d/gitea.conf on Rocky and Alma.
# Ubuntu, Debian
sudo apt install -y nginx certbot python3-certbot-nginx
sudo ufw allow 'Nginx Full'
# Rocky, Alma
sudo dnf install -y epel-release
sudo dnf install -y nginx certbot python3-certbot-nginx
sudo setsebool -P httpd_can_network_connect 1
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload
sudo systemctl enable --now nginx
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d git.example.net --redirectThe SELinux boolean lets Nginx connect to a local upstream on Rocky and Alma; without it you get a 502.
How do you finish the installer and secure the config?
Open https://git.example.net, fill in the database fields, set the base URL and SSH domain, create the first admin, then lock the config folder.
In the form choose PostgreSQL with host 127.0.0.1:5432, user gitea and database giteadb. Set Server Domain and SSH Server Domain to git.example.net, and the Base URL to https://git.example.net/. Expand the admin account section and create your user there. Afterwards:
sudo chmod 750 /etc/gitea
sudo chmod 640 /etc/gitea/app.ini
sudoedit /etc/gitea/app.iniAdd or change these keys, then sudo systemctl restart gitea:
[server]
HTTP_ADDR = 127.0.0.1
[service]
DISABLE_REGISTRATION = true
[mailer]
ENABLED = true
PROTOCOL = smtp+starttls
SMTP_ADDR = smtp.example.net
SMTP_PORT = 587
FROM = Git <git@example.net>
USER = git@example.net
PASSWD = `change-me`The mailer block sends through an authenticated relay on 587. Port 25 from the VPS is not guaranteed open, so ask support by ticket before planning direct mail; the SMTP relay guide shows the relay setup. Test with Site Administration, Configuration, Send test email.
How do you back up, upgrade and troubleshoot Gitea?
Use gitea dump for a full archive, upgrade by swapping the binary, and read the service journal when something breaks.
cd /tmp
sudo -u git /usr/local/bin/gitea dump --config /etc/gitea/app.ini --work-path /var/lib/gitea
# upgrade
sudo systemctl stop gitea
sudo install -m 755 /tmp/gitea-NEW-linux-amd64 /usr/local/bin/gitea
sudo systemctl start gitea
gitea --version
sudo journalctl -u gitea -n 50 --no-pagerThe dump bundles repositories, the database and config into one zip in the current folder. Read the release notes before each upgrade, since some versions change config keys. Clone over SSH with git clone git@git.example.net:deploy/site.git after adding your public key in user settings. If that asks for a password, check that /home/git/.ssh/authorized_keys exists and is owned by git. For hooks that deploy on push, see deploy with a bare repository and hooks.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Gitea Git hosting
Can I run Gitea in Docker instead?
Yes, the official image works with a Compose file much like the Forgejo guide. The binary route avoids mapping a second SSH port.
Does Gitea support CI?
Gitea Actions runs workflows in a GitHub Actions compatible format through a separate runner, act_runner. Woodpecker CI is another option.
How much memory does Gitea need?
About 1 GB covers a small team with PostgreSQL on the same server. Add memory for runners, large mirrors or code search indexing.
Can I import repositories from another forge?
Yes. New Migration imports repositories, and for some forges also issues, pull requests and releases, using an access token.
How do I reset the admin password?
Run sudo -u git gitea admin user change-password --username NAME --password NEW --config /etc/gitea/app.ini.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM