How to Install Gogs Git on AlmaLinux 9

This tutorial will walk you through the steps necessary to install the Gogs self-hosted Git service on an AlmaLinux 9 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

First, check for any pending system upgrade

Let's update software packages first. To perform updates, run the following command:

dnf update

Install MariaDB Database Server

Use the below command to install MariaDB.

dnf install mariadb-server mariadb-client

To check the status of MariaDB.

root@crown~# systemctl status mariadb
● mariadb.service - MariaDB 10.6.9 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enab>
     Active: active (running) since Sat 2022-11-19 17:44:57 UTC; 8s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 1808 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var>
    Process: 1811 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_ST>
    Process: 1818 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && >
    Process: 1876 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_S>
    Process: 1878 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/>
   Main PID: 1862 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 15 (limit: 2227)
     Memory: 61.6M
        CPU: 418ms
     CGroup: /system.slice/mariadb.service
             └─1862 /usr/sbin/mariadbd

Secure the MariaDB Installation with the below command,

mysql_secure_installation

Output:

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

Set 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 DATABASE IF NOT EXISTS gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

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

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

Download and Install Gogs from GitHub

Use curl to download the Gogs file into the /usr/local/bin directory.

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 -

Unzip the downloaded Gogs file.

dnf install tar

tar xvf gogs_*_linux_amd64.tar.gz

Create a new git.

adduser git

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/

Move the Gitea binary file to /home/git.

mv gogs /home/git/

Change the permission of the site directory.

chown -R git:git /home/git/

To check the status /enable of the Gogs service.

systemctl enable gogs

Go to the download folder

cd /home/git/gogs/

Next,Disable the firewalld

systemctl stop firewalld

Then,run the ./gogs web

./gogs web

./gogs web -port 3001

Navigate to your browser. http://yourserver-ip-address:3001 and you will see the Gogs installation screen.

image

image

image

image

image

image

This concludes the Installation and Gogs on AlmaLinux 9.


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