Install Gitea Git Service on Ubuntu 18.04

Gitea is a free, open source and self-hosted version control system alternative to GitHub and GitLab. It is simple, easy, robuts, scalable and a great alternative to other git services. All source code is available under the MIT License on GitHub. Gitea has low minimal requirements (1 CPU core and 1GB RAM), so it can run on an inexpensive Raspberry Pi.

You can also compile Gitea for Windows, macOS, Linux, ARM, etc. Gitea provides lots of features such as, Low resource usage, Multiple database support, free and open source, Multiple OS support, etc.

In this tutorial, we will learn how to install and configure Gitea Git Service on Ubuntu 18.04 server.

Official git repository of Gitea: https://github.com/go-gitea/gitea/

First of all install Ubuntu 18.04. on Your virtual or physical server. After that update and upgrade your system to latest version:

sudo apt-get update
sudo apt-get upgrade

First, you will need to download the latest version of Gitea binary from Git repository. All versions of Gitea You can see here: https://github.com/go-gitea/gitea/releases/. You can download it with the following command:

wget https://github.com/go-gitea/gitea/releases/download/v1.10.3/gitea-1.10.3-linux-amd64

Next, copy the downloaded file to /usr/local/bin/ directory and give necessary permissions:

cp gitea-1.10.3-linux-amd64 /usr/local/bin/gitea
chmod 755 /usr/local/bin/gitea

Next, create a system user for Gitea with the following command:

adduser --system --shell /bin/bash --group  --disabled-password --home /home/gitea gitea

Next, create a directory structure for Gitea with the following command:

mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
chown gitea:gitea /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
chmod 770 /etc/gitea

Create Systemd Service file for Gitea

Next, you will need to create a systemd service file to manage Gitea service. You can create it with the following command:

nano /etc/systemd/system/gitea.service

Add the following lines:

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

[Service]
RestartSec=2s
Type=simple
User=root
Group=root
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
Environment=USER=root HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Save and close the file. Then, reload systemd and start Gitea service with the following command:

systemctl start gitea

You can check the status of Gitea service with the following command:

systemctl status gitea

Next, enable Gitea service to start at boot time with the following command:

systemctl enable gitea

2 thoughts on “Install Gitea Git Service on Ubuntu 18.04”

  1. Great content! Super high-quality! Keep it up! 🙂

Comments are closed.