Jul 8, 2023 6 min read

How to Install and Configure Gogs on Ubuntu 20.04

In this tutorial, you will install and configure Gogs on Ubuntu 20.04. Gogs is an open-source self-hosted git server written in Go.

Install and Configure Gogs on Ubuntu 20.04
Table of Contents


Before we begin talking about how to install Gogs on Ubuntu 20.04, let’s briefly understand - What Gogs is?

Gogs is an open-source self-hosted git server written in Go. It consist of a repository file editor, tracking of project issues, and a built-in wiki as well. It is a lightweight application, easily installs on low-powered systems. It can be an alternative to Gitlab, having a much smaller memory footprint.

In this tutorial, you will install and configure Gogs on Ubuntu 20.04. We will also address some of the FAQs related to Gogs installation.


  • Gogs may use SQLite, PostgreSQL, or MariaDB database to store all its data.
  • You will use SQLite as the database. Install by running the following command:
sudo apt install sqlite3

For the additional security, we recommend you set up a basic firewall.

Step 1 - Installing Gogs

You will install Gogs from binary. It is a pretty straightforward process.

1) Firstly, install Git on the server. For this refresh the local package index and then install the git package. Do it by running the following commands as a sudo user:

sudo apt update
sudo apt install git

2) Next, verify the installation by displaying the Git version:

git --version

You will get the below output:


git version 2.33.1

3) Now, create a new system user and run the Gogs service by typing:

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

4) Here, the command will create the user and set the home directory to /home/git. The output will look like below:


Adding system user `git' (UID 111) ...
Adding new group `git' (GID 116) ...
Adding new user `git' (UID 111) with group `git' ...
Creating home directory `/home/git' ...

5) Now, visit the Gogs Download page and download the latest binary for architecture. The latest version is 0.13.0, if there is a new version available change the VERSION variable.

6) Now, download the Gogs archive in the /tmp directory. Use the following wget command:

wget https://dl.gogs.io/${VERSION}/gogs_${VERSION}_linux_amd64.tar.gz -P /tmp

7) After downloading, extract the Gogs tar.gz file. Move it to the /home/git directory using the below command:

sudo tar xf /tmp/gogs_*_linux_amd64.tar.gz -C /home/git

8) To change the ownership of the Gogs installation directory to the user and group git, run:

sudo chown -R git: /home/git/gogs

Create a systemd Unit File

1) Now, you will create a systemd Unit File. Gogs comes with a systemd unit file already configured to match the setup.

Copy the file to  /etc/systemd/system/ directory by command:

sudo cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/

2) After that, start and enable the Gogs service, using the below command:

sudo systemctl start gogs
sudo systemctl enable gogs

3) Now, verify that the services start successfully:


* gogs.service - Gogs
   Loaded: loaded (/etc/systemd/system/gogs.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-04-25 04:13:44 PDT; 9s ago
 Main PID: 14376 (gogs)
    Tasks: 8 (limit: 2319)
   CGroup: /system.slice/gogs.service
           `-14376 /home/git/gogs/gogs web

Gogs Installation using a Web Installer

1) Open your browser, then type http://YOUR_DOMAIN_IR_IP:3000. A setting screen will appear.

2) Now, do the database Settings:

  • Database Type - SQLite3
  • The path will be an absolute path, /home/git/gogs/gogs.db

Application General Settings

  • Application Name will be your organization name
  • For repository root path - Leave the default /home/git/gogs-repositories
  • Run User - git
  • Domain - Enter the domain or server the IP address
  • SSH Port - 22, change if the SSH is listening on other Port
  • The HTTP Port - 3000
  • For Application URL - Use http and your domain or server IP address
  • For the log path - leave the default /home/git/gogs/log
You will be able to change the settings later as well. Do it by editing the Gogs configuration file.

3) After that, hit the “Install Gogs” button, where the installation is basically instant. After it gets complete, you will be redirected to the login page.

4) Click on the “Sign-up now” link.

The first registered user automatically gets added to the Admin group.

Step 2 - Configuring Nginx as SSL Termination Proxy

1) To use Nginx as a reverse proxy you will need a domain or subdomain pointing to your server's public IP. So first, install Nginx. Then you will generate a free Let’s Encrypt SSL certificate as per the guidelines below:

2) After this, open your text editor. You will need to edit the domain server block file:

