Installing Gitea on Ubuntu 26.04

Gitea is an open-source forge software package for hosting software development version control using Git, along with features like issue tracking, pull requests, wikis, and code review.

Prerequisites

  • Full SSH root access or a user with sudo privileges.
  • Gitea supports:
    • SQLite
    • PostgreSQL
    • MySQL
    • MariaDB

In this guide, we will use SQLite as the database.

Install SQLite

Install SQLite:

apt update

apt install sqlite3 -y

Check SQLite version:

sqlite3 --version

Output:

3.46.1 2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69aalt1 (64-bit)

Install Git

Update the system:

apt update && apt upgrade -y

Install Git:

apt install git -y

Check Git version:

git --version

Output:

git version 2.53.0

Create Git User

Create a dedicated Git user:

adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git

Download the Gitea Binary

Download latest Gitea binary:

wget -O /tmp/gitea https://dl.gitea.com/gitea/1.24.1/gitea-1.24.1-linux-amd64

Move binary:

mv /tmp/gitea /usr/local/bin

Make executable:

chmod +x /usr/local/bin/gitea

Verify installation:

gitea --version

Output:

Gitea version 1.24.1 built with GNU Make 4.3, go1.24.4 : bindata, sqlite, sqlite_unlock_notify

Set Up Directories and Permissions

Create required directories:

mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}

Set ownership:

chown git: /var/lib/gitea/{data,indexers,log}

Set permissions:

chmod 750 /var/lib/gitea/{data,indexers,log}

Create configuration directory:

mkdir /etc/gitea

Set permissions:

chown root:git /etc/gitea

chmod 770 /etc/gitea

Create Systemd Service

Download Gitea systemd service:

wget https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/systemd/gitea.service -P /etc/systemd/system/

Reload systemd:

systemctl daemon-reload

Start Gitea:

systemctl start gitea

Enable at boot:

systemctl enable gitea

Check status:

systemctl status gitea

Output:

● gitea.service - Gitea
     Loaded: loaded (/etc/systemd/system/gitea.service; enabled)
     Active: active (running)

Configure Firewall

Allow Gitea port:

ufw allow 3000/tcp

Reload firewall:

ufw reload

Access Gitea Web Interface

Open your browser and visit:

http://your-server-ip:3000

Replace your-server-ip with your actual server IP or domain name.

Database Settings

Configure database:

  • Database Type: SQLite3
  • Path: /var/lib/gitea/data/gitea.db

image

Application Settings

Configure application settings:

  • Site Title: Your custom title
  • Repository Root Path: /home/git/gitea-repositories
  • Git LFS Root Path: /var/lib/gitea/data/lfs
  • Run As Username: git
  • Server Domain: Your domain or server IP
  • SSH Port: 22
  • Gitea HTTP Listen Port: 3000
  • Gitea Base URL: http://yourdomain.com:3000
  • Log Path: /var/lib/gitea/log

image

Replace example domains and IP addresses with your actual values.

Create Administrator Account

Create your administrator account during setup:

image

Click on Install Gitea to complete installation.

Gitea Dashboard

After installation completes, you will be redirected to the dashboard:

image

image

You can now create repositories, manage users, and start hosting your Git projects.

Upgrade Gitea

Stop Gitea service:

systemctl stop gitea

Download newer version:

VERSION=<LATEST_VERSION>

wget -O /tmp/gitea https://dl.gitea.com/gitea/${VERSION}/gitea-${VERSION}-linux-amd64

Replace binary:

mv /tmp/gitea /usr/local/bin/gitea

Make executable:

chmod +x /usr/local/bin/gitea

Restart Gitea:

systemctl restart gitea

Check status:

systemctl status gitea

🎉 Gitea has now been successfully installed and configured on Ubuntu 26.04.


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