Install Gitea (Self-Hosted Git) on Ubuntu 24.04
Step 1 – Create the git user
useradd -r -m -d /home/git -s /bin/bash git
Step 2 – Download Gitea binary
VERSION=1.22.0
wget -O /usr/local/bin/gitea \
https://dl.gitea.com/gitea/${VERSION}/gitea-${VERSION}-linux-amd64
chmod +x /usr/local/bin/gitea
Step 3 – Create directories
mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea
chmod -R 750 /var/lib/gitea
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
Step 4 – systemd service (/etc/systemd/system/gitea.service)
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target network.target mysql.service postgresql.service
[Service]
RestartSec=2s
Type=notify
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now gitea
Step 5 – Nginx reverse proxy
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Step 6 – Initial setup
Visit http://git.example.com and follow the installation wizard.
Choose your database (SQLite for small setups, PostgreSQL for production).