Learn how to install and configure a Gogs Git server on AlmaLinux 10. This guide shows how to install and configure everything securely and efficiently, helping us take full control of our code without relying on GitHub or GitLab.
What is Gogs?
Gogs, short for Go Git Service, is an open-source, self-hosted Git server written entirely in Go. It’s designed to be extremely lightweight, fast, and simple to deploy on virtually any platform — whether that’s Linux, macOS, Windows, or even ARM-based devices like Raspberry Pi.
What makes Gogs stand out is its minimal resource usage and ease of installation. We don’t need to configure a heavy stack or worry about large system dependencies. It runs as a single binary with a built-in web UI, making it perfect for small teams, individual developers, or businesses that want full control over their code repositories without relying on platforms like GitHub or GitLab.
Gogs supports SSH/HTTPS, user authentication, repository management, pull requests, webhooks, issue tracking, and more—all packaged in a clean, fast, and user-friendly interface.
Prerequisites
Before we begin, let’s ensure our environment meets the following requirements:
- A AlmaLinux 10 installed dedicated server or KVM VPS.
- A non-root user with sudo privileges.
- Basic knowledge of using the terminal.
- A domain name pointing to server IP.
How to Set Up Gogs on AlmaLinux 10: A Lightweight, Self-Hosted Git Server for Developers
Step 1: Update the System
We begin by making sure our AlmaLinux 10 system is up to date:
sudo dnf update -y
sudo dnf install epel-release -y
Step 2: Install Required Packages
We’ll need some essential tools, including Git, wget, MySQL, and Nginx:
sudo dnf install -y git wget nano nginx tar
Step 3: Install and Configure MySQL Server
Let’s install MariaDB, a drop-in MySQL replacement:
sudo dnf install -y mariadb-server mariadb
sudo systemctl enable --now mariadb
Now we’ll secure the database:
sudo mysql_secure_installation
Follow prompts to:
- Set root password
- Remove anonymous users
- Disallow remote root login
- Remove test DB
- Reload privileges
Then log in and create a database and user for Gogs:
sudo mysql -u root -p
Inside the MySQL shell:
CREATE DATABASE gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'gogsuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON gogs.* TO 'gogsuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Create a Gogs User and Download Gogs
We’ll now create a system user to manage the Gogs process:
sudo adduser --system --shell /sbin/nologin --create-home --home /home/gogs gogs
Download and extract Gogs. For latest version visit the official download page.
cd /home/gogs
sudo wget https://dl.gogs.io/0.13.3/gogs_0.13.3_linux_amd64.tar.gz
sudo tar -xvzf gogs_0.13.3_linux_amd64.tar.gz
sudo chown -R gogs:gogs gogs
Step 5: Create a Systemd Service for Gogs
This ensures Gogs starts automatically and can be managed easily:
sudo nano /etc/systemd/system/gogs.service
Paste the following:
[Unit]
Description=Gogs Git Server
After=network.target
[Service]
Type=simple
User=gogs
Group=gogs
WorkingDirectory=/home/gogs/gogs
ExecStart=/home/gogs/gogs/gogs web
Restart=always
Environment=USER=gogs HOME=/home/gogs
[Install]
WantedBy=multi-user.target
Save and exit. Then enable and start the service:
sudo systemctl daemon-reexec
sudo systemctl enable --now gogs
Step 6: Open Required Ports in Firewall
We’ll open ports for HTTP (80) and Gogs (3000) temporarily during setup:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 7: Configure Nginx as Reverse Proxy
Let’s now set up Nginx to serve Gogs on port 80:
sudo nano /etc/nginx/conf.d/gogs.conf
Paste the following config:
server {
listen 80;
server_name git.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable and restart Nginx:
sudo systemctl enable --now nginx
sudo systemctl restart nginx
Step 8: Secure with SSL (Optional but Recommended)
To add HTTPS support via Let's Encrypt:
sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d git.example.com
Follow prompts to set up auto-renewing SSL.
Step 9: Configure SELinux (if enforcing)
We need to allow Nginx to make network connections to the Gogs backend:
sudo setsebool -P httpd_can_network_connect 1
Ensure the Gogs directory has the correct SELinux file context:
sudo semanage fcontext -a -t httpd_sys_content_t "/home/gogs/gogs(/.*)?"
sudo semanage fcontext -a -t bin_t "/home/gogs/gogs(/.*)?"
sudo restorecon -R /home/gogs/gogs
Troubleshooting
If you still getting error in the brower, disable SELinux and check.
setenforce 0
Step 10: Complete Gogs Web Setup (With MySQL)
Visit Gogs at:
https://git.example.com
In the setup form:
- Database Type: MySQL
- Host: 127.0.0.1:3306
- User: gogsuser
- Password: StrongPassword123!
- Database Name: gogs
- Application URL: http://git.example.com/ (or use IP temporarily)
- Admin Account: Set your admin username and password
Click Install Gogs.
Step 11: Using Gogs
Create a repository through the Gogs dashboard.
Clone it:
git clone http://git.example.com/yourname/project.git
Push code, manage branches, and collaborate from your self-hosted Git server.
Final Notes
Setting up Gogs with MySQL and Nginx on AlmaLinux 10 gives us:
- A blazing-fast Git server
- Low system footprint
- Full admin control
- Easy web interface
- Clean code collaboration
Gogs is great for developers who want Git hosting without complexity. We can always migrate to larger platforms later, but for many use cases—Gogs is more than enough.
Checkout our low cost dedicated servers.