GitHub is great, but you might want a private Git server for your projects. Self‑hosting gives you full control, unlimited private repositories, and no storage limits besides your VPS disk.

Gitea is a lightweight, open‑source Git service. It runs on low‑spec VPS (1 GB RAM is enough). This guide covers installation.

Prerequisites

A VPS with at least 1 GB RAM, domain name (optional), and basic knowledge of Linux.

Step 1: Install Dependencies

sudo apt update
sudo apt install git sqlite3 wget -y

Step 2: Download Gitea

Get the latest binary from gitea.com.

wget -O gitea https://dl.gitea.com/gitea/1.21.4/gitea-1.21.4-linux-amd64
chmod +x gitea
sudo mv gitea /usr/local/bin/

Step 3: Create Gitea User

sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/gitea gitea

Step 4: Configure Gitea

Create directories and set permissions:

sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R gitea:gitea /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
sudo mkdir -p /etc/gitea
sudo chown root:gitea /etc/gitea
sudo chmod 770 /etc/gitea

Create config file /etc/gitea/app.ini:

[server]
DOMAIN = git.yourdomain.com
HTTP_PORT = 3000
ROOT_URL = https://git.yourdomain.com
; If you don't have a domain, use IP: http://YOUR_IP:3000

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

Set ownership: sudo chown gitea:gitea /etc/gitea/app.ini

Step 5: Create Systemd Service

Create /etc/systemd/system/gitea.service:

[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target

[Service]
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea

Step 6: Configure Nginx Reverse Proxy (Optional)

Install Nginx:

sudo apt install nginx -y

Create /etc/nginx/sites-available/gitea:

server {
    listen 80;
    server_name git.yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Enable site and test:

sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 7: Access and Complete Installation

Open your browser to http://your_server_ip:3000 (or your domain). The first visit shows install page. It should detect existing config. Click "Install".

Create an admin account.

Step 8: Set Up HTTPS with Certbot (Recommended)

After domain is pointed, get Let's Encrypt certificate:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d git.yourdomain.com

Using Your Gitea Server

Create a new repository, then push:

git remote add origin http://git.yourdomain.com/username/repo.git
git push -u origin master

For SSH access, you need to add your public key in Gitea web UI.

Next Steps

Set up regular backups of /var/lib/gitea/data. You can also configure email notifications and webhooks.

Need a VPS to host Gitea? Check our recommended VPS providers.