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.

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)