step-by-step guide to install and configure Gitea (a self-hosted Git service) on a Linux System
π§° Prerequisites
Make sure you have:
- A Linux server (Ubuntu/Debian/CentOS, etc.)
- Root or sudo access
- Git installed
- A database (SQLite, MySQL, or PostgreSQL). SQLite works by default for testing.
πͺ Step 1: Update Your System
sudo apt update && sudo apt upgrade -y
πͺ Step 2: Install Dependencies
sudo apt install -y git wget tar
If youβre using MySQL or PostgreSQL, install their client libraries, for example:
sudo apt install -y mariadb-server mariadb-client
# or for PostgreSQL
sudo apt install -y postgresql postgresql-contrib
πͺ Step 3: Create a Gitea User
For security, run Gitea as a non-root user.
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
πͺ Step 4: Create Necessary 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/
sudo mkdir -p /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
πͺ Step 5: Download Gitea Binary
Check the latest version at https://dl.gitea.io/gitea/.
For example:
sudo wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/1.22.0/gitea-1.22.0-linux-amd64
sudo chmod +x /usr/local/bin/gitea
πͺ Step 6: Create a Systemd Service
Create a service file:
sudo nano /etc/systemd/system/gitea.service
Paste the following content:
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
Requires=network.target
[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
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
Save and exit (Ctrl+O, Enter, Ctrl+X).
πͺ Step 7: Start and Enable Gitea
sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea
Check status:
sudo systemctl status gitea
πͺ Step 8: Configure Firewall (optional)
If youβre using UFW:
sudo ufw allow 3000/tcp
sudo ufw reload
πͺ Step 9: Access Gitea Web Interface
Open your browser and navigate to:
http://your_server_ip:3000/
Follow the setup wizard:
- Database Type: SQLite (default) β or MySQL/PostgreSQL if configured
- Root URL: e.g.,
http://your_server_ip:3000/ - Repository Root Path:
/var/lib/gitea/data/ - Application Log Path:
/var/lib/gitea/log/ - Gitea Config Path:
/etc/gitea/app.ini
Create your first admin user during this setup.
πͺ Step 10: Make Gitea Start at Boot
Already done if you ran:
sudo systemctl enable gitea
To verify:
sudo systemctl is-enabled gitea
Would you like me to include how to set it up behind Nginx with HTTPS as well?
