Install and Configure Forgejo on Ubunut 24.04

By Anurag Singh

Updated on Nov 07, 2025

Install and Configure Forgejo on Ubunut 24.04

In this tutorial, we'll learn how to install and configure Forgejo on Ubunut 24.04 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 Ubuntu 24.04 dedicate server or KVM VPS.
  • Basic Linux Command Line Knowledge.
  • A domain name, pointing A record to server IP.

Install and Configure Forgejo on Ubunut 24.04

Step 1: Update the Server

We first make sure our server is up to date.

sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl wget ufw ca-certificates

Step 2: Create a System User for Forgejo

We run Forgejo under a separate user for security and clean management.

sudo adduser \
  --system --shell /bin/bash \
  --gecos 'Forgejo' \
  --group --disabled-password \
  --home /var/lib/forgejo forgejo

sudo mkdir -p /var/lib/forgejo/{data,custom}
sudo mkdir -p /var/log/forgejo /etc/forgejo
sudo chown -R forgejo:forgejo /var/lib/forgejo /var/log/forgejo /etc/forgejo

Step 3: Download Forgejo

We download the latest stable Forgejo binary.

Replace the version number with the latest release if needed.

cd /tmp
wget -O forgejo https://codeberg.org/forgejo/forgejo/releases/download/v13.0.2/forgejo-13.0.2-linux-amd64
chmod +x forgejo
sudo mv forgejo /usr/local/bin/forgejo

Step 4: Create Forgejo Configuration

sudo tee /etc/forgejo/app.ini >/dev/null <<EOF
[server]
DOMAIN = git.example.com
HTTP_ADDR = 127.0.0.1
HTTP_PORT = 3000
ROOT_URL = https://git.example.com/
APP_DATA_PATH = /var/lib/forgejo/data

[database]
DB_TYPE = sqlite3
PATH = /var/lib/forgejo/data/forgejo.db

[repository]
ROOT = /var/lib/forgejo/data/repositories

[log]
MODE = file
LEVEL = info
ROOT_PATH = /var/log/forgejo
EOF

Change permission:

sudo chown forgejo:forgejo /etc/forgejo/app.ini

Step 5: Create Systemd Service

This allows Forgejo to run as a service and start at boot.

sudo tee /etc/systemd/system/forgejo.service >/dev/null <<EOF
[Unit]
Description=Forgejo Git Service
After=network.target

[Service]
User=forgejo
Group=forgejo
WorkingDirectory=/var/lib/forgejo
ExecStart=/usr/local/bin/forgejo web --config /etc/forgejo/app.ini
Restart=always

[Install]
WantedBy=multi-user.target
EOF

Reload and start service:

sudo systemctl daemon-reload
sudo systemctl enable --now forgejo

Check status:

sudo systemctl status forgejo

Step 6: Configure Firewall

We need to add HTTP and HTTPS ports in the firewall.

sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable

Step 7: Install and Configure Nginx

Forgejo runs on port 3000, so we use Nginx as a reverse proxy.

sudo apt install -y nginx

Create site config:

sudo tee /etc/nginx/sites-available/forgejo >/dev/null <<EOF
server {
    listen 80;
    server_name git.example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
    }
}
EOF

Enable the conf file:

sudo ln -s /etc/nginx/sites-available/forgejo /etc/nginx/sites-enabled/

Test and restart Nginx service:

sudo nginx -t
sudo systemctl restart nginx

Step 8: Enable HTTPS (Recommended)

We're install Certbot to obtain free Let's encrypt SSL certitificate.

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d git.example.com

Step 9: Complete Web Setup

Open your browser and visit:

https://git.example.com

Follow on-screen instructions to create admin account and finalize setup.

Troubleshooting

If you get 500 error in browser or any error, check status of forgejo.service

systemctl status forgejo.service

Look why it is failing.

You can also login using 

su - forgejo

Execute following command:

/usr/local/bin/forgejo web --config /etc/forgejo/app.ini

You will get exact error.

Conclusion

We now have a fully functional Forgejo server running on Ubuntu 24.04, ready to host repositories, manage code, and support team collaboration securely. This setup gives us a dependable self-hosted Git environment with a clean configuration, proper service management, and strong foundations for future growth.

With Forgejo installed, we can start creating repositories, adding team members, enabling SSH access, and integrating CI/CD tools to enhance our development workflow. This setup provides a stable and efficient platform for managing projects while keeping full control of our data.