Hosting

Gitea Self-Hosted Git Service

Set up a lightweight self-hosted Git service with Gitea, including installation, configuration, backup, and daily administration.

Who This Is For
  • Team leads or developers choosing a Git hosting solution
Prerequisites
  • Basic Git remote operation knowledge
  • Understanding of code hosting requirements
Common Risks
  • Comparing only feature lists while ignoring operational costs
  • Choosing a self-hosted solution without sufficient maintenance capacity

Overview

Gitea is a lightweight self-hosted Git service written in Go. Compared to GitLab CE, Gitea has minimal resource requirements (128MB RAM is enough), making it ideal for small teams or personal use.

Installation

Method 1: Binary Install (Recommended)

# Download the latest binary
wget -O gitea https://dl.gitea.com/gitea/1.22/gitea-1.22-linux-amd64
chmod +x gitea

# Create the git user
sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git git

# Create required directories
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea

# Start
sudo -u git ./gitea web

Method 2: Docker Deployment

# docker-compose.yml
version: "3"
services:
  gitea:
    image: gitea/gitea:1.22
    ports:
      - "3000:3000"
      - "222:22"
    volumes:
      - ./gitea-data:/data
    restart: always
docker compose up -d

Initial Configuration

Visit http://localhost:3000 in your browser — the installation page appears:

SettingRecommended
DatabaseSQLite (small team) or PostgreSQL
DomainCustom domain or IP
SSH port222 (if using Docker port mapping)
HTTP port3000
Admin accountCreate immediately

Daily Administration

Backup

# Built-in backup command
sudo -u git ./gitea dump -c /etc/gitea/app.ini

# Backup includes: database, repos, config, logs
# Output to /var/lib/gitea/data/

Upgrade

# 1. Stop service
sudo systemctl stop gitea

# 2. Backup
sudo -u git ./gitea dump

# 3. Replace binary
cp gitea-old gitea-new

# 4. Restart
sudo systemctl start gitea

Configuration

# /etc/gitea/app.ini
[server]
DOMAIN = git.example.com
ROOT_URL = https://git.example.com/
HTTP_PORT = 3000
SSH_DOMAIN = git.example.com

[database]
DB_TYPE = sqlite3
PATH = /var/lib/gitea/data/gitea.db

[mailer]
ENABLED = true
SMTP_ADDR = smtp.example.com

Comparison

FeatureGiteaGitLab CEGitHub
Memory~128MB~4GBSaaS
Setup complexityLowHighNone
CI/CDBuilt-in ActionsBuilt-in CIActions
Code reviewYesYesYes
Team managementBasicRichRich
Migration toolsYesYesYes

Continue Learning

  1. hosting/self-hosted-git — Self-hosted Git overview
  2. hosting/platform-comparison — Platform comparison
  3. hosting/github-deep-dive — GitHub advanced features