Table of Contents
#Introduction
In this tutorial, How to install Gitea repository in Ubuntu.
- 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.
Install the Gitea repository in Ubuntu
Install the necessary dependencies
sudo apt-get install wget get mariadb-server -y
After installed complete, to step 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

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!