Setup Gogs on Linux

Using a Different System?

  • Setup Gogs on Debian 9 or Ubuntu 16.04

Are we missing a guide for your target system? Request one, or submit your own!


Gogs ( Go Git Service ) is a painless self-hosted Git service. The setup is very easy and it runs on almost every platform that supports Go. Gogs is fully written in the Go-Lang and published as open source.


  • Nginx ( reverse proxy )
  • Go-Lang installed or self-compiled
  • MySQL or SQLite Database

Install pre-requirements

apt-get updateapt-get install golang nginx

Download Gogs

cd /opt/wget

Run Gogs

After downloading Gogs, we can already start running it using the included webserver.

 cd /opt/gogs/ ./gogs web -port 10000

Setup Nginx

Because we don’t want to use the included Gogs webserver, we’ll use Nginx as forwarding proxy. Copy the default Nginx config server-block ( /etc/nginx/sites-enabled/default ) to /etc/nginx/sites-enabled/gogs and remove this part:

    location / {            # First attempt to serve request as file, then            # as directory, then fall back to displaying a 404.            try_files $uri $uri/ /index.html;            # Uncomment to enable naxsi on this location            # include /etc/nginx/naxsi.rules    }

Because Nginx would do nothing, we have to add the reverse-proxy part:

   location / {            proxy_pass;    }

After these steps, we can customize server-name, listen, or anything else we want in the Nginx config.

Configuring Gogs

After starting Gogs and Nginx, it redirects us to a setup page. We need a working MySQL Server for Gogs, because it stores the users in a database. We installed MySQL earlier, so let’s create a new database called “gogs” and a new user called “gogs” and use those credentials in the Gogs configuration. But keep in mind, Gogs also supports other database types, MySQL is just the easiest one to setup.

Enjoy your new Gogs setup on Debian!

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article

No comments

Powered by Blogger.