How To Install Gitea on Linux Mint 22
In this tutorial, we will show you how to install Gitea on Linux Mint 22. Self-hosting your own Git repositories has become increasingly popular among developers and organizations seeking greater control over their code management infrastructure. Gitea stands out as an exceptional lightweight, self-hosted Git service that offers robust functionality without the resource overhead of alternatives like GitLab. This comprehensive guide will walk you through installing Gitea on Linux Mint 22, from initial system preparation to production-ready configuration.
Gitea is a community-managed, lightweight code hosting solution written in Go and published under the MIT license. As a fork of Gogs, it provides essential features including issue tracking, repository branching, file locking, merge requests, and time tracking capabilities. Unlike resource-intensive alternatives, Gitea runs efficiently on modest hardware while delivering enterprise-grade functionality for individual developers, small teams, and organizations requiring private repository hosting.
Prerequisites and System Requirements
Hardware Requirements
Before beginning the installation process, ensure your Linux Mint 22 system meets the minimum hardware specifications. Gitea requires at least 512 MB of RAM for basic operation, though 1 GB or more is recommended for optimal performance with multiple concurrent users. A dual-core processor provides adequate performance for small teams, while organizations expecting heavy usage should consider quad-core or better processors.
Storage requirements depend heavily on your intended repository usage. Plan for at least 10 GB of available disk space for the initial installation and basic repositories. Organizations with extensive codebases or binary assets should allocate significantly more storage, considering that Git repositories can grow substantially over time with history retention.
Software Prerequisites
Linux Mint 22 provides an excellent foundation for Gitea installation. The system requires Git version 2.0 or newer, which is typically included in standard installations. Administrative access through sudo privileges is essential for system-level configuration and service management.
Database selection significantly impacts long-term scalability and performance. Gitea supports multiple database backends including SQLite (built-in), MySQL (>= 8.0), MariaDB (>= 10.4), PostgreSQL (>= 12), and MSSQL (>= 2012 SP4). SQLite works well for personal use and small teams but doesn’t scale effectively for larger deployments. Production environments should consider MySQL, MariaDB, or PostgreSQL for better performance and concurrent user support.
Network Considerations
Gitea defaults to port 3000 for web interface access, though this can be customized during configuration. Ensure this port remains available and not blocked by other services. For production deployments, plan for proper firewall configuration and consider implementing reverse proxy solutions with nginx or Apache for SSL termination and enhanced security.
Domain or subdomain planning becomes crucial for production installations. While localhost access suffices for development, production deployments benefit from proper DNS configuration and SSL certificate implementation for secure access.
Preparing the Linux Mint 22 System
Updating the System
Begin by ensuring your Linux Mint 22 system is current with the latest security patches and package updates. Open a terminal and execute the following commands to refresh package repositories and upgrade existing packages:
sudo apt update
sudo apt upgrade -y
Install essential build tools and dependencies required for Gitea operation:
sudo apt install curl build-essential git sqlite3 ca-certificates wget -y
These packages provide foundational tools for downloading, installing, and running Gitea effectively. The ca-certificates package ensures proper SSL/TLS certificate validation for secure communications.
Creating the Gitea User Account
Security best practices strongly recommend running Gitea under a dedicated system user rather than root or your personal account. This approach limits potential security exposure and provides better process isolation.
Create a dedicated system user for Gitea:
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
This command creates a system user named ‘git’ with restricted privileges, no password authentication, and a dedicated home directory. The user will own all Gitea-related files and processes, enhancing security through privilege separation.
Directory Structure Setup
Proper directory structure establishment ensures secure file organization and appropriate permission management. Create the required directories for Gitea operation:
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo mkdir -p /etc/gitea
sudo chown -R git:git /var/lib/gitea/
sudo chown root:git /etc/gitea
sudo chmod -R 750 /var/lib/gitea/
sudo chmod 770 /etc/gitea
These commands establish the standard Gitea directory structure with appropriate ownership and permissions. The /var/lib/gitea
directory stores application data, while /etc/gitea
contains configuration files. Permission settings ensure the git user can read and write necessary files while maintaining security boundaries.
Gitea Installation Methods
Method 1: Binary Installation (Recommended)
Binary installation offers the most straightforward and reliable approach for Gitea deployment on Linux Mint 22. This method provides optimal performance and direct control over the installation process.
Downloading the Binary
Navigate to the Gitea downloads page or use wget
to download the appropriate binary directly. For Linux Mint 22 on 64-bit Intel/AMD systems, select the linux-amd64 version:
cd /tmp
wget https://dl.gitea.com/gitea/1.24.0/gitea-1.24.0-linux-amd64
Verify the download integrity by checking the file size and ensuring the download completed successfully. The binary should be several dozen megabytes in size.
Installing the Binary
Copy the downloaded binary to the system binary directory and set appropriate permissions:
sudo cp gitea-1.24-linux-amd64 /usr/local/bin/gitea
sudo chmod +x /usr/local/bin/gitea
The binary name should remain generic (‘gitea’) rather than including version numbers to avoid complications during updates. This naming convention ensures existing repositories and configurations continue functioning correctly after version upgrades.
Test the installation by checking the Gitea version:
/usr/local/bin/gitea --version
This command should display version information confirming successful installation.
Method 2: Snap Package Installation
Linux Mint 22 includes snap support, though it may require enabling for Gitea installation. Snap packages provide containerized application deployment with automatic updates.
Enabling Snap Support
Linux Mint typically includes snap preferences that may restrict snap package installation. Remove these restrictions if present:
sudo rm /etc/apt/preferences.d/nosnap.pref
sudo apt update
sudo apt install snapd -y
Restart your system or reload snap services to ensure proper snap functionality.
Installing Gitea via Snap
Install Gitea using the snap package manager:
sudo snap install gitea
Snap installation provides automatic updates and simplified management but offers less control over configuration and may have performance implications due to snap confinement.
Method 3: Docker Installation
Docker provides containerized Gitea deployment for users preferring container-based solutions. Install Docker on Linux Mint 22:
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo systemctl start docker
Create a docker-compose.yml file for Gitea deployment:
version: "3"
services:
gitea:
image: gitea/gitea:latest
restart: always
ports:
- "3000:3000"
- "222:22"
volumes:
- ./gitea:/data
environment:
- USER_UID=1000
- USER_GID=1000
Deploy Gitea using Docker Compose:
docker-compose up -d
Database Configuration
SQLite Configuration (Default)
SQLite provides the simplest database configuration for Gitea, requiring no additional setup or external database server installation. Gitea includes built-in SQLite support, making it ideal for personal use, development environments, and small team deployments.
The SQLite database file will be automatically created in /var/lib/gitea/data/gitea.db
during initial configuration. Ensure the git user has read/write permissions to this location. SQLite offers excellent performance for moderate workloads but doesn’t scale effectively for high-concurrency environments or large user bases.
MariaDB/MySQL Setup
Production environments often benefit from dedicated database servers for improved performance and scalability. Install MariaDB server:
sudo apt install mariadb-server -y
sudo systemctl enable mariadb
sudo systemctl start mariadb
Secure the MariaDB installation:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disable remote root access, and remove test databases.
Create a dedicated database and user for Gitea:
sudo mysql -u root -p
Execute the following SQL commands:
CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'secure_password_here';
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Test the database connection:
mysql -u gitea -p giteadb
This should successfully connect to the database, confirming proper setup.
PostgreSQL Alternative
PostgreSQL offers excellent performance characteristics and advanced features for demanding environments. Install PostgreSQL:
sudo apt install postgresql postgresql-contrib -y
sudo systemctl enable postgresql
sudo systemctl start postgresql
Create a Gitea database and user:
sudo -u postgres psql
Execute PostgreSQL commands:
CREATE DATABASE giteadb;
CREATE USER gitea WITH PASSWORD 'secure_password_here';
GRANT ALL PRIVILEGES ON DATABASE giteadb TO gitea;
\q
Initial Gitea Configuration
First-Time Setup Wizard
Start Gitea for initial configuration:
sudo -u git /usr/local/bin/gitea web -c /etc/gitea/app.ini
Open your web browser and navigate to http://localhost:3000
. The initial setup wizard will guide you through essential configuration options.
Configure database settings based on your chosen database backend. For SQLite, select SQLite3 and leave default paths. For MariaDB/MySQL, enter your database credentials, hostname (localhost for local installations), and database name.
Create the administrative account during initial setup. Choose a strong username and password for the primary administrative user. This account will have full system privileges and should be secured appropriately.
Configure general settings including site title, description, and default repository settings. These options can be modified later through the administrative interface or configuration file editing.
Configuration File Management
Gitea’s primary configuration resides in /etc/gitea/app.ini
. This file contains comprehensive settings for database connections, server behavior, security parameters, and feature toggles.
Key configuration sections include:
- [database]: Database connection parameters
- [server]: Web server settings including ports and domains
- [security]: Security-related settings including secret keys
- [service]: User registration and repository creation policies
- [mailer]: Email notification configuration
After completing the web-based setup, secure the configuration file:
sudo chmod 750 /etc/gitea
sudo chmod 640 /etc/gitea/app.ini
Security and Production Hardening
File System Security
Proper file permissions are crucial for Gitea security. Ensure appropriate ownership and permissions for all Gitea-related directories and files:
sudo chown -R git:git /var/lib/gitea/
sudo chown root:git /etc/gitea/app.ini
sudo chmod 640 /etc/gitea/app.ini
These settings ensure the git user can access necessary files while preventing unauthorized access from other system users.
Service Configuration
Create a systemd service file for automatic Gitea startup and management:
sudo nano /etc/systemd/system/gitea.service
Add the following content:
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
Enable and start the Gitea service:
sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea
Network Security
Configure the firewall to allow Gitea access while maintaining security:
sudo ufw allow 3000/tcp
sudo ufw enable
For production deployments, implement SSL/TLS encryption using reverse proxy configuration with nginx or Apache. This approach provides enhanced security and allows for advanced features like load balancing and caching.
Starting and Managing Gitea Service
Service Management Commands
Use systemctl commands for comprehensive Gitea service management:
# Start Gitea
sudo systemctl start gitea
# Stop Gitea
sudo systemctl stop gitea
# Restart Gitea
sudo systemctl restart gitea
# Check service status
sudo systemctl status gitea
# View service logs
sudo journalctl -u gitea -f
These commands provide complete control over Gitea service lifecycle and monitoring capabilities.
Monitoring and Maintenance
Regular monitoring ensures optimal Gitea performance and early problem detection. Check service logs regularly for errors or warnings:
sudo journalctl -u gitea --since "24 hours ago"
Monitor system resources including CPU usage, memory consumption, and disk space to ensure adequate capacity for your Gitea deployment.
Post-Installation Configuration
User Management and Permissions
Access the Gitea administrative interface by logging in with your administrative account and navigating to Site Administration. Create additional user accounts, configure organizations, and establish team-based access controls based on your organizational requirements.
Configure user registration policies in the administrative settings. Options include open registration, invitation-only registration, or disabled registration for maximum security control.
Repository Management
Create your first repository by clicking the “+” icon and selecting “New Repository.” Configure repository visibility (public or private), add description and README files, and set up initial branch protection rules as needed.
For migrating existing repositories from other Git services, use Gitea’s built-in migration tools accessible through the repository creation interface. This feature supports importing from GitHub, GitLab, Bitbucket, and other Git-compatible services.
Troubleshooting Common Issues
Service and Permission Issues
Port conflicts often cause startup failures. If you encounter “address already in use” errors, either stop conflicting services or configure Gitea to use an alternative port:
sudo -u git /usr/local/bin/gitea web -p 3001
Permission-related errors typically stem from incorrect file ownership or permissions. Verify and correct permissions using the commands provided in the security section.
Database connection problems often indicate incorrect credentials or database server issues. Verify database connectivity using the command-line tools for your chosen database backend.
Performance and Resource Issues
Memory-related problems may occur on systems with limited RAM. Monitor memory usage and consider increasing system memory or optimizing Gitea configuration for lower resource consumption.
Large repository operations can temporarily impact performance. Consider implementing repository size limits and educating users about Git best practices for managing large files and repositories.
Updating and Maintenance
Update Procedures
Gitea updates require careful planning to prevent data loss and service interruption. Always create comprehensive backups before updating:
# Stop Gitea service
sudo systemctl stop gitea
# Backup data directory
sudo tar -czf gitea-backup-$(date +%Y%m%d).tar.gz /var/lib/gitea/ /etc/gitea/
# Download new binary
wget https://dl.gitea.com/gitea/latest/gitea-latest-linux-amd64
# Replace binary
sudo cp gitea-latest-linux-amd64 /usr/local/bin/gitea
sudo chmod +x /usr/local/bin/gitea
# Start Gitea service
sudo systemctl start gitea
The binary file name should remain unchanged during updates to avoid problems with existing repositories.
Long-term Maintenance
Establish regular backup schedules for both the Gitea data directory and database. Automated backup scripts can simplify this process and ensure consistent data protection.
Monitor security advisories for Gitea and underlying system components. Apply security updates promptly to maintain system security and stability.
Review and rotate administrative passwords regularly. Implement SSH key rotation for users accessing repositories via SSH protocols.
Congratulations! You have successfully installed Gitea. Thanks for using this tutorial for installing the latest version of Gitea on the Linux Mint 22 system. For additional help or useful information, we recommend you to check the official Gitea website.