How to Install Gitea Locally on Ubuntu 24.0.1 LTS

Gitea is designed to be resource-efficient and fast, making it suitable for both small and large projects.

Since i want to have Local Version control so i find Gitea is good tool for me to install Locally and maintain own version for my automation application i am working on to build.

This Blog show how to setup Gitea on Ubunut from Scratch to end, its each and less resource consumption on your Local VM.

For now i am using Esxi (but i am going to Migrate to Proxmox free VM deployment – that i will cover another blog)

I have installed Ubuntu 24 LTS with 8 CPU and 32GB RAM and 1TB HDD (which is used for all my DevOp).

Gitea Installation :

Prerequisites

  • A user with Sudo privileges is required or Full SSH root access.
  • Gitea supports the following databases.
    • SQLite
    • PostgreSQL
    • MySQL
    • MariaDB

In my installation guide below, i will be using PostgresSQL as the database for Gitea. You can pick any of the supported databases in your installation as needed. Since i use PGSQL for other purpose for Large application deployment.

PostgreSQL

  1. For remote database setup, configure PostgreSQL on database instance to listen to your IP address by editing listen_addresses on postgresql.conf
    • listen_addresses = 'localhost, 203.0.113.3'
  2. PostgreSQL uses md5 challenge-response encryption scheme for password authentication by default. Nowadays this scheme is not considered secure anymore. Use SCRAM-SHA-256 scheme instead by editing the postgresql.conf configuration file on the database server
    • password_encryption = scram-sha-256
      Restart PostgreSQL to apply the setting.
  3. On the database server, login to the database console as superuser:
    • su -c "psql" - postgres
  4. Create database user (role in PostgreSQL terms) with login privilege and password. Please use a secure, strong password instead of 'gitea' below:
    • CREATE ROLE gitea WITH LOGIN PASSWORD 'xxxxx';
      Replace username and password as appropriate.
  5. Allow the database user to access the database created above by adding the following authentication rule to pg_hba.conf.For local database:
  • local giteadb gitea scram-sha-256
    For remote database:
  • host giteadb gitea 192.168.1.74/32 scram-sha-256
  • Replace database name, user, and IP address of Gitea instance with your own.

Testing PGSQL working as expected :

psql

giteadb=>

display tables

giteadb-> \dt

Note : you can find good cheat sheet how to use PGSQL on many searches.

Install Git

Prepare environment

Check that Git is installed on the server. If it is not, install it first. Gitea requires Git version >= 2.0.

git –version

git version 2.43.0

# On Ubuntu/Debian:
adduser \
   --system \
   --shell /bin/bash \
   --gecos 'Gitea Version Control' \
   --group \
   --disabled-password \
   --home /home/git \
   git

Create the directory structure and set the required permissions and ownership.

mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
chown git: /var/lib/gitea/{data,indexers,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea

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

mv gitea /usr/local/bin
chmod +x /usr/local/bin/gitea

Create a Systemd Unit File, which we can use to run the gitea in background and control with systemctl.

Download the file to the “/etc/systemd/system/” directory using the following command.

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


ls /etc/systemd/system/ -al
systemctl daemon-reload
systemctl enable gitea
systemctl start gitea.service

systemctl status gitea

netstat -lntpd

Now Gitea running, we use Web GUI to configure

Navigate to your browser. http://192.168.1.74:3000 to access the Gitea dashboard.

Now that we’ve started Gitea we can access it on port 3000 of our server. Upon opening Gitea in your browser for the first time, you should be greated with an initial configuration page. This configuration page should be fairly straight forward.

If you have been following this guide so far, the database settings section should be configured like this (with the password filled in):

The “General Application Settings” should be configured , Follow the on-screen instructions to complete the Gitea setup. Click on Register to start the database initialization.

Once all good you get Home Page screen

Good Luck – i will cover another blog when my application ready and using version control to show how we can manage on demand CI/CD part of the process.

HappyLabbinggggggggggggggggg!!!!