How to install Gitea git repository on Ubuntu Server 22.04

Jack Wallen shows you how to install the easy-to-use local Gitea repository on Ubuntu Server 22.04.

git commit command programming technology code repository online cloud
Image: Ribkhan/Adobe Stock

Gitea is one of the best self-hosted Git servers on the market. This Go-based package is very easy to use, lightweight, and fairly easy to install. Once you get it up and running, your development teams can enjoy a Git repository from your LAN, which means sensitive code is less likely to find its way into the hands of a third party. Gitea features notifications, a built-in editor, user management, and more.

SEE: Hiring Kit: Back-End Developer (TechRepublic Premium)

I want to walk you through the process of deploying the latest version of Gitea (1.17.1) on the latest version of Ubuntu Server (22.04). The process should only take you 5-10 minutes to complete.

What you will need to install Gitea

All you will need for this is a running instance of Ubuntu Server (Jammy Jellyfish) and a user with sudo privileges. That is all.

How to install the necessary dependencies

The first thing we will do is install the necessary dependencies. Login to your Ubuntu Server instance and issue the command:

sudo apt-get install wget get mariadb-server -y

When the installation is complete, secure the database server with the command:

sudo mysql_secure_installation

Be sure to create a new admin user password and answer y for the final questions.

How to create a database and a user

The next step is to create your database. Login to the database console with:

sudo mysql -u root -p

Create the database with:


Next, create a database user with:


Where PASSWORD is a strong and unique password.

Flush the privileges and exit the database console with:


How to install Gitea

Let’s download the latest version of Gitea and copy it to /usr/local/bin with:

sudo wget -O /usr/local/bin/gitea

Change the permissions of the downloaded file with:

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

Next, we need to create a new user with the command:

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

Create the required directories with:

sudo mkdir -pv /var/lib/gitea/{custom,data,log}

Change ownership of new directories:

sudo chown -Rv git:git /var/lib/gitea

Change the permissions of the main gitea directory with the command:

sudo chmod -Rv 750 /var/lib/gitea

Create a new config directory for Gitea with:

sudo mkdir -v /etc/gitea

Change the ownership of the new directory:

sudo chown -Rv root:git /etc/gitea

Change the permissions of the new directory with:

sudo chmod -Rv 770 /etc/gitea

How to create a systemd service file

Next, you need to create a systemd service file for Gitea. Create the file with the command:

sudo nano /etc/systemd/system/gitea.service

In that file, paste the following content:



ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea


Save and close the file.

Start and enable the gitea service:

sudo systemctl enable --now gitea

How to access the Gitea web installer

Finally, you can finish the installation with the web-based installer. Open a browser and point it to http://SERVER:3000, where SERVER is the IP address of the hosting server.

You will see the Gitea configuration page, where you need to configure the database settings (Figure A) and other options you may want to change. Make sure to change both the server domain and Gitea base URL from localhost to the IP address or domain of the hosting server.

Figure A

Gitea’s configuration page.

When you’re done, click Install Gitea at the bottom of the page and allow the installation to complete. You will then find yourself on the Gitea login page, where you can register an account and start using your LAN-based Gitea server.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube to get the latest tech tips for business professionals from Jack Wallen.

Leave a Comment