DebianLinuxTutorials

How To Install Gitea on Debian 10

Install Gitea on Debian 10

In this tutorial, we will show you how to install Gitea on Debian 10. For those of you who didn’t know, Gitea is a free, open-source, and self-hosted version control system alternative to GitHub and GitLab. Gitea comes with a rich set of features including time tracking, repository branching, issues tracking, file locking, merging, and much more. Gitea can be installed on all popular operating systems like Windows, macOS, Linux, and ARM.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Gitea on a Debian 10 (Buster).

Prerequisites

  • A server running one of the following operating systems: Debian 10 (Buster).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Gitea on Debian 10 Buster

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Step 2. Installing Git and Create Git User.

You need to have git installed in your Debian machine:

sudo apt install git nano bash-completion

Confirm Git the installation:

[root@idroot.us ~]# git --version
git version 2.30.1

Next, add a Git user account for Gitea using the following commands:

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

Step 3. Installing Gitea on Debian 10.

Now we download Git from the GitHub page:

wget https://github.com/go-gitea/gitea/releases/download/v1.13.0/gitea-1.13.0-linux-amd64 -O gitea

Next, set the permission, so the Gitea is able to run:

chmod +x gitea
sudo mv gitea-v1.13.0-linux-amd64 /usr/local/bin/gitea

Confirm successful installation by checking the version of Gitea installed:

gitea --version

Step 4. Create Gitea Systemd File.

Now we create systemd for Gitea services on /etc/systemd/system/gitea.service:

nano /etc/systemd/system/gitea.service

Add the following line:

[Unit]
Description=Gitea
After=syslog.target
After=network.target
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=4000
RestartSec=2s
Type=simple
User=atetux
Group=atetux
WorkingDirectory=/home/atetux
ExecStart=/home/atetux/gitea web --config custom/conf/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
 
[Install]
WantedBy=multi-user.target

Then, enable and start the Gitea service:

sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea

Step 5. Installing an SSL certificate.

First, install Nginx on Debian 10:

sudo apt install nginx

In this step, we will install the SSL (TLS) certificate. We will use a free Let’s Encrypt certificate that will work in all browsers and the CertBot application to install the certificate and keep it updated:

sudo apt install certbot python-certbot-nginx

Next, run the certbot a command that will download the certificate and create the Nginx configuration to use the certificate:

sudo certbot --nginx -d DOMAIN --agree-tos -m email@gmail.com

You will then be prompted to enter an email address for the certificate. After you have entered that you must agree to the T&C’s and decide if you want to share your email address with the Electronic Frontier Foundation. This last step is optional. Once successfully, Reload Nginx again to load all the new configurations:

sudo systemctl reload nginx

Step 6. Setup Gitea Reverse Proxy.

Open the Nginx config file on /etc/nginx/sites-enabled/default, and set the proxy_pass to Gitea URL:

server {
listen 80;
server_name git.idroot.us;

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://localhost:3000;
   }
}

Set correct domain name and restart Nginx service:

sudo systemctl restart nginx

Step 7. Accessing Gitea Web Interface.

Now, open a web browser and visit https://git.idroot.us. You should see the following page:

Install Gitea on Debian 10

Congratulations! You have successfully installed Gitea. Thanks for using this tutorial for installing Gitea on Debian 10 Buster. For additional help or useful information, we recommend you to check the official Gitea website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button