How to Install Gitea with Nginx and free Let's Encrypt SSL on Ubuntu 20.04

 

 

Gitea is a lightweight and self-hosted Git service. In this guide, we will walk you through the steps to install Gitea on Ubuntu 20.04 with Nginx as a reverse proxy and securing it with a free Let's Encrypt SSL certificate. This setup is perfect for a windows vps uk or any other VPS provider.

Prerequisites

Before we begin, ensure you have the following:

  • Ubuntu 20.04 server.
  • A domain name pointing to your server.
  • Root access or a user with sudo privileges.
  • Install Nginx:
sudo apt update
sudo apt install nginx -y

Step 1: Install Gitea

First, download the latest Gitea binary:

wget -O gitea https://dl.gitea.io/gitea/latest/gitea--linux-amd64

Make it executable:

chmod +x gitea

Move it to /usr/local/bin:

sudo mv gitea /usr/local/bin/

Step 2: Create Gitea User and Directories

Create a user for Gitea:

sudo useradd -r -m -U -d /var/lib/gitea -s /bin/bash gitea

Create necessary directories:

sudo mkdir -p /etc/gitea
sudo mkdir -p /var/lib/gitea/{custom,data,indexers,log,public}

Change ownership:

sudo chown -R gitea:gitea /var/lib/gitea/
sudo chown -R gitea:gitea /etc/gitea

Step 3: Configure Gitea

Create a Gitea configuration file:

sudo nano /etc/gitea/app.ini

Add the following configuration (adjust paths and domain):

[server]
DOMAIN = your_domain.com
ROOT_URL = https://your_domain.com
HTTP_PORT = 3000
PROTOCOL = https

Step 4: Configure Nginx

Create a new Nginx configuration file:

sudo nano /etc/nginx/sites-available/gitea

Add the following content:

server {
    listen 80;
    server_name your_domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Enable the configuration:

sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/

Step 5: Obtain SSL Certificate

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Obtain and install the SSL certificate:

sudo certbot --nginx -d your_domain.com

Step 6: Start Gitea

To start Gitea, run the following command:

sudo -u gitea gitea web

Step 7: Access Gitea

Now you can access Gitea by visiting https://your_domain.com. You will be guided through the setup process.

Conclusion

Congratulations! You have successfully installed Gitea with Nginx and secured it with a free Let's Encrypt SSL certificate on Ubuntu 20.04. If you're looking for a reliable virtual private server hosting windows, consider Windows VPS UK for your hosting needs.

  • 0 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

Boost Your Ubuntu System's Performance with a Swap File: A Step-by-Step Guide

What is a Swap File? A swap file in Ubuntu serves as dedicated virtual memory on your hard...

How to Migrate ISPConfig 2, ISPConfig 3.x, Confixx, CPanel or Plesk to ISPConfig 3.2 (single server)

Introduction Migration from other control panels like ISPConfig 2, ISPConfig 3.x, Confixx,...

How to Install and Configure Zabbix Server and Client on Rocky Linux 9

Introduction Zabbix is an open-source monitoring solution that provides real-time...

How to Install CockroachDB Cluster on Debian 12

Introduction CockroachDB is a distributed SQL database built to handle large-scale,...

How to Install Joomla with Apache and Let's Encrypt SSL on AlmaLinux 9

Introduction Joomla is a popular open-source content management system (CMS) used to build...