How to Install Gogs Git on RockyLinux 9
This tutorial will walk you through the steps necessary to install the Gogs self-hosted Git service on an RockyLinux 8 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
Now, start the MariaDB service
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
Check the status of MariaDB service.
[root@vps ~]# systemctl start mariadb
[root@vps ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor >
Active: active (running) since Sat 2023-03-11 19:45:39 UTC; 17min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 31681 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited,>
Process: 31703 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.ser>
Process: 31807 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exite>
Main PID: 31790 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 8 (limit: 17516)
Memory: 75.3M
CPU: 842ms
CGroup: /system.slice/mariadb.service
└─31790 /usr/libexec/mariadbd --basedir=/usr
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: you need to be th>
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: After connecting >
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: able to connect a>
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: See the MariaDB K>
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: Please report any>
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: The latest inform>
Mar 11 19:45:39 vps.server.com mariadb-prepare-db-dir[31743]: Consider joining
Secure the Mysql 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 Mysql as root
user,
mysql -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 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";
Replace "StrongPassword" with an actual password that is long and strong.
FLUSH PRIVILEGES;
EXIT
Download and Install Gogs
from GitHub
Use curl
to download the Gogs
file from their official github repository.
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 Gogs
file.
unzip gogs_*_linux_amd64.zip
Install the packages of git
using dnf
command
dnf install git
Create a new user called 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 Gogs binary file to /home/git
,
mv gogs /home/git/
Change the permission of the site directory.
chown -R git:git /home/git/
Next, Enable the firewalld for Port 3001
firewall-cmd --zone=public --add-port=3001/tcp --permanent
firewall-cmd --reload
Switch to git
user that was created earlier,
su -i git
Then change the directory to where gogs is located,
cd /home/git/gogs/
Then, run the gogs
with the web
option:
./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 Rockylinux 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