How to Install Gogs Git on Rocky Linux 10

This tutorial walks you through the steps to install the Gogs self-hosted Git service on a Rocky Linux 10 server.
Gogs (Go Git Service) is a painless, lightweight, and self-hosted Git service written in Go. It is optimized for performance and minimal resource usage.

For more information, visit the official site: https://gogs.io

Prerequisites

  • Root or sudo user access
  • Gogs supports the following databases:
    • SQLite3
    • PostgreSQL
    • MySQL / MariaDB

System Update

Update all software packages:

dnf update -y

Install MariaDB

Install MariaDB Server:

dnf install mariadb-server -y

Start and enable MariaDB:

systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb

Secure the MariaDB installation:

mysql_secure_installation

Configure MariaDB for Gogs

Log in to MariaDB as root:

mysql -u root -p

Inside the MariaDB shell, run:

SET GLOBAL innodb_file_per_table = ON;

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

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

FLUSH PRIVILEGES;
EXIT;

Replace StrongPassword with a secure password.

Step 4: Download and Install Gogs

Install required packages:

dnf install git unzip curl -y

Download the latest Gogs release:

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

Unzip the downloaded archive:

unzip gogs_*_linux_amd64.zip

Set Up Gogs User and Directory

Create the git user:

adduser git

Create the logs directory:

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

Move the gogs folder to the home directory of git:

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

Open Firewall Port

Allow Gogs through the firewall (port 3001):

firewall-cmd --zone=public --add-port=3001/tcp --permanent
firewall-cmd --reload

Start Gogs

Switch to the git user:

su - git

Navigate to the Gogs directory:

cd /home/git/gogs

Run Gogs on port 3001:

./gogs web -port 3001

Configure Gogs

In your browser, go to:

http://your_server_ip:3001

Replace your_server_ip with your actual server IP address.

Fill the Installation Form

Database Settings:
Enter the MariaDB database details created earlier.

image

Application General Settings:

  • Application Name: Any name you like
  • Run User: git
  • Domain: Your domain or server IP
  • Application URL: http://your_server_ip:3001
  • Log Path: /var/log/gogs

image

Optional Settings:

  • Enable features as needed
  • Create the initial Admin account

image

Click Install Gogs to complete the setup.

Final Step: Log In

Log in with the Admin account you just created.

image

image

image

🎉 Conclusion

You’ve successfully installed Gogs Git on Rocky Linux 10. You can now manage your repositories with a lightweight and self-hosted Git service.


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