How to Install Gogs Git on Debian 12

This tutorial will walk you through the steps necessary to install the Gogs self-hosted Git service on an Debian 12 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 for more information.


  • 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. To perform updates, run the following command:

apt update
apt upgrade

Install MariaDB Database Server

Install the MariaDB using below command,

apt install mariadb-server mariadb-client -y

After installation completed, Check the status of MariaDB service.

systemctl status mariadb


root@vps:~# systemctl status mariadb
● mariadb.service - MariaDB 10.11.3 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
     Active: active (running) since Thu 2023-06-15 18:37:33 UTC; 17s ago
       Docs: man:mariadbd(8)
   Main PID: 3493 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 18 (limit: 4652)
     Memory: 171.7M
        CPU: 1.390s
     CGroup: /system.slice/mariadb.service
             └─3493 /usr/sbin/mariadbd

Secure the MariaDB Installation with the below command,



Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Login to MariaDB as root user,

mariadb -u root -p

Enable global variables as shown below,

SET GLOBAL innodb_file_per_table = ON;

Create a database called gogs which will be used for this project,


Create a user and grant all the privileges of the gogs database,

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

Replace "StrongPassword" with an actual password that is long and strong.


Download and Install Gogs from GitHub

Use curl to download the Gogs file from their official github repository.

apt install curl -y

curl -s | grep browser_download_url | grep '\linux_amd64.tar.gz' | cut -d '"' -f 4 | wget -i -

Un-tar the downloaded Gogs file.

tar xvf gogs_*_linux_amd64.tar.gz

Create a new user called git and set password,

adduser git


root@vps:~# adduser git
Adding user `git' ...
Adding new group `git' (1000) ...
Adding new user `git' (1000) with group `git (1000)' ...
Creating home directory `/home/git' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 

Create a dedicated logs directory for it's user,

mkdir /var/log/gogs

Permit created directory access to the added user,

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

Add the gogs systemd service file to the system directory at /etc/systemd/system/,

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

Create a configuration file for Gogs,

nano /etc/systemd/system/gogs.service

If you want to make use of a different port to host Gogs, refer below. You can use any other port you want to, this is to keep the site a bit safer.

Edit the ExecStart=/home/git/gogs web port, you can set a custom port such as 3001

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

Move the Gogs binary file to /home/git,

mv gogs /home/git/

Change the permission of the site directory.

chown -R git:git /home/git/

Start the Gogs service using below command,

systemctl daemon-reload
systemctl start gogs

Enable Gogs service to run on boot and check the Status,

systemctl enable gogs
systemctl status gogs


root@vps:~# systemctl status gogs
● gogs.service - Gogs
     Loaded: loaded (/etc/systemd/system/gogs.service; enabled; preset: enabled)
     Active: active (running) since Thu 2023-06-15 18:54:49 UTC; 6s ago
   Main PID: 2123 (gogs)
      Tasks: 8 (limit: 4652)
     Memory: 38.2M
        CPU: 517ms
     CGroup: /system.slice/gogs.service
             └─2123 /home/git/gogs/gogs web -port 3001

Configure Gogs

Navigate to your browser and load the server's IP address or the domain name with 3001 port.

http://server-ip-address:3001 and you will see the Gogs installation screen.

In Database Settings we'll first enter the Database information that was created earlier.


Next, In Application General Settings

  • Application Name - enter the Project name of your choice.
  • Run User - will be the new user that was added earlier, git.
  • Domain - enter the Domain name that should be associated with the application. If you do not have any domain, use localhost.
  • Application URL - enter the IP address of the server or the Domain name with the port to be used.

    Do not use localhost in Application URL.

  • Log Path - enter the directory path that was created earlier, /var/log/gogs.


In Optional Settings,

  • Enable or Disable the required settings that goes with your application usage.
  • Create an Admin Account which you will be using as first user with Admin privileges.


Now click on Install Gogs button to start the installation. Once the installation is complete, you will be redirected to login screen.

Login with the Admin user that was just created in the last step.


This concludes the Installation and Gogs on Debian 12