sudo nano /etc/nginx/sites-enabled/gogs.example.com
server {
    listen 80;
    server_name gogs.example.com;

    include snippets/letsencrypt.conf;
    return 301 https://gogs.example.com$request_uri;

server {
    listen 443 ssl http2;
    server_name gogs.example.com;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    client_max_body_size 50m;

    # Proxy headers
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;

    # SSL parameters
    ssl_certificate /etc/letsencrypt/live/gogs.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/gogs.example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/gogs.example.com/chain.pem;
    include snippets/letsencrypt.conf;
    include snippets/ssl.conf;

    # log files
    access_log /var/log/nginx/gogs.example.com.access.log;
    error_log /var/log/nginx/gogs.example.com.error.log;

    # Handle / requests
    location / {
       proxy_redirect off;
Do not forget to replace the gogs.example.com with your Gogs domain. Further, set the correct path to the SSL certificate files. As a result, the HTTP requests will be redirected to HTTPS.

3) Now, restart the Nginx service for the changes to take effect:

sudo systemctl restart nginx

4) Next, you will need to change the Gogs domain and the root URL. For this, open the configuration file and edit the following lines:

sudo nano /home/git/gogs/custom/conf/app.ini
DOMAIN           = gogs.example.com
ROOT_URL         = https://gogs.example.com/

5) Restart the Gogs service by running:

sudo systemctl restart gogs

6) Now the configuration of the Gogs is complete. You can access it at: https://gogs.example.com

Step 3 - Configuring the Email Notifications

1) For Gogs to enable to send notification emails, you can install Postfix. You can also do it by using transactional mail services like SendGrid, MailChimp, MailGun, or the SES.

2) So to enable email notifications, open the configuration file and edit the following lines:

sudo nano /home/git/gogs/custom/conf/app.ini
ENABLED = true

3) You need to make sure to put the right SMTP server information.

4) Then, restart the Gogs service for changes to take place:

sudo systemctl restart gogs

5) Gogs will also allow you to connect to Slack by creating a web webhook. It sends the notification to your Slack channels.

Step 4 - Upgrading Gogs

1) To upgrade Gogs, it needs manual steps. Firstly, you need to stop the Gogs service:

sudo systemctl stop gogs

2) Next, rename the Gogs installation directory using the following command:

sudo mv /home/git/gogs{,_old}

3) Download the latest version of Gogs then move it to the /home/git directory:

wget https://dl.gogs.io/${VERSION}/gogs_${VERSION}_linux_amd64.tar.gz -P /tmp
sudo tar xf /tmp/gogs_*_linux_amd64.tar.gz -C /home/git

4) Also, make sure to change VERSION with the actual Gogs release version.

5) Now, copy the custom, data, log directories to the extracted directory. Do it by using the following rsync command:

sudo rsync -a /home/git/gogs_old/{custom,data,log} /home/git/gogs/

6) Now, finally start the Gogs service:

sudo systemctl restart gogs

FAQs to Install Gogs on Ubuntu 20.04

Which database systems are compatible with Gogs? 

Gogs is compatible with various database systems, including MySQL, PostgreSQL, and SQLite.

Does Gogs provide features like issue tracking and pull requests? 

Yes, Gogs provides features like issue tracking, pull requests, and code reviews, making it a comprehensive solution for managing Git repositories.

Where is the Default configuration in Gogs?

The default configuration is basically saved in conf/app.ini. You will not need to edit it entirely as it is embedded into the binary since v0.6.0.

Is Gogs compatible with other Git clients and IDEs?

Yes, Gogs is compatible with any Git client and can be integrated with popular IDEs such as Visual Studio Code, IntelliJ IDEA, and Eclipse.

Can Gogs be integrated with external tools and services? 

Yes, Gogs can be integrated with external tools and services through webhooks and APIs. You can connect it with CI/CD tools, issue trackers, and other systems for a seamless development workflow.

Can I use Gogs on a machine with limited resources? 

Yes, Gogs is designed to be lightweight and has low resource requirements, making it suitable for running on machines with limited resources such as Raspberry Pi or low-end servers.

Is Gogs suitable for team collaboration? 

Yes, Gogs provides collaboration features like issue tracking, pull requests, and wiki pages, making it suitable for team development and collaboration on Git repositories.


We hope this detailed guide helped you understand how to install Gogs on Ubuntu 20.04 server.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.