How to install Gitea git repository on Ubuntu Server 22.04


Jack Wallen shows you how to install the user-friendly Gitea local Git repository on Ubuntu Server 22.04.

Image: ribkhan/Adobe Stock

Gitea is one of the best self-hosted Git servers on the market. This Go-based package is very user-friendly, lightweight, and fairly simple to install. Once it’s up and running, your development teams can take advantage of a Git repository from your local network, which means sensitive code will be less likely to end up in the hands of a third party. Gitea offers notifications, an integrated editor, user management and much more.

SEE: Recruitment 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 about 5-10 minutes.

What you will need to install Gitea

The only things you will need for this are a running instance of Ubuntu Server (Jammy Jellyfish) and a user with sudo privileges. That’s it.

How to install the necessary dependencies

The first thing we are going to do is install the necessary dependencies. Log in to your Ubuntu Server instance and run the command:

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

Once 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 it for the final questions.

How to create a database and a user

The next step is to create your database. Connect 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.

Dump 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

Modify 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 the owner of new directories:

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

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

sudo chmod -Rv 750 /var/lib/gitea

Create a new configuration directory for Gitea with:

sudo mkdir -v /etc/gitea

Change the owner of the new directory:

sudo chown -Rv root:git /etc/gitea

Modify 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 this 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 activate the gitea service:

sudo systemctl enable --now gitea

How to Access Gitea Web Installer

Finally, you can complete the installation with the web 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 might want to change. Be sure to change both the server domain and the Gitea base URL from localhost to the hosting server’s IP address or domain.

Figure A

The Gitea configuration page.

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

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


Comments are closed.