How to install Gitea repository in Ubuntu

Introduction

In this tutorial, How to install Gitea repository in Ubuntu.

Understanding Gitea

  • Gitea is a web-based Git repository management tool, similar to GitHub, GitLab, and Bitbucket. It is a self-hosted, open-source software that allows developers to create and manage Git repositories, as well as collaborate with others on software development projects.
  • With Gitea, you can create your own private Git repositories, manage access control and permissions for users and teams, and track issues and bugs with an integrated issue tracker. It also supports pull requests, code reviews, and continuous integration and deployment with built-in integrations for popular tools like Jenkins and Travis CI.
  • It is written in Go, and it’s lightweight and easy to set up and run.

Why Choose Gitea?

  • Lightweight: Gitea is very resource-efficient.
  • Open Source: It is free to use and modify.
  • Feature-Rich: Offers essential Git features along with additional tools like issue tracking and code review.
  • Easy to Install: The setup process is straightforward, making it accessible even for beginners.

Prerequisites

Before you begin, ensure you have the following:

  • An Ubuntu server instance with sudo privileges.
  • A basic understanding of terminal commands.

Install Gitea repository in Ubuntu

Install the necessary dependencies

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

After the installation, secure the database server as command below:

sudo mysql_secure_installation

Create a database and user

Log in to the database console as below:

sudo mysql -u root -p

Create the database

CREATE DATABASE gitea;
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY "your_password";
FLUSH PRIVILEGES;
exit

Install Gitea repository

Download and copy to /usr/local/bin

sudo wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/1.17.1/gitea-1.17.1-linux-amd64

Change the permissions

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

Create a new system user for running Gitea:

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

Create the folder and change the permission

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

Create a systemd service file for Gitea.

Create a new systemd service file for Gitea by running the following command:

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

Paste the following configuration into the service file:

[Unit]
Description=Gitea
After=syslog.target
After=network.target

[Service]
RestartSec=3s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/

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

[Install]
WantedBy=multi-user.target

Save and close the file.

Start and enable the Gitea service by running the following commands:

sudo systemctl start gitea
sudo systemctl enable --now gitea
How to install Gitea repository in Ubuntu

Access the Gitea web-based installer

Open a browser and point it to http://YOUR_SERVER:3000

Conclusion

You have to install Gitea repository in Ubuntu. I hope this will be helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.