In this tutorial, we'll learn how to install and configure Forgejo on AlmaLinux 10 server.
What is Forgejo?
Forgejo is a lightweight, open-source, self-hosted Git service designed to help teams manage their code, repositories, issues, and collaboration in one place. It offers a fast and user-friendly interface, making it easy for developers and businesses to maintain full control of their projects without relying on external platforms. Forgejo is community-driven, privacy-focused, and ideal for personal use, small teams, or organisations that value data ownership and flexible customization.
Prerequisites
Before we begin, ensure we have the following:
- An AlmaLinux 10 dedicate server or KVM VPS.
- Basic Linux Command Line Knowledge.
- A domain name, pointing A record to server IP.
Install and Configure Forgejo on AlmaLinux 10
Step 1: Update Server Packages
We start by ensuring the server has the latest security patches and dependencies.
sudo dnf update -y
sudo dnf install -y git wget vim
Step 2: Create a Dedicated System User for Forgejo
A separate user improves security and prevents direct root execution.
sudo useradd \
--system \
--shell /bin/bash \
--comment 'Forgejo User' \
--create-home \
--home-dir /var/lib/forgejo forgejo
Create required directories with proper ownership:
sudo mkdir -p /var/lib/forgejo/{custom,data,log}
sudo chown -R forgejo:forgejo /var/lib/forgejo
sudo chmod -R 750 /var/lib/forgejo
sudo mkdir -p /etc/forgejo
sudo chown -R forgejo:forgejo /etc/forgejo
sudo chmod -R 750 /etc/forgejo
Step 3: Install Forgejo Binary
We download the latest stable binary from the official source.
sudo wget -O /usr/local/bin/forgejo https://codeberg.org/forgejo/forgejo/releases/download/v13.0.2/forgejo-13.0.2-linux-amd64
sudo chmod +x /usr/local/bin/forgejo
(Use the latest version link available when installing.)
Step 4: Create Forgejo Service File
Setting Forgejo as a systemd service allows automatic start at boot.
sudo tee /etc/systemd/system/forgejo.service <<EOF
[Unit]
Description=Forgejo Git Service
After=network.target
[Service]
Type=simple
User=forgejo
Group=forgejo
WorkingDirectory=/var/lib/forgejo
ExecStart=/usr/local/bin/forgejo web --config /etc/forgejo/app.ini
Restart=always
Environment=USER=forgejo HOME=/var/lib/forgejo FORGEJO_WORK_DIR=/var/lib/forgejo
[Install]
WantedBy=multi-user.target
EOF
Reload and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable --now forgejo
Check status:
sudo systemctl status forgejo
Step 5: Configure Firewall Rules
Allow access to default Forgejo port 3000.
sudo firewall-cmd --permanent --add-port={80,443,3000}/tcp
sudo firewall-cmd --reload
Configure SELinux
sudo setsebool -P httpd_can_network_connect 1
sudo chcon -t bin_t /usr/local/bin/forgejo
Step 6: Access and Complete Web Setup
Open a browser and visit:
http://<server-ip>:3000
Configure:
- Database Type: SQLite3 (works well for small to medium installations)
- Application URL:
https://forgejo.example.com - Repository Root Path:
/var/lib/forgejo/data/forgejo-repositories
Complete admin setup and create the first admin account.
(For larger teams, MariaDB or PostgreSQL is recommended.)
Step 7: Set Up Reverse Proxy (Recommended for Production)
Using Nginx allows HTTPS support and better performance.
Install Nginx:
sudo dnf install -y nginx
sudo systemctl enable --now nginx
Create a new config:
sudo vim /etc/nginx/conf.d/forgejo.conf
Add:
server {
listen 80;
server_name forgejo.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Restart:
sudo systemctl restart nginx
Step 8: Enable HTTPS with Let’s Encrypt SSL
sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d forgejo.example.com
Step 9: Basic Security Hardening
- Disable registration if running a private instance
- Enable 2FA
- Make regular backups of /var/lib/forgejo
- Use fail2ban to prevent brute-force attacks
Step 10: Backup and Update forgejo
Backup:
sudo tar -czvf forgejo-backup-$(date +%F).tar.gz /var/lib/forgejo/
Update:
sudo systemctl stop forgejo
sudo wget -O /usr/local/bin/forgejo https://dl.forgejo.com/forgejo/latest/forgejo-1.23.4-linux-amd64
sudo chmod +x /usr/local/bin/forgejo
sudo systemctl start forgejo
Conclusion
A self-hosted Git platform gives full ownership of code and data without relying on external services. This guide provided a complete setup for Forgejo on AlmaLinux 10 including installation, service configuration, optional PostgreSQL integration, reverse proxy setup, SSL, and essential security practices.
With this environment running, teams can confidently manage repositories, collaborate efficiently, and maintain complete data privacy.

