How to install Gitea repository in Ubuntu

#Introduction

In this tutorial, How to install Gitea repository in Ubuntu. Gitea is one self-hosted Git server. I will install Gitea on the Ubuntu server.

Install Gitea repository in Ubuntu

How to install the package 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 user

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.

To use nano edit to copy and paste the content into gitea.service file

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

The content is as below:

[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.

Enable and start gitea service.

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 the 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 and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. 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.

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