Gitea is a lightweight, self-hosted Git service written in Go that provides a GitHub-like web interface with a tiny resource footprint — ideal for teams that want a simple hosted Git server without the overhead of a full GitLab installation. On RHEL 8, Gitea can be set up in under an hour using a single binary, a systemd service unit, and an SQLite database for small teams. This tutorial walks through creating a dedicated system user, downloading and configuring the Gitea binary, setting up the service, opening the firewall, and completing the web-based installer.
Prerequisites
- A RHEL 8 server with at least 1 GB RAM
- Root or sudo access
gitinstalled on the server (sudo dnf install -y git)- Port 3000 (Gitea web UI) and port 22 (SSH) accessible from client machines
Step 1 — Create a Dedicated Git System User
Gitea should run as a non-privileged system user. Create a git user with a dedicated home directory that will store repository data and configuration.
sudo adduser
--system
--shell /bin/bash
--comment 'Gitea'
--create-home
--home-dir /home/git
git
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
sudo mkdir -p /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
The /var/lib/gitea directory tree stores repositories, attachments, and LFS objects. The /etc/gitea directory holds the app.ini configuration file, which is written by the web installer on first run.
Step 2 — Download the Gitea Binary
Gitea distributes signed binary releases at dl.gitea.io. Download the Linux amd64 binary for the current stable release and make it executable.
GITEA_VERSION=1.22.1
sudo curl -fsSL "https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64"
-o /usr/local/bin/gitea
sudo chmod 755 /usr/local/bin/gitea
# Verify the binary
gitea --version
Optionally, verify the download against the published checksum to confirm integrity before running the binary on your server.
curl -fsSL "https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64.sha256"
-o /tmp/gitea.sha256
echo "$(cat /tmp/gitea.sha256) /usr/local/bin/gitea" | sha256sum --check
Step 3 — Create the systemd Service Unit
Create a systemd unit file so Gitea starts automatically on boot and is managed like any other system service.
sudo tee /etc/systemd/system/gitea.service <<'EOF'
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
After=syslog.target
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now gitea
sudo systemctl status gitea
The service will start and listen on port 3000. The app.ini will be created by the web installer in the next step, so it is normal for Gitea to run in installer mode at first launch.
Step 4 — Open Firewall Ports
Open port 3000 for the Gitea web interface and confirm port 22 is open for Git-over-SSH operations.
sudo firewall-cmd --permanent --add-port=3000/tcp
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
If you want Gitea to handle SSH itself on a non-standard port (for example port 2222 so that port 22 remains for server administration), set SSH_PORT = 2222 in app.ini and open that port instead: sudo firewall-cmd --permanent --add-port=2222/tcp.
Step 5 — Complete the Web Installer and Create the First Admin
Navigate to http://<server-ip>:3000 in a browser to run the interactive setup wizard. Fill in the database and site settings, then scroll to the Administrator Account Settings section to create the first admin user.
# Recommended settings in the web installer:
#
# Database Type: SQLite3 (path: /var/lib/gitea/data/gitea.db)
# — use PostgreSQL or MySQL for larger teams
#
# Site Title: Your Organisation Git
# Repository Root Path: /var/lib/gitea/data/repositories
# Git LFS Root Path: /var/lib/gitea/data/lfs
# Run As Username: git
# SSH Server Domain:
# SSH Port: 22
# HTTP Port: 3000
# Gitea Base URL: http://:3000/
# Log Path: /var/lib/gitea/log
#
# Scroll to "Administrator Account Settings":
# Admin Username: gitadmin
# Password:
# Email: [email protected]
#
# Click "Install Gitea"
After clicking Install Gitea, the installer writes /etc/gitea/app.ini and redirects you to the dashboard. Lock down the config file permissions immediately.
sudo chmod 640 /etc/gitea/app.ini
sudo chown root:git /etc/gitea/app.ini
Conclusion
You have installed Gitea on RHEL 8 using a dedicated system user and a systemd service unit, configured the firewall, completed the web-based installer, and created the first administrator account. Gitea is now a fully functional self-hosted Git server ready to host repositories, manage SSH keys, and serve as a remote for developer workstations. For team setups, explore Gitea’s built-in Organizations, Teams, and webhook integrations to trigger external CI systems on push events. Upgrade by replacing the binary and running sudo systemctl restart gitea.
Next steps: How to Configure GitLab CI/CD Pipelines on RHEL 8, How to Install Jenkins on RHEL 8, and How to Configure Jenkins Pipelines and Jenkinsfile on RHEL 8.