Operations 7 min read

Installing and Configuring Gogs: A Self‑Hosted Git Service Guide

This guide explains why Gogs is a lightweight alternative to GitLab, outlines its key features, details the required environment, and provides step‑by‑step Linux commands for installing, configuring, and running the self‑hosted Git server, including troubleshooting tips and post‑installation notes.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Installing and Configuring Gogs: A Self‑Hosted Git Service Guide

Gogs is presented as a lightweight, Go‑based self‑hosted Git service that consumes far fewer resources than GitLab, making it suitable for personal use where only basic Git operations such as push, pull, commit history, and diff viewing are needed.

The platform supports a rich set of features including activity timelines, SSH/HTTP(S) protocols, LDAP/SMTP authentication, repository management, webhooks, issue tracking, pull requests, Wiki, two‑factor authentication, multiple databases (MySQL, PostgreSQL, SQLite3, MSSQL, TiDB), and multilingual UI.

Installation prerequisites include choosing one of the supported databases (MySQL ≥ 5.5.3 with InnoDB, PostgreSQL, MSSQL, TiDB, or SQLite3), Git ≥ 1.7.1 on both client and server, and optionally an SSH server for non‑HTTP access.

The following Linux commands are used to set up the environment and install Gogs:

# Add Git user
groupadd git
useradd git -g git -s /bin/false

# Update Git (CentOS 6 example)
yum install epel-release -y
rpm -Uvh https://centos6.iuscommunity.org/ius-release.rpm
yum remove git -y
yum install git2u -y

# Download init script
wget https://raw.githubusercontent.com/gogits/gogs/master/scripts/init/centos/gogs -O /etc/init.d/gogs
chmod +x /etc/init.d/gogs

# Download Gogs binary
cd /home/git/
wget https://dl.gogs.io/0.11.34/linux_amd64.tar.gz
tar xzf linux_amd64.tar.gz
rm -rf linux_amd64.tar.gz

# Create log directory required by init script
mkdir -p /home/git/gogs/log
touch /home/git/gogs/log/gogs.log
chown -R git:git /home/git/gogs

# Start service and enable at boot
service gogs start
chkconfig --add gogs

It is recommended to install Gogs via the binary package rather than a system package to avoid automatic overwriting of configuration files during upgrades.

After installation, access the web UI at http:// IP :3000/ to complete the setup. If a MySQL error "Specified key was too long; max key length is 767 bytes" appears, upgrade to MySQL 5.7 or switch to another database.

For personal use, SQLite is a viable alternative; backing up simply involves copying the database file. Additional configuration options are documented at the Gogs advanced configuration cheat sheet.

Several screenshots in the original article illustrate the installation process and the final UI.

devopsgitLinuxinstallationGogsself-hosted
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.