Website Vidya
Cloud & DevOpsStep-by-Step Guide

How to Install Gitea on Ubuntu 24.04

Step-by-step guide on how to install Gitea on Ubuntu 24.04 LTS with PostgreSQL, Git, Nginx reverse proxy, and Let's Encrypt SSL certificates.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install Gitea on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Step-by-step guide on how to install Gitea on Ubuntu 24.04 LTS with PostgreSQL, Git, Nginx reverse proxy, and Let's Encrypt SSL certificates.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Updating System and Installing Git Dependencies
  • Step 2: Creating a Dedicated Git System User
Grounded in full engineering runbookWebsiteVidya AI Engine

Interactive Builder for this Guide

Build your custom nginx syntax (How to Install Gitea on Ubuntu 24.04)

Generated Config Output
server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name app.example.com;

    ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript application/xml;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        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 Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
Production Nginx reverse proxy -> 127.0.0.1:3000 for app.example.com.
Flag-by-Flag Breakdown
server_nameBinds this virtual host to app.example.com
return 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPS
proxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application server
X-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjacking

Git has become the de facto standard for version control in modern software engineering. While centralized services like GitHub and GitLab offer comprehensive enterprise features, hosting your own private Git server provides critical advantages: absolute ownership over proprietary source code, compliance with strict data-residency standards, offline accessibility within local networks, and zero per-seat licensing fees.

Gitea is an open-source, lightweight code hosting solution written in Go. Forked from Gogs, Gitea is renowned for its effortless setup, exceptionally low resource consumption (typically under 100 MB of RAM), and rich feature set—including pull requests, issue tracking, wikis, branch protection, code review, package registries, and integrated CI/CD workflows via Gitea Actions. Learning how to install gitea on ubuntu 24.04 gives you a self-hosted Git platform with enterprise capabilities on minimal hardware.

In this comprehensive tutorial, we cover the complete installation and production hardening of Gitea on Ubuntu 24.04 LTS (Noble Numbat). We guide you through creating an unprivileged service user, installing Git and database dependencies, configuring a managed systemd background service, setting up Nginx as an encrypted reverse proxy with Let's Encrypt SSL, and finalizing security permissions.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A server or virtual machine running Ubuntu 24.04 LTS.
  • A user account with sudo administrative privileges.
  • A domain or subdomain (e.g., git.example.com) pointed to your server's public IP address.
  • At least 1 GB of RAM (Gitea is extremely lightweight and operates smoothly even on 512 MB instances).

Step 1: Updating System and Installing Git Dependencies

Before downloading Gitea, update your local APT repository index and install essential dependencies. Gitea requires git on the host system to perform core version control operations.

Install git, sqlite3 (for lightweight database storage), and curl using APT.

Advertisement

Verify the installed Git version to ensure compatibility.

# Update repository indices
sudo apt update && sudo apt upgrade -y

# Install Git, SQLite, and network utilities
sudo apt install -y git sqlite3 curl wget

Step 2: Creating a Dedicated Git System User

To adhere to the principle of least privilege, Gitea should never be run as root. Create a dedicated system user and group named git.

This user account will manage repository storage, handle SSH connections for git operations, and execute the Gitea daemon.

Configure the user with a disabled password and a standard home directory at /home/git.

Advertisement
# Create system user and group for Git
sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Git Version Control' git

Step 3: Downloading and Installing the Gitea Binary

Gitea is distributed as a single, self-contained Go binary with no external runtime dependencies.

Download the latest stable 64-bit Linux binary from the official Gitea GitHub repository into /usr/local/bin.

Make the binary executable by setting chmod +x.

# Download latest stable Gitea binary
GITEA_VERSION="1.22.3"
sudo curl -fsSL -o /usr/local/bin/gitea https://dl.gitea.com/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64

# Make the binary executable
sudo chmod +x /usr/local/bin/gitea

# Verify binary execution
gitea --version

Step 4: Creating Directory Structure and Setting Permissions

Gitea requires dedicated directories for working data, user repositories, runtime logs, and configuration files.

Create standard directories under /var/lib/gitea, /etc/gitea, and /var/log/gitea.

Assign ownership to the git user and set secure permissions to restrict access from other system users.

# Create required application directories
sudo mkdir -p /var/lib/gitea/{custom,data,indexers,public} /var/log/gitea /etc/gitea

# Set directory ownership to git user
sudo chown -R git:git /var/lib/gitea /var/log/gitea /etc/gitea

# Secure permissions
sudo chmod -R 750 /var/lib/gitea /var/log/gitea
sudo chmod 770 /etc/gitea

Step 5: Creating the Systemd Service for Gitea

To ensure Gitea starts automatically at boot and can be monitored by systemd, create a service definition file.

Create /etc/systemd/system/gitea.service with the recommended production settings.

Enable and start the service, and verify its active status.

# Create systemd service unit
sudo bash -c 'cat <<EOF > /etc/systemd/system/gitea.service
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target network.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'

