Gogs also known as Go Git Server is an open source cross-platform self-hosted Git server written in Golang, similar to the GitLab which is written in Ruby.

It is easy to install and configure and offers a lot of customization options while installing, it lets you choose between MySQL, SQLite, and PostgreSQL as a Database backend. It is also one of the lightest and fastest self-hosted Git server solutions, it does not offer a lot of features like GitLab, but whatever it offers, it does it without pain. If you don’t already have a CentOS server, you can get a VPS on Digital Ocean, by signing up with this referral you get $10 credit and I get $25 credit. Installing Gogs is easy it’s available as a pre-compiled package from Packager. It receives updates like every other package you would install on your system. So you can do the setup once and receive an update on new builds. This setup being pre-build, might not support SQLite, for this guide, I am using MariaDB. You can use PostgreSQL over MariaDB if you prefer it.

Getting started.

Adding Gogs repository key.

sudo rpm --import https://rpm.packager.io/key  Code language: JavaScript (javascript)

Add Gogs packager.io repository to your local packages database.

echo "[gogs]  
name=Repository for pkgr/gogs application.  
baseurl=https://rpm.packager.io/gh/pkgr/gogs/centos7/pkgr  
enabled=1" | sudo tee /etc/yum.repos.d/gogs.repo  
Code language: TOML, also INI (ini)

Installing Gogs

sudo yum install gogs

Installing MySQL

sudo yum install mysql-server -y  

Setting up MySQL

sudo mysql_secure_installation  

Logging into MySQL console.

mysql -u root -p  
CREATE DATABASE gogs;  

Exiting MySQL console.

exit  Code language: PHP (php)

Installing NGINX to reverse proxy Gogs to port 80.

sudo rpm -Uhv http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm  
Code language: JavaScript (javascript)
sudo yum install -y nginx  

Editing the NGINX config /etc/nginx/conf.d/default.conf

sudo nano /etc/nginx/conf.d/default.conf  Code language: JavaScript (javascript)

Add the following lines to your NGINX config.

server {  
listen          80;  
  server_name     ${HOSTNAME};
  location / {
    proxy_pass      http://localhost:3000;
  }
}

Code language: Nginx (nginx)

Restart NGINX.

sudo service nginx restart  

You can access the newly setup Gogs Server at http://127.0.0.1/, and further configure it to your preference and create your new user, you can now store your projects on your private Git server. Have a question, leave a comment below.

I compiled a list of software and services that I use to improve my workflow, here is the link to the list.

Darryl Dias

I’m Darryl. I’m a 3D Artist, Programmer and Linux enthusiast. On this site I share my insights, tips and tricks, tutorials, methods and best practices.