How to Install Gogs Git on Debian 13

This tutorial will walk you through the steps necessary to install the Gogs self-hosted Git service on a Debian 13 server. The Gogs project, written in Go, aims to create a simple, stable, and extensible self-hosted Git service with a simple setup process.

Gogs performs admirably and is extremely light. It uses very little RAM and CPU power.

Checkout the Gogs Project at https://gogs.io/ for more information.

Prerequisites

  • Full SSH root access or a user with sudo privileges is required.
  • Gogs supports the following databases:
    • SQLite3
    • PostgreSQL
    • MySQL
    • MariaDB

Update the System

Let's update software packages first:

apt update
apt upgrade -y

Install MariaDB Database Server

Install MariaDB:

apt install mariadb-server mariadb-client -y

Check the status:

systemctl status mariadb

Secure the installation:

mariadb-secure-installation

Login to MariaDB:

mariadb -u root -p

Set global variable:

SET GLOBAL innodb_file_per_table = ON;

Create a new database:

CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Create a new user:

GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY "StrongPassword";
FLUSH PRIVILEGES;
EXIT;

Replace StrongPassword with a secure password.

Download and Install Gogs (Latest Version)

Install curl:

apt install curl -y

Download the latest Gogs release:

curl -s https://api.github.com/repos/gogs/gogs/releases/latest | grep browser_download_url | grep 'linux_amd64.tar.gz' | cut -d '"' -f 4 | wget -i -

Extract the archive:

tar xvf gogs_*_linux_amd64.tar.gz

Create Git User and Directories

apt install git -y

Check the location of the Git executable:

which git

This should return a path like /usr/bin/git.

Edit the .bash_profile for the git user:

nano /home/git/.bash_profile

Add the following line to ensure the git user has the correct PATH:

export PATH=$PATH:/usr/bin

Create the git user:

adduser git

Create a logs directory:

mkdir /var/log/gogs
chown -R git:git /var/log/gogs/

Configure Gogs systemd Service

Copy the systemd file:

cp gogs/scripts/systemd/gogs.service /etc/systemd/system/

Edit it:

nano /etc/systemd/system/gogs.service

Change the default port if needed:

ExecStart=/home/git/gogs/gogs web -port 3001

Move the Gogs directory:

mv gogs /home/git/
chown -R git:git /home/git/

Start and Enable Gogs

Start and enable the service:

systemctl daemon-reload
systemctl start gogs
systemctl enable gogs
systemctl status gogs

Output:

root@server:~# systemctl daemon-reload
systemctl start gogs
systemctl enable gogs
systemctl status gogs
Created symlink '/etc/systemd/system/multi-user.target.wants/gogs.service' → '/etc/systemd/system/gogs.service'.
● gogs.service - Gogs
     Loaded: loaded (/etc/systemd/system/gogs.service; enabled; preset: enabled)
     Active: active (running) since Mon 2025-08-04 13:00:15 EDT; 786ms ago
 Invocation: 908140da5ef8416e9c51226d3f8de03f
   Main PID: 13625 (gogs)
      Tasks: 6 (limit: 7052)
     Memory: 38M (peak: 38.2M)
        CPU: 444ms
     CGroup: /system.slice/gogs.service
             └─13625 /home/git/gogs/gogs web -port 3001

Configure Gogs via Web Installer

Navigate to the following in your browser:

http://<server-ip>:3001

Database Settings

Use:

  • Type: MySQL
  • Host: 127.0.0.1:3306
  • User: gogs
  • Password: (your password)
  • DB Name: gogs

Application General Settings

  • Application Name: anything
  • Run User: git
  • Domain: your-server-ip or domain
  • App URL: http://:3001/
  • Log Path: /var/log/gogs

Optional Settings

  • Enable additional features if needed
  • Create the first admin user

Click Install Gogs to finalize setup.

✅ Done

You can now log in using the admin user and begin using your self-hosted Gogs Git service on Debian 13.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS