How To Install Gitea on Ubuntu 20.04 LTS

Install Gitea on Ubuntu 20.04

In this tutorial, we will show you how to install Gitea on Ubuntu 20.04 LTS. For those of you who didn’t know, Gitea is a free, open-source, and self-hosted version control system alternative to GitHub and GitLab. Gitea comes with a rich set of features including time tracking, repository branching, issues tracking, file locking, merging, and much more. Gitea can be installed on all popular operating systems like Windows, macOS, Linux, and ARM.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Gitea on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.


  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Gitea on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Installing Git and Create Git User.

Run the command to install the Git package on Ubuntu:

sudo apt install git

Confirm Git the installation:

[ ~]# git --version
git version 2.25.1

After installing Git, now we create a Git user to run Gitea services:

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

Step 3. Installing MariaDB on Ubuntu.

You can install MySQL on your Ubuntu 20.04 LTS system with the following command:

sudo apt install mariadb-server mariadb-client

After the server is installed, the commands below can be used to stop, start, and restart the database services:

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl restart mariadb.service

Let’s confirm our installation of the MariaDB server on Ubuntu 20.04:

mysql -V

Now we secure MariaDB after installation.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:


Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

To log into MariaDB, use the following command (note that it’s the same command you would use to log into a MySQL database) and create a database for Gitea:

$ mysql -u root -p

CREATE USER 'giteauser'@'localhost' IDENTIFIED BY 'your_strong_passwd';
GRANT ALL ON giteadb.* TO 'giteauser'@'localhost' IDENTIFIED BY 'your_strong_passwd' WITH GRANT OPTION;

Step 4. Installing Gitea on Ubuntu 20.04.

Now download the latest version of the Gitea binary from the Git repository. You can download it with the following command:

sudo wget -O /tmp/gitea

Copy the binary to a global location:

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

Make the binary executable:

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

Next, create the directories and set the required permissions and ownership:

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

Step 4. Create Systemd Service for Gitea.

Now, you have to create a systemd service file gitea.service for Gitea in the /etc/systemd/system/ directory:

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

Paste the content below into the file and save:

Description=Gitea (Git with a cup of tea)

# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below


Then, enable and start the Gitea service:

sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea

Step 5. Accessing Gitea Web Interface.

Now, open a web browser and visit http://YOUR_DOMAIN_OR_IP_ADDRESS:3000. You should see the following page:

Install Gitea on Ubuntu 20.04

Congratulations! You have successfully installed Gitea. Thanks for using this tutorial for installing Gitea on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you to check the official Gitea website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button