How to Install Gitea on Ubuntu 20.04


Welcome to our comprehensive guide on how to install Gitea on your Ubuntu 20.04 system. Gitea is a lightweight, open-source, self-hosted Git service that allows you to manage your code repositories with ease. Whether you’re a developer, a small team, or an organization, Gitea provides a convenient platform for version control and collaboration. In this guide, we’ll walk you through the installation process step by step, making it easy for you to set up your own Git repository hosting solution on Ubuntu 20.04.

Chapter 1: Understanding Gitea

Gitea is a Git service that provides a web-based interface for managing Git repositories. It offers features such as code hosting, collaboration, issue tracking, pull requests, and more. Gitea is designed to be lightweight, easy to install, and suitable for small to medium-sized teams or individual developers who want to self-host their Git repositories.

  • SEO Tip: Include keywords like “Gitea,” “Git service,” and “code repository hosting” to optimize for search engines.

Chapter 2: Prerequisites

Before we begin the installation, ensure that you have the following prerequisites in place:

  • A Ubuntu 20.04 server or virtual machine with a non-root user account with sudo privileges.
  • A domain name or IP address pointing to your server.
  • Basic knowledge of working with the Linux command line.

Chapter 3: Update System Packages

Before installing Gitea, it’s essential to ensure that your system is up to date. Use the following commands to update the package list and upgrade installed packages:

sudo apt update
sudo apt upgrade

Chapter 4: Install Required Dependencies

Gitea relies on a few external dependencies that need to be installed on your Ubuntu system. Use the following command to install these dependencies:

sudo apt install -y git mysql-server nginx
  • SEO Tip: Include keywords like “install dependencies,” “Gitea prerequisites,” and “external dependencies” to improve SEO rankings.

Chapter 5: Create a System User for Gitea

For security and isolation, it’s a good practice to create a dedicated system user and group for running Gitea. Let’s create a user named “gitea” and a group named “git” for this purpose:

sudo adduser --system --group --disabled-password --home /var/lib/gitea --gecos 'Gitea User' gitea

Chapter 6: Download and Configure Gitea

Now, let’s download the Gitea binary and configure it. You can obtain the latest Gitea release from the official website ( Be sure to replace “VERSION” with the actual version number you want to install.

wget -O gitea
sudo mv gitea /usr/local/bin/
sudo chmod +x /usr/local/bin/gitea

Next, let’s create a Gitea configuration file by running:

sudo mkdir -p /etc/gitea
sudo chown gitea:git /etc/gitea
sudo chmod 750 /etc/gitea

Now, you can generate a sample configuration file using the following command:

sudo -u gitea gitea web -c /etc/gitea/app.ini

This command creates a sample configuration file named “app.ini” in the “/etc/gitea” directory.

  • SEO Tip: Include keywords like “download Gitea,” “Gitea configuration,” and “Gitea binary” to enhance SEO visibility.

Chapter 7: Create a Systemd Service for Gitea

To run Gitea as a service, create a systemd service unit file. Create a file named “gitea.service” in the “/etc/systemd/system” directory and open it with a text editor:

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

Now, paste the following systemd service unit configuration into the file:

Description=Gitea (Git with a cup of tea)

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


Save and exit the text editor (in nano, press Ctrl + O, then Enter, and Ctrl + X to exit).

  • SEO Tip: Incorporate keywords like “systemd service for Gitea,” “Gitea service unit,” and “Gitea systemd configuration” for SEO optimization.

Chapter 8: Enable and Start the Gitea Service

After creating the systemd service unit, you can enable and start the Gitea service with the following commands:

sudo systemctl enable gitea
sudo systemctl start gitea

This will enable Gitea to start automatically at boot and start it immediately.

  • SEO Tip: Use keywords like “enable Gitea service,” “start Gitea service,” and “systemctl commands” for SEO visibility.

Chapter 9: Configure Firewall Rules (if applicable)

If you have a firewall enabled on your Ubuntu server, you’ll need to configure it to allow access to the Gitea web interface. By default, Gitea runs on port 3000. Use the following commands to allow incoming traffic on port 3000:

sudo ufw allow 3000/tcp
sudo ufw reload

Make sure to adjust your firewall rules according to your specific requirements.

  • SEO Tip: Mention keywords like “firewall configuration,” “Gitea port 3000,” and “ufw rules” for SEO optimization.

Chapter 10: Accessing the Gitea Web Interface

Now that Gitea is up and running, you can access its web interface by opening a web browser and navigating to your server’s IP address or domain name followed by “:3000.” For example, if your server’s IP address is “,” you would enter “” in your browser’s address bar.

You should see the Gitea web interface, where you can set up your administrator account

, configure repositories, and start using Gitea for version control and collaboration.

  • SEO Tip: Include keywords like “access Gitea web interface,” “Gitea setup,” and “Gitea administrator account” for SEO visibility.

Chapter 11: Conclusion

In conclusion, you’ve successfully installed Gitea on your Ubuntu 20.04 server, creating your own Git repository hosting solution. Gitea provides a user-friendly and efficient platform for managing code repositories and collaborating with others.

As you explore Gitea further, consider customizing its configuration, creating user accounts, and setting up your first repositories. Gitea offers a wide range of features to streamline your development workflow, making it a valuable tool for developers and teams.

Continuously enhancing your knowledge of Gitea and Git practices will empower you to leverage the full potential of version control and code management in your projects. Enjoy your journey with Gitea on Ubuntu 20.04!

Leave a Comment