Setup Gogs on Linux

Updated on April 24, 2016
Setup Gogs on Linux header image


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 update
apt-get install golang nginx

Download Gogs

cd /opt/

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 / {

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!