How to Install and Configure Gogs on Ubuntu 24.04
Learn how to install and configure Gogs on Ubuntu 24.04 LTS. Setup lightweight self-hosted Git with SQLite/MySQL, systemd service, and Nginx proxy.

6 min read
Learn how to install and configure Gogs on Ubuntu 24.04 LTS. Setup lightweight self-hosted Git with SQLite/MySQL, systemd service, and Nginx proxy.
- Prerequisites and Supported Releases
- Step 1: Updating System Repositories and Installing Git
- Step 2: Creating a Dedicated Git User Account
Interactive Builder for this Guide
Build your custom nginx syntax (How to Install and Configure Gogs on Ubuntu 24.04)
server {
listen 80;
listen [::]:80;
server_name app.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
gzip on;
gzip_types text/plain text/css application/json application/javascript application/xml;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
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 "upgrade";
}
}server_nameBinds this virtual host to app.example.comreturn 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPSproxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application serverX-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjackingSelf-hosting your version control system provides ultimate control over sensitive source code, internal compliance policies, and continuous integration workflows. While enterprise platforms like GitLab require multi-gigabyte memory footprints, Gogs (Go Git Service) is engineered with a singular focus: delivering a painless, self-hosted Git service with the absolute minimum resource consumption.
Written in Go and powered by a minimalist web interface, Gogs can run comfortably on a 512 MB VPS or a Raspberry Pi while supporting user management, organization teams, repository issues, pull requests, webhooks, and SSH key authentication. Learning how to install and configure gogs on ubuntu 24.04 gives you a reliable, fast private Git repository server that deploys in minutes.
In this comprehensive step-by-step tutorial, we demonstrate how to install and configure Gogs on Ubuntu 24.04 LTS (Noble Numbat). We cover creating a dedicated system user, downloading official precompiled binaries, configuring directory permissions, setting up a systemd background service, proxying traffic through Nginx with Let's Encrypt SSL, and performing initial repository setup.
Deploy the ultra-lightweight Gogs self-hosted Git service on Ubuntu 24.04 LTS using standalone precompiled binaries, systemd service management, and Nginx SSL reverse proxy.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server or virtual machine running
Ubuntu 24.04 LTS. - A user account with
sudoadministrative privileges. - A domain name or subdomain (e.g.,
gogs.example.com) pointed to your server IP address. - At least
512 MB of RAM(Gogs is extremely resource-efficient and runs seamlessly on minimal hardware).
Step 1: Updating System Repositories and Installing Git
Gogs depends on Git installed on the host operating system to execute low-level repository commands, handle commits, and resolve branch merges.
Update your local package lists and install git, sqlite3, and standard file extraction tools using APT.
Verify that the Git binary is installed and functional.
# Refresh package index and upgrade packages
sudo apt update && sudo apt upgrade -y
# Install Git, SQLite, and network utilities
sudo apt install -y git sqlite3 curl wget tar
# Verify Git version
git --version
Step 2: Creating a Dedicated Git User Account
For security reasons, Gogs should never run under the root account. Create an unprivileged system user named git.
This account will own all repository files, run the Gogs server daemon, and handle incoming Git SSH authentication.
Assign a home directory at /home/git and standard login shell access.
# Create dedicated git system user and group
sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Gogs Git Version Control' git
Step 3: Downloading and Extracting the Gogs Binary Archive
Gogs is distributed as a precompiled standalone binary archive for Linux. This eliminates the need for compilation toolchains or external runtime interpreters.
Download the latest stable 64-bit Linux tarball from the official Gogs GitHub release repository.
Extract the archive directly into the git user's home directory (/home/git).
Set file ownership to the git user.
# Navigate to /tmp and download official Gogs archive
cd /tmp
GOGS_VERSION="0.13.0"
wget https://github.com/gogs/gogs/releases/download/v${GOGS_VERSION}/gogs_${GOGS_VERSION}_linux_amd64.tar.gz
# Extract into /home/git
sudo tar -xzf gogs_${GOGS_VERSION}_linux_amd64.tar.gz -C /home/git
# Assign directory ownership to git user
sudo chown -R git:git /home/git/gogs
Step 4: Configuring Gogs Directory Structure and Custom Config
Gogs stores custom runtime overrides inside /home/git/gogs/custom/conf/app.ini. This file configures listening ports, database types, domain URLs, and security tokens.
Create the custom configuration directory and a dedicated directory for repository storage.
Ensure that all newly created folders inherit proper git:git ownership.
# Create custom configuration and data directories
sudo mkdir -p /home/git/gogs/custom/conf /home/git/gogs-repositories /home/git/gogs/data /home/git/gogs/log
# Ensure git user owns all directories
sudo chown -R git:git /home/git/gogs /home/git/gogs-repositories
Step 5: Setting Up Systemd Service for Gogs
Gogs includes a sample systemd service file inside its distribution directory at /home/git/gogs/scripts/systemd/gogs.service.
Copy this template to /etc/systemd/system/gogs.service.
Reload the systemd daemon, enable the service to start automatically at boot, and start the Gogs server.
Confirm that Gogs is active and listening on default port 3000.
# Copy systemd service file
sudo cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/
# Reload systemd and enable Gogs service
sudo systemctl daemon-reload
sudo systemctl enable --now gogs
# Check service status
sudo systemctl status gogs --no-pager
Step 6: Configuring Nginx Reverse Proxy
By default, Gogs serves HTTP traffic on internal port 3000. To expose the service securely over standard port 80/443, configure Nginx as a reverse proxy.
Install Nginx using APT and create a server configuration file at /etc/nginx/sites-available/gogs.conf.
Configure proxy parameters to forward requests to http://127.0.0.1:3000 and permit large Git packfile uploads by setting client_max_body_size 100M;.
Enable the site and reload Nginx.
# Install Nginx web server
sudo apt install -y nginx
# Create Nginx reverse proxy configuration
sudo bash -c 'cat <<EOF > /etc/nginx/sites-available/gogs.conf
server {
listen 80;
server_name gogs.example.com;
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;
client_max_body_size 100M;
}
}
EOF'
# Enable site and reload Nginx
sudo ln -s /etc/nginx/sites-available/gogs.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Step 7: Securing Gogs with Let's Encrypt SSL
Encrypting user logins, API authentication tokens, and git push/pull operations is critical for code security.
Install Certbot and the Nginx plugin, then execute Certbot to obtain and configure a free Let's Encrypt SSL certificate for your Gogs domain.
Certbot will automatically configure HTTPS redirects and renew certificates via systemd timers.
# Install Certbot and Nginx plugin
sudo apt install -y certbot python3-certbot-nginx
# Issue and bind SSL certificate
sudo certbot --nginx -d gogs.example.com
Step 8: Completing the Web-Based Setup Wizard
Open your web browser and navigate to https://gogs.example.com to access the initial configuration wizard.
1. Database Type: Select SQLite3 (for simple single-server setups) or MySQL/PostgreSQL if you prefer an external database.
2. Application Settings: Set Application Name, Repository Root Path (/home/git/gogs-repositories), Run User (git), and Domain (gogs.example.com).
3. Application URL: Set your full domain URL: https://gogs.example.com/.
4. Admin Account: Expand the Optional Settings section to create your initial administrator user and password.
Click Install Gogs. After setup finishes, lock file permissions on the configuration file for security.
# Secure the custom configuration file permissions
sudo chmod 640 /home/git/gogs/custom/conf/app.ini
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Gogs fails to start with 'bind: address already in use'
Resolution: This indicates that another process is already listening on port 3000. Identify the conflicting process using sudo ss -tulpn | grep 3000 or change Gogs's listening port to 3001 in /home/git/gogs/custom/conf/app.ini.
Permission denied when cloning or pushing over SSH
Resolution: Ensure that the git user's shell is set to /bin/bash in /etc/passwd, and verify that /home/git/.ssh/authorized_keys has 0600 permissions.
502 Bad Gateway error on Nginx
Resolution: Verify that the Gogs service is active using sudo systemctl status gogs and check Gogs runtime log output located at /home/git/gogs/log/gogs.log.
Security Best Practices and Hardening
Always restrict read and write permissions on /home/git/gogs/custom/conf/app.ini using sudo chmod 640 to protect database passwords and security secret keys.
Disable public user registration under [service] DISABLE_REGISTRATION = true in app.ini if your Gogs instance is strictly for private internal teams.
Enforce HTTPS across all web and git clone endpoints to protect credentials and code from man-in-the-middle attacks.
Regularly create automated database and repository backups by running the built-in backup tool: sudo -u git /home/git/gogs/gogs backup.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
sudo -u git /home/git/gogs/gogs backup --target=/backup/gogs to create a complete archive containing all repositories, user accounts, and database records.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!