Back to articles
Technology Insight

Running Your Own Git Server with Gitea on VPS: A Complete Guide to Replacing GitHub Private

May 17, 2026

Introduction: The Case for Self-Hosted Git

In today's software development landscape, version control is non-negotiable. While platforms like GitHub, GitLab, and Bitbucket dominate the market, many organizations are reconsidering their dependency on third-party services. The limitations of GitHub's free private repositories, concerns about data sovereignty, and the desire for complete control over development infrastructure have led teams to explore self-hosted alternatives. Enter Gitea: a lightweight, open-source Git service written in Go that provides GitHub-like functionality without the vendor lock-in.

This guide will walk you through deploying Gitea on a Virtual Private Server (VPS), transforming it into a fully functional Git server that can replace GitHub Private for your organization. We'll cover everything from initial setup to advanced configuration, security hardening, and migration strategies.

Why Choose Gitea Over GitHub Private?

Before diving into implementation, it's essential to understand the compelling reasons for migrating to a self-hosted solution:

  • Complete Data Control: Your code never leaves your infrastructure, addressing compliance requirements for regulated industries like healthcare, finance, and government.
  • Unlimited Private Repositories: Unlike GitHub's tiered pricing, Gitea imposes no artificial limits on private repositories or collaborators.
  • Cost Efficiency: After the initial VPS investment, Gitea runs indefinitely without recurring subscription fees, making it economical for growing teams.
  • Customization Freedom: Modify workflows, integrate with internal systems, and tailor the environment to your specific development practices.
  • Performance Optimization: Host your Git server geographically close to your development team for faster clone, push, and pull operations.
  • Reduced Vendor Risk: Eliminate concerns about service outages, pricing changes, or platform policy shifts affecting your development pipeline.

Prerequisites and VPS Selection

Successful Gitea deployment begins with proper infrastructure planning. Here's what you'll need:

Hardware Requirements

Gitea is remarkably resource-efficient. For small to medium teams (1-50 developers), we recommend:

  • CPU: 2+ cores (x86-64 or ARM64 architecture)
  • RAM: 2-4 GB minimum, 8 GB recommended for active use
  • Storage: 20+ GB SSD storage (consider growth and backup requirements)
  • Network: Stable internet connection with sufficient bandwidth for your team size

VPS Provider Considerations

When selecting a VPS provider, evaluate these critical factors:

  1. Reliability and Uptime: Look for providers offering 99.9%+ SLA with transparent monitoring.
  2. Data Center Location: Choose a region close to your primary development team for optimal latency.
  3. Backup Solutions: Ensure automated backup options are available for disaster recovery.
  4. Scalability: Select providers that allow easy resource upgrades as your needs grow.
  5. Security Features: Prefer providers with DDoS protection, firewall management, and private networking options.

Software Prerequisites

Your VPS should run a modern Linux distribution. We recommend Ubuntu 22.04 LTS or Debian 12 for their stability and extensive documentation. Ensure you have:

  • SSH access with sudo privileges
  • Git installed (version 2.0 or later)
  • Basic firewall configuration (UFW or firewalld)
  • A registered domain name (optional but recommended for production use)

Step-by-Step Gitea Installation

1. System Preparation

Begin by updating your system and installing essential dependencies:

Note: All commands should be executed as a non-root user with sudo privileges. Regular system updates and security patches are crucial for maintaining a secure Git server.

2. Database Setup

Gitea supports multiple database backends. For production deployments, we recommend PostgreSQL or MySQL/MariaDB over SQLite for better performance and concurrent access handling. Here's how to set up PostgreSQL:

  • Install PostgreSQL and create a dedicated database user
  • Configure appropriate authentication methods
  • Create a database with proper encoding and permissions
  • Test the connection before proceeding with Gitea installation

3. Gitea Binary Installation

Download the latest stable Gitea release from the official repository. Verify the checksum for security, set appropriate permissions, and place the binary in a standard location like /usr/local/bin. Create a dedicated system user for Gitea to run under, enhancing security through privilege separation.

4. Configuration and Service Setup

Generate the initial configuration using Gitea's built-in wizard or create a custom app.ini file. Key configuration areas include:

  • Database Connection: Specify your PostgreSQL/MySQL connection details
  • Server Settings: Configure domain, HTTP/HTTPS ports, and application URLs
  • Repository Settings: Define storage paths and repository organization
  • Email Configuration: Set up SMTP for notifications and user verification

