How to Install Gitea on Ubuntu 22.04

how to install gitea on ubuntu 22.04

Gitea is a community-managed lightweight code hosting solution written in Go. It is published under the MIT license. Gitea can run cross-platform using Go and can compile for Windows, macOS, and Linux ARM.

The goal of Gitea is to provide a painless way of setting up a self-hosted Git service.

In this tutorial, we will show you how to install Gitea on Ubuntu 22.04. Let’s get started!

Step 1. Update the System

Update the system packages to the latest versions available. Execute the following command:

# apt-get update
# apt-get upgrade

Step 2. Install and configure database server – MariaDB

You can install the MariaDB database server using the following command:

# apt install mariadb-server

Once the MariaDB server installation has been completed, you can log in to the console using the command:

# mysql -u root -p

Then you continue setting up the database for Gitea; you can create a database with the CREATE DATABASE command and create a
new user with all privileges on the gitea database by following the commands.

MariaDB [(none)]>CREATE DATABASE gitea;

MariaDB [(none)]>GRANT ALL PRIVILEGES ON gitea.* to 'gitea'@'localhost' IDENTIFIED BY 'Strong-Password';


MariaDB [(none)]>exit;

With this, you have completed the database installation and configuration, and you can now continue to install Gitea.

Step 3. Install Gitea

Before we start installing Gitea, you will need to create a new system user, ‘git’:

adduser --system --shell /bin/bash --group --disabled-password --home /home/git git

Next, you can download Gitea in your current directory and copy it to /usr/bin/gitea


cp gitea-1.19-linux-amd64 /usr/bin/gitea

Now you change the permissions of the new download file:

# chmod 755 /usr/bin/gitea

Next, you can go ahead and create the new directories in /var/lib/gitea and /etc/gitea and assign the correct permissions and directory ownership to the user ‘git’.

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

#chown git:git /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}

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

#chmod 770 /etc/gitea

Since you have created the new directories and assigned the correct permissions and directory ownership, you can now create the Gitea service.

Open a new file called gitea.service in /etc/systemd/system with your favorite text editor; in this tutorial, we will use nano.

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

You should add the following lines in your gitea.service file:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99


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


You can save the gitea.service file in nano using Ctrl+O and click enter to save the file, next click Ctrl+X to exit the nano text editor. Now you can reload systemd daemon and start the Gitea service with:

# systemctl daemon-reload
systemctl start gitea

To make sure the Gitea service is automatically started on system reboot, use the command:

# systemctl enable gitea

Step 3. Accessing Gitea Web Interface

You can now open your web browser and type the URL http://IP-address-of-your-server:3000. You should see Gitea’s Initial configuration screen

To use Gitea with a domain assigned, you should create a reverse proxy for Gitea. Your web engine (nginx, apache or others) can then serve Gitea without adding a port number and using a domain that would be much easier to remember instead of an IP address.

You should use the Database credentials you previously set up for the Gitea Initial configuration and also configure General Settings. Then you need to click ‘Install Gitea‘. You should be then redirected to Gita’s homepage and log in to Gitea

If you find this setup difficult or do not know how to install Gitea on Ubuntu 22.04, you can always contact our technical support. We are available 24/7 via live chat or support tickets. All you have to do is to sign up for one of our Linux VPS hosting plans and submit a support ticket. Our admins will reply to you in no time!

If you liked this post about installing Gitea on Ubuntu 22.04, please share it with your friends on social networks or simply leave a reply below.

Leave a Comment

To prove you are human please solve the following *