On this page
- When is Gogs the right choice?
- How do you create the git user and database?
- How do you download and install the release?
- How do you put Nginx and HTTPS in front?
- How do you complete the web installer?
- How do you configure outgoing mail?
- How do you back up and upgrade Gogs?
- What should you check when something fails?
- Questions
When is Gogs the right choice?
Gogs fits when you want the smallest possible Git web service: repositories, issues, pull requests, wikis and webhooks in one binary that idles in well under 100 MB of memory. It has fewer features than its descendants Gitea and Forgejo (no built-in CI or package registry) and its releases come less often, so check the project's release page and decide whether that pace suits you.
You need:
- Ubuntu 24.04/22.04 or Debian 12/13 with a sudo user.
- DNS records for
git.example.net. - Git and a database. MariaDB is used here; PostgreSQL and SQLite also work.
sudo apt update && sudo apt install -y git wget tar mariadb-server
git --version
sudo systemctl enable --now mariadbHow do you create the git user and database?
Create a system account named git that will own the program and repositories, then a MariaDB database with full UTF-8 support.
sudo adduser --system --shell /bin/bash --gecos 'Gogs' \
--group --disabled-password --home /home/git git
sudo mariadb-secure-installation
sudo mariadb
CREATE DATABASE gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'gogs'@'localhost' IDENTIFIED BY 'Long-Random-Secret';
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost';
FLUSH PRIVILEGES;
EXIT;The login shell must stay /bin/bash, because Git over SSH runs commands as this user through the keys Gogs writes to /home/git/.ssh/authorized_keys.
How do you download and install the release?
Fetch the Linux archive for your architecture, unpack it into the git home, and install the systemd unit that ships inside it.
VER=0.13.3 # replace with the newest release number
cd /tmp
wget https://dl.gogs.io/$VER/gogs_${VER}_linux_amd64.tar.gz
sudo tar -xzf gogs_${VER}_linux_amd64.tar.gz -C /home/git
sudo chown -R git:git /home/git/gogs
sudo -u git /home/git/gogs/gogs --version
sudo cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/
grep -E 'User|WorkingDirectory|ExecStart' /etc/systemd/system/gogs.serviceThe shipped unit expects /home/git/gogs and user git, which matches this layout; the grep confirms it. If the file mentions a different database service in its After= line, change it to mariadb.service. Then start it:
sudo systemctl daemon-reload
sudo systemctl enable --now gogs
sudo ss -ltnp | grep 3000How do you put Nginx and HTTPS in front?
Create a proxy site for the host name, get a certificate with Certbot, and keep port 3000 closed in the firewall.
sudo apt install -y nginx certbot python3-certbot-nginx
sudo tee /etc/nginx/sites-available/gogs >/dev/null <<'EOF'
server {
listen 80;
listen [::]:80;
server_name git.example.net;
client_max_body_size 256M;
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;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/gogs /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo certbot --nginx -d git.example.net --redirectRaise client_max_body_size if people push large files over HTTPS. The Nginx reverse proxy guide explains each header.
How do you complete the web installer?
Open https://git.example.net; the first visit shows the install form, where you enter the database and the public address.
- Database: MySQL, host
127.0.0.1:3306, usergogs, the password you set, databasegogs. - Run user:
git. Domain:git.example.net. SSH port: 22. HTTP port: 3000. - Application URL:
https://git.example.net/. - Admin account: open the optional section and create it now, so nobody else can claim the first account.
Gogs writes /home/git/gogs/custom/conf/app.ini. Then tighten it with sudoedit:
[server]
HTTP_ADDR = 127.0.0.1
[auth]
DISABLE_REGISTRATION = truesudo systemctl restart gogs
sudo ss -ltnp | grep 3000The listener should now show 127.0.0.1:3000 only. Older 0.11 releases used the [service] section for the registration switch, so match the section names your release documents.
How do you configure outgoing mail?
Enable the email section with an authenticated relay on port 587 and restart; Gogs uses it for account activation and notifications.
[email]
ENABLED = true
HOST = smtp.example.net:587
FROM = Gogs <git@example.net>
USER = git@example.net
PASSWORD = change-meThen use the admin panel option to send a test message. Sending straight to recipients on port 25 is not something to rely on from a VPS; ask support by ticket first if you need it, and use the relay meanwhile. The SMTP relay guide covers SPF and DKIM so messages land in inboxes.
How do you back up and upgrade Gogs?
Use the built-in backup command, and upgrade by unpacking the new release next to your custom, data and log folders.
sudo -u git mkdir -p /home/git/backups
cd /home/git/gogs
sudo -u git ./gogs backup --config custom/conf/app.ini --target /home/git/backups
ls -lh /home/git/backupsThe archive holds the database, repositories and custom files; restore with gogs restore --from FILE. To upgrade:
sudo systemctl stop gogs
sudo mv /home/git/gogs /home/git/gogs-old
sudo tar -xzf /tmp/gogs_NEW_linux_amd64.tar.gz -C /home/git
sudo cp -a /home/git/gogs-old/custom /home/git/gogs-old/data /home/git/gogs-old/log /home/git/gogs/
sudo chown -R git:git /home/git/gogs
sudo systemctl start gogsRead the changelog first, keep gogs-old until the new version runs, and copy backups off the server. The daily backup add-on adds a full-disk layer.
What should you check when something fails?
Gogs writes its own log under /home/git/gogs/log/, and systemd keeps start errors in the journal.
sudo journalctl -u gogs -n 50 --no-pager
sudo tail -n 50 /home/git/gogs/log/gogs.log- Installer reappears:
INSTALL_LOCKis false or the service runs from a different folder than the config. - SSH asks for a password: the key is missing in
/home/git/.ssh/authorized_keys, or the folder permissions are too open (700 for.ssh, 600 for the file). - Clone URLs show port 3000:
ROOT_URLin[server]is wrong.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Gogs Git service
How does Gogs compare with Gitea and Forgejo?
Gitea started as a fork of Gogs, and Forgejo later forked Gitea. Both add CI, packages and more admin options; Gogs stays smaller. See the Gitea guide if you need those features.
Can I use SQLite instead of MariaDB?
Yes, choose SQLite3 in the installer. It suits a single user, needs no database server, and backs up with the same command.
Does Gogs have a Docker image?
Yes, an official image exists. It runs its own SSH server inside the container, so you map a second port such as 10022 for clones.
How much memory does it need?
Very little: Gogs plus MariaDB fit comfortably in 1 GB for personal or small team use.
Can I migrate from Gogs to Gitea later?
Yes, Gitea documents a path from Gogs, and both can import repositories over HTTPS with a token.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- 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