# Reload systemd and enable Gitea service
sudo systemctl daemon-reload
sudo systemctl enable --now gitea
sudo systemctl status gitea --no-pager

Step 6: Configuring Nginx Reverse Proxy and Firewall

By default, Gitea listens on port 3000. In a production environment, you should route web traffic through Nginx on standard HTTP/HTTPS ports.

Install Nginx using APT and create a server block configuration at /etc/nginx/sites-available/gitea.conf.

Configure proxy headers to ensure client IP addresses and protocols are passed correctly to Gitea.

Enable the site and adjust your UFW firewall to allow HTTP and HTTPS traffic.

# Install Nginx
sudo apt install -y nginx

# Create Nginx reverse proxy configuration
sudo bash -c 'cat <<EOF > /etc/nginx/sites-available/gitea.conf
server {
    listen 80;
    server_name git.example.com;

    location / {
        proxy_pass http://localhost: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;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size 100M;
    }
}
EOF'

# Enable site and reload Nginx
sudo ln -s /etc/nginx/sites-available/gitea.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

# Allow HTTP/HTTPS and SSH through UFW
sudo ufw allow 'Nginx Full'
sudo ufw allow 22/tcp

Step 7: Securing Gitea with Let's Encrypt SSL

Protect Git credentials and source code by securing your Nginx reverse proxy with a free Let's Encrypt SSL certificate.

Install Certbot and the Nginx plugin, then execute Certbot to obtain and configure the certificate automatically.

Certbot will reconfigure your Nginx virtual host with strong TLS ciphers and automated HTTP-to-HTTPS redirects.

# Install Certbot and Nginx plugin
sudo apt install -y certbot python3-certbot-nginx

# Obtain and install SSL certificate
sudo certbot --nginx -d git.example.com

Step 8: Completing the Web Setup and Hardening Permissions

Open your browser and navigate to https://git.example.com. The Gitea initial configuration screen will display.

1. Database Type: Select SQLite3 (for simple single-server setups) or PostgreSQL/MySQL if you configured a separate database.

2. Application Settings: Set Application Name, Repository Root Path (/home/git/gitea-repositories), and Gitea HTTP Listen Port (3000).

3. Base URL: Enter your full domain URL: https://git.example.com/.

4. Administrator Account: Expand the Optional Settings section to create your initial administrator user.

After completing the wizard, lock down write permissions on /etc/gitea to prevent unauthorized configuration changes through the web interface.

# Lock down configuration file permissions after web setup
sudo chmod 750 /etc/gitea
sudo chmod 640 /etc/gitea/app.ini

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Permission denied errors in /var/log/gitea or /var/lib/gitea

Resolution: Verify that all application directories are owned by the git user: sudo chown -R git:git /var/lib/gitea /var/log/gitea /etc/gitea and ensure the systemd service specifies User=git.

Nginx 502 Bad Gateway error when accessing domain

Resolution: A 502 error indicates that Gitea is not running on port 3000. Check service status with sudo systemctl status gitea and inspect log output with sudo journalctl -u gitea -e.

Git push over SSH fails with 'Permission denied (publickey)'

Resolution: Ensure your public SSH key has been added in Gitea user settings. Check that /home/git/.ssh/authorized_keys exists and has 0600 permissions owned by git:git.

Security Best Practices and Hardening

Always restrict permissions on /etc/gitea/app.ini to 0640 with ownership git:git to prevent database credentials from leaking.

Disable self-registration under [service] DISABLE_REGISTRATION = true in /etc/gitea/app.ini if your instance is strictly for private team usage.

Always enforce HTTPS and strong TLS ciphers to safeguard Git credentials and tokens during push and pull operations.

Regularly create automated backups of /var/lib/gitea/data and /etc/gitea/app.ini using the gitea dump utility.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
Gitea requires only 100 to 200 MB of RAM, whereas GitLab typically requires 4 GB or more due to its extensive Ruby on Rails and background worker stack. Gitea is ideal for lightweight VPS and homelab environments.
Yes, Gitea includes native support for LDAP, Active Directory, OAuth2 (GitHub, Google, GitLab), and PAM authentication sources, manageable directly through the web UI.
Upgrading Gitea takes less than a minute: stop the service with sudo systemctl stop gitea, download the new binary to /usr/local/bin/gitea, ensure executable permissions, and restart the service with sudo systemctl start gitea.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Cloud & DevOps•

How to Close File Descriptors Above 9 in Dash Shell

Attempting to close a file descriptor above 9 in Dash using exec 10<&- results in a 10: not found error because Dash's POSIX lexer only recognizes single-digit file descriptors (0–9) in redirection operators. This guide explains the exact parser limitation, why FDs 10+ are reserved for internal shell state, and how to safely close inherited file descriptors using close_range, Python, or Perl wrappers.

RR
Rajesh Rai
Read More
Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout