How to install Gitea on Ubuntu 20.04?

Overview

Gitea is a self-hosted Git service, similar to Github or Gitlab, that allows users to host their own repositories and collaborate with others. It was forked from Gogs in 2016 and is written in Go language. Gitea provides users with an easy-to-use and customizable interface, as well as features such as code highlighting, issue tracking, multiple authentication methods, and integration with third-party tools like Jenkins, Slack, and Discord. Gitea is widely used by developers, small teams, and organizations to manage their codebase and collaborate on projects.

In this tutorial, we will guide you on how to install Gitea on Ubuntu 20.04.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • Ubuntu 20.04 server with SSH access

  • Stable internet connection

Get Started

Step 1: Update and upgrade the system's packages and software.

sudo apt update && sudo apt upgrade

Step 2: Check the git version.

git --version

Step 3: Create a git user to execute the Gitea application.

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

Step 4: Download the latest stable version of Gitea from the official website using the following command:

VERSION=1.14.1
sudo wget -O /tmp/gitea https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-linux-amd64

Step 5: Move the downloaded Gitea binary to the /usr/local/bin directory using the following command:

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

Step 6: To create the directories and set up the appropriate permissions and ownership, use the following commands:

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

Step 7: Make a Systemd Unit File using the following command:

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

Step 8: Activate and launch the Gitea service:

sudo systemctl daemon-reload
sudo systemctl enable --now gitea

Step 9: Run the following command to see if Gitea is running.

sudo systemctl status gitea

Conclusion

In this tutorial, we have shown you how to install Gitea on Ubuntu 20.04. We have covered the pre-requisites, including updating the system and installing Git. Then, we proceeded to install Gitea by downloading the latest version, creating a system user, and setting up the data directory. With these steps, you can now have your own self-hosted Git service using Gitea on your Ubuntu 20.04 server.

Last updated