Create a systemd service file to manage Gitea as a background service, enabling automatic startup on boot and proper logging through journald.

Security Hardening and Best Practices

Network Security

Protect your Git server with these essential measures:

  • Firewall Configuration: Restrict access to necessary ports only (SSH, HTTP/HTTPS)
  • Fail2ban Implementation: Protect against brute-force attacks on SSH and web interfaces
  • Reverse Proxy Setup: Use Nginx or Apache as a reverse proxy with SSL termination
  • SSL/TLS Encryption: Obtain and configure Let's Encrypt certificates for HTTPS

Application Security

Gitea includes several security features that require proper configuration:

  • Authentication Methods: Enable and configure OAuth2, LDAP, or SMTP authentication as needed
  • Access Controls: Implement repository permissions, branch protection rules, and team-based access
  • Audit Logging: Enable comprehensive logging for security monitoring and compliance
  • Regular Updates: Establish a process for applying Gitea security patches promptly

Data Protection

Ensure your code remains safe and recoverable:

  • Automated Backups: Schedule regular database and repository backups
  • Off-site Storage: Store backups in geographically separate locations
  • Disaster Recovery Plan: Document and test restoration procedures
  • Monitoring: Implement system monitoring for disk space, memory usage, and service availability

Migration from GitHub Private

Preparation Phase

Successful migration requires careful planning:

  1. Inventory Assessment: Document all repositories, teams, and permissions on GitHub
  2. Communication Plan: Inform all stakeholders about the migration timeline and expectations
  3. Testing Environment: Set up a staging instance of Gitea for migration testing
  4. Rollback Strategy: Prepare to revert to GitHub if unexpected issues arise

Migration Tools and Techniques

Gitea provides built-in migration tools that handle:

  • Repository cloning with full history
  • Issue and pull request migration
  • Wiki content transfer
  • Webhook recreation

For large organizations, consider a phased migration approach, moving non-critical repositories first to validate the process before migrating mission-critical codebases.

Post-Migration Validation

After migration, verify:

  • All repository history is intact and accessible
  • Collaborators have appropriate access permissions
  • CI/CD pipelines function correctly with the new Git URLs
  • Webhooks and integrations work as expected
  • Performance meets or exceeds previous GitHub experience

Advanced Configuration and Integration

CI/CD Pipeline Integration

Gitea integrates seamlessly with popular CI/CD systems:

  • Gitea Actions: Native CI/CD solution similar to GitHub Actions
  • Drone CI: Lightweight container-native continuous integration platform
  • Jenkins: Enterprise automation server with extensive Gitea plugins
  • Custom Webhooks: Trigger external systems on repository events

Containerized Deployment

For organizations embracing containerization, Gitea offers official Docker images and Helm charts for Kubernetes deployment. Containerized deployment provides:

  • Consistent environments across development, staging, and production
  • Simplified scaling and high-availability configurations
  • Easier version management and rollback capabilities
  • Isolation from underlying host system changes

High Availability Setup

For mission-critical deployments, consider implementing high availability:

  • Multiple Gitea instances behind a load balancer
  • Shared storage for repositories (NFS, S3-compatible object storage)
  • Database clustering or replication
  • Session management with Redis cluster

Maintenance and Monitoring

Regular Maintenance Tasks

Establish a maintenance schedule including:

  • Weekly repository integrity checks
  • Monthly security updates and patches
  • Quarterly performance reviews and optimization
  • Annual disaster recovery testing

Monitoring and Alerting

Implement monitoring for key metrics:

  • System resources (CPU, memory, disk I/O)
  • Application performance (response times, error rates)
  • Repository growth and storage utilization
  • Security events and failed authentication attempts

Conclusion: Embracing Infrastructure Independence

Migrating from GitHub Private to self-hosted Gitea represents more than just a technical change—it's a strategic decision to reclaim control over your development infrastructure. While the initial setup requires investment, the long-term benefits of complete control, unlimited scalability, and cost predictability make it a compelling choice for organizations of all sizes.

Gitea's active development community, comprehensive documentation, and GitHub-compatible interface ensure a smooth transition for development teams. By following the best practices outlined in this guide, you can establish a secure, performant, and reliable Git hosting environment that supports your organization's growth for years to come.

Remember that successful self-hosting requires commitment to ongoing maintenance and security practices. The investment in proper setup, monitoring, and regular updates pays dividends in the form of a stable, controlled development environment that aligns perfectly with your organization's specific needs and compliance requirements.