How to Install Forgejo on Rocky Linux 9
Forgejo is a lightweight, self-hosted Git service, ideal for teams or individuals who want to host their own Git repositories with a modern web interface.
Prerequisites
- A Rocky Linux 9 VPS
- A user with
sudoprivileges - Basic knowledge of Linux commands
Update Your System
sudo dnf clean all
sudo dnf update -y
Install Dependencies
sudo dnf install git wget tar sqlite -y
Create a Dedicated User
sudo groupadd --system forgejo
sudo useradd --system \
--shell /bin/bash \
--comment "Forgejo Git Service" \
--home /var/lib/forgejo \
--gid forgejo \
forgejo
Download Forgejo
cd /tmp
wget https://codeberg.org/forgejo/forgejo/releases/download/v9.0.1/forgejo-9.0.1-linux-amd64
sudo mkdir -p /usr/local/bin
sudo mv forgejo-9.0.1-linux-amd64 /usr/local/bin/forgejo
sudo chmod +x /usr/local/bin/forgejo
Create Data Directories
sudo mkdir -p /var/lib/forgejo/{custom,data,log}
sudo chown -R forgejo:forgejo /var/lib/forgejo
Create Systemd Service
sudo vi /etc/systemd/system/forgejo.service
Paste the following content:
[Unit]
Description=Forgejo (Self-Hosted Git Service)
After=network.target
[Service]
RestartSec=2s
Type=simple
User=forgejo
Group=forgejo
WorkingDirectory=/var/lib/forgejo
ExecStart=/usr/local/bin/forgejo web
Restart=always
Environment=USER=forgejo HOME=/var/lib/forgejo GITEA_WORK_DIR=/var/lib/forgejo
[Install]
WantedBy=multi-user.target
Save and exit.
Start and Enable Forgejo
sudo setenforce 0
sudo systemctl restart forgejo
sudo systemctl status forgejo
Allow Firewall Port (Optional)
If firewalld is enabled:
sudo firewall-cmd --permanent --add-port=3000/tcp
sudo firewall-cmd --reload
If firewalld is not available, use iptables:
sudo iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
sudo service iptables save
sudo systemctl restart iptables
Access Forgejo
Visit http://your-server-ip:3000 in your browser and complete setup.
Use SQLite3 for quick setup, or MariaDB/PostgreSQL if preferred.
Initial Configuration
After starting Forgejo for the first time, open http://your-server-ip:3000 in your browser.
You will see the Initial Configuration screen. Use the following recommended values for a typical Rocky Linux 9 setup:
| Setting | Recommended Value (Rocky Linux 9 Setup) |
|---|---|
| Database type | SQLite3 (simple setup) OR MariaDB/PostgreSQL if you want production-ready. |
| Database settings | If using SQLite3, no host/user/password is needed. For MariaDB/PostgreSQL, fill in Host, Username, Password, Database name. |
| Instance title | Forgejo (or your team/project name). |
| Instance slogan | Optional (default: Beyond coding. We Forge.). |
| Repository root path | /var/lib/forgejo/data/forgejo-repositories (keep default). |
| Git LFS root path | /var/lib/forgejo/data/lfs (keep default unless you want to disable LFS). |
| User to run as | forgejo (must match the user created earlier). |
| Server domain | Your server IP or domain name (e.g. git.example.com). |
| SSH server port | 22 (keep default unless you use a custom SSH port). |
| HTTP listen port | 3000 (keep as is unless using a reverse proxy later). |
| Base URL | http://your-server-ip:3000/ or https://git.example.com/ if using HTTPS. |
| Log path | /var/lib/forgejo/log (default). |
| Allow user registration | Keep unchecked if this is a private instance. |
| Version check | Leave enabled unless you want to disable version checks. |


Administrator Account Setup
Scroll down to Administrator Account Settings and create your first user:
- Username: your admin username (e.g.,
admin) - Password: a strong password
- Email: your admin email address
This account will have full control of the Forgejo instance.



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