Gitea is a lightweight, self-hosted Git service written in Go. It offers a GitHub-like interface with a tiny resource footprint — ideal for small teams and personal servers. This guide installs Gitea on Ubuntu 24.04 LTS.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- MySQL 8.0 or PostgreSQL 16 installed
- A domain name pointed to the server
- A user with sudo privileges
Step 1 – Create a Gitea System User
Run Gitea as a dedicated non-root user:
sudo adduser --system --shell /bin/bash --gecos 'Gitea' --group --disabled-password --home /home/git git
Step 2 – Download the Gitea Binary
Download the latest Gitea binary:
sudo wget -O /usr/local/bin/gitea https://dl.gitea.com/gitea/1.21.1/gitea-1.21.1-linux-amd64
sudo chmod +x /usr/local/bin/gitea
Step 3 – Create Required Directories
Set up the Gitea directory structure:
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
Step 4 – Create a systemd Service
Create the service file:
sudo nano /etc/systemd/system/gitea.service
Add:
[Unit]
Description=Gitea Git Service
After=syslog.target network.target mysql.service
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable gitea
sudo systemctl start gitea
Step 5 – Create the Database
Create a Gitea database in MySQL:
sudo mysql
CREATE DATABASE gitea;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'GiteaPass123!';
GRANT ALL ON gitea.* TO 'gitea'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 6 – Configure Nginx Reverse Proxy
Create the Nginx server block:
sudo nano /etc/nginx/sites-available/gitea
Add:
server {
listen 80;
server_name git.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Enable and reload:
sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Step 7 – Complete the Web Installer
Visit http://git.example.com and complete the setup form. Enter your database credentials and create the admin account.
Conclusion
Gitea is now running on Ubuntu 24.04 LTS. It provides a full Git hosting solution with minimal resource requirements — typically running in less than 100 MB of RAM.