In this tutorial, we'll learn how to install and configure Gitea on AlmaLinux 10 server.
What is Gitea?
Gitea is a lightweight, open-source, self-hosted Git service used for managing code repositories. It provides features similar to GitHub, GitLab, and Bitbucket, but can run comfortably even on low-resource servers. With Gitea, we can host repositories, manage issues, perform code reviews, collaborate with teams, and integrate CI/CD tools. It is simple to set up, easy to maintain, and designed for speed and flexibility. Gitea supports SSH and HTTPS, multiple databases, built-in user management, and access controls, giving us full control over our development workflow.
Prerequisites
Before we begin, ensure we have the following:
- An AlmaLinux 10 on dedicated server or KVM VPS.
- Basic Linux Command Line Knowledge.
- A domain name pointing A record to server IP.
Install and Configure Gitea on AlmaLinux 10
Step 1: Update Server Packages
We start by ensuring the server has the latest security patches and dependencies.
sudo dnf update -y
sudo dnf install -y git wget vim
Step 2: Create a Dedicated System User for Gitea
A separate user improves security and prevents direct root execution.
sudo useradd \
--system \
--shell /bin/bash \
--comment 'Gitea Service' \
--create-home \
--home-dir /var/lib/gitea \
gitea
Create required directories with proper ownership:
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 -R gitea:gitea /etc/gitea
sudo chmod -R 750 /etc/gitea
Step 3: Install Gitea Binary
We download the latest stable binary from the official source.
sudo wget -O /usr/local/bin/gitea \
https://dl.gitea.com/gitea/latest/gitea-1.25.1-linux-amd64
sudo chmod +x /usr/local/bin/gitea
(Use the latest version link available when installing.)
Step 4: Create Gitea Service File
Setting Gitea as a systemd service allows automatic start at boot.
sudo vim /etc/systemd/system/gitea.service
Add the following:
[Unit]
Description=Gitea Self-Hosted Git Service
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=GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
Reload and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable --now gitea
Check status:
sudo systemctl status gitea
Step 5: Configure Firewall Rules
Allow access to default Gitea port 3000.
sudo firewall-cmd --permanent --add-port={80,443,3000}/tcp
sudo firewall-cmd --reload
Configure SELinux
sudo setsebool -P httpd_can_network_connect 1
Step 6: Access and Complete Web Setup
Open a browser and visit:
http://<server-ip>:3000
Configure:
- Database Type: SQLite3 (works well for small to medium installations)
- Application URL: http://<server-ip>:3000/
- Repository Root Path: /var/lib/gitea/data/gitea-repositories
- Complete admin setup and create the first admin account.
(For larger teams, MariaDB or PostgreSQL is recommended.)
Step 7: Set Up Reverse Proxy (Recommended for Production)
Using Nginx allows HTTPS support and better performance.
Install Nginx:
sudo dnf install -y nginx
sudo systemctl enable --now nginx
Create a new config:
sudo vim /etc/nginx/conf.d/gitea.conf
Add:
server {
listen 80;
server_name gitea.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Restart:
sudo systemctl restart nginx
Step 8: Enable HTTPS with Let’s Encrypt SSL
sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d gitea.example.com
Step 9: Basic Security Hardening
- Disable registration if running a private instance
- Enable 2FA
- Make regular backups of /var/lib/gitea
- Use fail2ban to prevent brute-force attacks
Step 10: Backup and Update Gitea
Backup:
sudo tar -czvf gitea-backup-$(date +%F).tar.gz /var/lib/gitea/
Update:
sudo systemctl stop gitea
sudo wget -O /usr/local/bin/gitea https://dl.gitea.com/gitea/latest/gitea-1.23.4-linux-amd64
sudo chmod +x /usr/local/bin/gitea
sudo systemctl start gitea
Conclusion
A self-hosted Git platform gives full ownership of code and data without relying on external services. This guide provided a complete setup for Gitea on AlmaLinux 10 including installation, service configuration, optional PostgreSQL integration, reverse proxy setup, SSL, and essential security practices.
With this environment running, teams can confidently manage repositories, collaborate efficiently, and maintain complete data privacy.
