Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host Gitea on a VPS (Complete Guide)

A complete step-by-step guide to self-hosting Gitea on a VPS in 2026, covering installation, configuration, securing Gitea, and the specs you need.

How to Self-Host Gitea on a VPS (Complete Guide)

Gitea is a lightweight, self-hosted Git service that allows developers to manage their projects with ease. In this guide, we will walk through the steps to self-host Gitea on a Virtual Private Server (VPS) using Docker. This setup gives you control over your source code management while keeping costs low.

Choosing a VPS Provider

When selecting a VPS for running Gitea, consider factors like performance, cost, and reliability. Below is a comparison of popular VPS providers that are suitable for self-hosting applications like Gitea:

ProviderStarting PriceCPURAMStorage
Contabo VPS5.99 EUR/mo2 vCPU4 GB500 GB SSD
Hetzner Cloud4.15 EUR/mo1 vCPU2 GB20 GB SSD
DigitalOcean6 USD/mo1 vCPU1 GB25 GB SSD
Vultr6 USD/mo1 vCPU1 GB25 GB SSD
Linode (Akamai Cloud)5 USD/mo1 vCPU1 GB25 GB SSD

For Gitea, even a low-spec VPS will suffice, although you may want to consider a provider with better uptime and customer support, such as Contabo or Hetzner.

Prerequisites

Before we begin the installation, ensure you have the following:

  1. A VPS instance running a Linux distribution (Ubuntu is recommended).
  2. Root access to your VPS.
  3. Docker and Docker Compose installed on your server. If they are not installed, follow the steps below:

Install Docker and Docker Compose

  1. Connect to your VPS via SSH:

    ssh root@your_vps_ip
  2. Update your package index:

    apt update && apt upgrade -y
  3. Install Docker:

    apt install -y docker.io
  4. Enable and start Docker:

    systemctl enable docker
    systemctl start docker
  5. Install Docker Compose:

    apt install -y docker-compose

Installing Gitea with Docker

Now that Docker is installed, we can proceed to deploy Gitea.

  1. Create a directory for Gitea:

    mkdir -p /opt/gitea
    cd /opt/gitea
  2. Create a Docker Compose file named docker-compose.yml:

    version: '3'
    services:
      gitea:
        image: gitea/gitea:latest
        environment:
          - USER=git
          - GITEA__database__DB_TYPE=sqlite3
          - GITEA__database__PATH=/data/gitea.db
          - GITEA__server__DOMAIN=yourdomain.com
          - GITEA__server__ROOT_URL=https://yourdomain.com
          - GITEA__server__HTTP_PORT=3000
          - GITEA__server__SSH_PORT=22
          - GITEA__security__INSTALL_LOCK=true
        volumes:
          - gitea_data:/data
        ports:
          - "3000:3000"
          - "222:22"
    volumes:
      gitea_data:
  3. Replace yourdomain.com with your actual domain name or the IP address of your VPS.

  4. Start the Gitea service:

    docker-compose up -d
  5. Check if Gitea is running:

    docker ps

Configuring Gitea

After starting Gitea, you can access it in your web browser by entering http://your_vps_ip:3000 or http://yourdomain.com:3000. The initial setup will guide you through configuring the database and admin account.

Steps to Configure:

  1. Database: Since we are using SQLite, you can keep the default settings.

  2. Application URL: Set this to your domain or IP.

  3. Admin Account: Create the admin user account.

  4. Additional Settings: Configure email notifications and other features according to your needs.

Managing Gitea

Once Gitea is installed and configured, you can manage it through the web interface. You can create repositories, manage access controls, and utilize the various features offered by Gitea.

FAQs

1. Can I use Gitea for private repositories?

Yes, Gitea allows you to create private repositories where only invited collaborators can access the code. This is perfect for teams working on proprietary projects or sensitive code.

2. How secure is Gitea when self-hosting?

Security largely depends on your serverโ€™s configuration. Ensure your firewall is configured, keep your software updated, and consider using HTTPS for secure connections. Regular backups of your data are also a good practice.

3. Can I migrate my projects from GitHub to Gitea?

Yes, Gitea provides built-in tools to import repositories from GitHub and other services. Simply follow the import tools in the Gitea web UI and provide the necessary repository URLs and authentication tokens.

Conclusion

Self-hosting Gitea on a VPS is a straightforward process that provides you with flexibility and control over your code repositories. The Docker deployment method ensures easy setup, scalability, and management of your Gitea instance. For a comprehensive view of different VPS options to host your applications, check out our full VPS comparison. Happy coding!