How To

Install Gogs on Ubuntu 18.04: Self-Hosted Git Server Setup Guide

Gogs is a free, self-hosted Git service written in Go. It gives you a private GitHub-like environment on your own server, complete with repository browsing, issue tracking, pull requests, team management, and a built-in wiki. It is a lighter-weight alternative to GitLab and uses significantly less memory. Gogs runs comfortably on a small VPS or even a Raspberry Pi.

This guide walks you through installing Gogs on Ubuntu 18.04 from the official binary, running it as a systemd service, and configuring Nginx as an SSL reverse proxy.

<strong>Prerequisites:</strong>&nbsp;You need sudo access. This guide uses SQLite as the database. Install it if it is not already present:
bashsudo apt install sqlite3

Install Gogs on Ubuntu

Install Git and create the service user

Install Git first:

bashsudo apt update &amp;&amp; sudo apt install git

Create a dedicated system user to run the Gogs process. This account has no login password and cannot SSH in directly, which limits the attack surface if the service is ever compromised:

bashsudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Git Version Control' git

Download and set up the Gogs binary

Check the Gogs download page for the latest release and download the archive. Replace the VERSION value if a newer release is available:

bashVERSION=0.11.86wget https://dl.gogs.io/${VERSION}/gogs_${VERSION}_linux_amd64.tar.gz -P /tmpsudo tar xf /tmp/gogs_*_linux_amd64.tar.gz -C /home/gitsudo chown -R git: /home/git/gogs

Start the Gogs service

Gogs ships with a pre-built systemd unit file. Copy it to the system directory, then start and enable the service:

bashsudo cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/sudo systemctl start gogssudo systemctl enable gogs

Complete the Setup via the Web Installer

Open http://YOUR_SERVER_IP:3000 in a browser. The web installer prompts you to configure:

  • Database Settings: Select SQLite3 and set the path to /home/git/gogs/gogs.db
  • Application Settings: Enter your application name, confirm the repository root (/home/git/gogs-repositories), set Run User to git, and enter your domain or server IP
  • HTTP Port: Leave as 3000 unless you need a different port

Click Install Gogs. The process finishes instantly and redirects you to the login page. Click Sign up now to register. The first account created is automatically assigned admin privileges.

Configure Nginx as an SSL Reverse Proxy

Running Gogs behind Nginx with a valid SSL certificate is strongly recommended for any public-facing server. You will need a domain name pointing to the server and a Let’s Encrypt certificate already installed on Nginx.

Configure Nginx to proxy port 3000 over HTTPS, then update the Gogs configuration to use the new domain:

bashsudo nano /home/git/gogs/custom/conf/app.ini

Update the server section:

[server]DOMAIN   = gogs.example.comROOT_URL = https://gogs.example.com/

Restart Gogs to apply the change:

bashsudo systemctl restart gogs

Gogs also supports email notifications via any SMTP provider. Configure the [mailer] block in app.ini with your SMTP credentials and restart the service. For Slack notifications, use Gogs’s built-in webhook integration under each repository’s settings page.

Upgrading Gogs: Stop the service, rename the old directory, download and extract the new binary, copy customdatalog, and gogs.db from the old directory using rsync, then restart Gogs.

Gogs is now installed and running on your Ubuntu 18.04 server. Create your first repository, invite your team, and start using your private Git server today. Leave a comment below if you run into any issues.

Cyber Defence

Recent Posts

Install Opera Web Browser on Ubuntu 18.04: Complete Setup Guide

Opera is one of the most popular cross-platform web browsers in the world, available on Windows,…

2 hours ago

Install Elasticsearch on Ubuntu 18.04: Setup and Config Guide

Elasticsearch is an open-source distributed search and analytics engine built on Apache Lucene. It supports RESTful…

2 hours ago

Install Flask on Ubuntu 18.04: venv Setup and Hello World App

Flask is a free, open-source micro web framework for Python. It is built on Werkzeug and…

2 hours ago

Install Memcached on Ubuntu 18.04: Setup, Config, and Client Guide

Memcached is a free, open-source, high-performance in-memory caching system. It stores data as key-value pairs in…

2 hours ago

Install TensorFlow on Ubuntu 18.04: Python venv Setup and Usage

TensorFlow is a free, open-source machine learning platform developed by Google. It is used by major…

23 hours ago

Install Minecraft Server on Ubuntu 18.04: Systemd Setup Guide

Minecraft is one of the most popular games ever made — a sandbox game where players…

24 hours ago