How to Configure Gogs on Ubuntu 15.04

Gogs(Go Git Service) a painless self-hosted Git Service written in Go. As its built with Go, so we automatically get its cross-platform compatibility that it supports, including Linux, Mac OS and Windows. Gogs has really low footprints so its easy on low system resources. In this article we will guide you with simple steps and to get it up and running on Ubuntu 15.04 with its web interface, admin dashboard and all its operational functions where you can preferably host your codes because of its many great features, easy to use and access.

Basic Requirements

In order to setup Gogs we need an update OS with its basic resources and following mandatory packages.

  • MySQL version 5.1 or greater.
  • git(bash) version 1.8.0 or greater

We will setup gogs installation and its configurations within the following environment as a general user with sudo privileges.

Gogs (Go Git Service)
Base Operating System Ubuntu 15.04 (GNU/Linux 3.19.0-15-generic x86_64)
Database mysql  Ver 14.14 Distrib 5.6.24, for debian-linux-gnu (x86_64)
Go go1.4.2.linux-amd64.tar.gz
Git git version 2.1.4
RAM and CPU 2 GB  , 1.0 GHZ
Hard Disk 30 GB

System Update

Before starting with installation we need to make sure that our system is upto date, we can always do so by using following command.

[email protected]:~#apt-get update

Create New User

We are going to create a new user that we will use for the whole setup and installation under this user.

[email protected]:~# adduser git

Grant super user privileges to user "git"

[email protected]:~# visudo
# User privilege specification

Start Installation Process

First we need to install the prerequisites that are necessary for Gogs setup.

Git Installation

Ubuntu 15.04 comes with pre installed git latest version, so don't need to re install it. We can check its version using following command.

[email protected]:~$ git --version
git version 2.1.4

MySQL Database Installation

In these steps will install mysql server and then create a new database and a user that will serves as Gogs database.

Step 1: Install mysql using apt-get

[email protected]:~$ sudo apt-get install mysql-server mysql-server-5.6

[email protected]:~$sudo systemctl status mysql

[email protected]:~$ sudo mysql --version
mysql Ver 14.14 Distrib 5.6.24, for debian-linux-gnu (x86_64) using EditLine wrapper

Step 2: Choose the root password

During the installation process it will ask for mysql root user password, so choose a secured password.

Set Password

Step 3: Create New Database and user for Gogs as folowing:

[email protected]:~$ sudo mysql -u root -p
Enter password:
mysql> SET GLOBAL storage_engine = 'InnoDB';
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'gogs'@'localhost' IDENTIFIED by 'gogs123';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY 'gogs123';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> \q

Go Installation

We will install the go(bash) package in a separate directory so that it wouldn't interface with future updates by system's packet manager.

Step 1: Create a new directory and download latest release of Go

[email protected]:~$ sudo mkdir local
[email protected]:~$ cd local/
[email protected]:~/local$ pwd
[email protected]:~/local$ sudo wget

Step 2: Expand the package into same ~/local directory

[email protected]:~/local$ sudo tar xf go1.4.2.linux-amd64.tar.gz
[email protected]:~/local$ ls
go go1.4.2.linux-amd64.tar.gz

Step 3: Type “go” in the terminal and you will see its command line manual as

Go Manual

Set Up the Environment for Go

Here we need to build an environment for git user to setup its paths that are corresponding to our system.

Git Home

Gogs Installation Starts

Now we at the point to start the installation of Gogs using the Go source code command line tool.

Step 1:Run the Get command of Go to download Gogs

[email protected]:~/local$ go get -u

Step 2: Change directory and build main program

[email protected]:~/local$ cd $GOPATH/src/
[email protected]:~/go/src/$ go build

Step 3: Gogs Installation Test

Run following command to make sure that gogs is working fine and if you don't see any error message just Press Ctrl-c to stop Gogs, you can also access it on your localhost web browser with your IP and port 3000 but its better not to start the installation at this point to avoid from errors.

[email protected]:~$ cd $GOPATH/src/
[email protected]:~/go/src/$ ./gogs web

Gogs Web Service

Nginx Installation

We need to install Nginx to use it as a reverse proxy so that we can bind our domain name to Gogs.
So lets start with its installation and then we will configure it for Gogs.

Step 1: Install Nginx with apt-get command as

[email protected]:~$ sudo apt-get install nginx

[email protected]:~$ sudo systemctl status nginx

[email protected]:~$ sudo nginx -V
nginx version: nginx/1.6.2 (Ubuntu)

Step 2: Configure Nginx

[email protected]:~$ sudo vi /etc/nginx/sites-available/default
# Default server configuration
server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;


location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:3000;
try_files $uri $uri/ =404;

Step 3: Now Restart Niginx Service and check its status

[email protected]:~$ systemctl restart nginx

Nginx Status

Gogs as a Service StartUp

To setup Gogs starts automatically as a running service at the back end we are going to do so by installing a package Supervisor.

Step 1: Installing Supervisor with apt-get

[email protected]:~$ sudo apt-get install supervisor

[email protected]:~$ systemctl status supervisor

Step 2: Reconfigure Supervisor
After installing supervisor, now configure it as per according to our environment and needs. Lets start with creating a new directory for logs and then append the supervisod.conf file as:

[email protected]:~$ sudo mkdir -p /var/log/gogs
[email protected]:~$ sudo vi /etc/supervisor/supervisord.conf

[program:gogs] directory=/home/git/go/src/
command=/home/git/go/src/ web
environment = HOME="/home/git", USER="git"

Step 3: Restart Supervisor Service and check its status

Supervisor Status

Finalize Gogs Installation Setup

Gogs has been been all setup with its initial setting and configurations with other required packages. Now we only need to perform few installation step at its first time run.

Lets Open your web browser and access gogs with your localhost IP as:


Install Gogs

Choose the appropriate configurations in its database type, user name and Password. Then after creating an admin account just click to Install Gogs, thats it.

Create Account

Welcome To Gogs

Gogs Login

Let's Create Your Repositories

New Repository

You have created your first repository on Gogs

Gogs Repository

Gogs Dashboard

Gogs Dashboard

Clone Local Repository with SSH

We can also clone any repositories by using its dashboard. We only need to get the desired repository's link and then SSH the other system then by using git clone command we can easily get it on other system.

Clone Repository

We can also comment out using git commit and git push commands to pass on our comments on the master repositories.

Commit or Push


Gogs is a great git hosting service and much more powerful than Github. Its lightweight, easy to set up, cross-platform git hosting service and with features favorably comparable to Gitlab/Github. So I definitely recommend Gogs as your git self-hosting service.

Kashif Siddique 3:00 am


Your email address will not be published. Required fields are marked *

All comments are subject to moderation.