Manual Installation of Gitea on Debian 12 for Self-Hosted Git Management

Introduction

If you're looking to host your own Git service, Gitea is an excellent choice due to its lightweight design and ease of use. At , we understand the importance of having a reliable, self-hosted Git management solution. In this comprehensive guide, we will walk you through the process of installing Gitea on Debian 12 manual install guide. This method provides a native, bare-metal setup without Docker, perfect for beginners who want full control over their environment.

Prerequisites: Preparing Your Debian 12 VPS and Installing Necessary Dependencies

Before we begin, ensure you have a Debian 12 VPS ready. Our VPS plans are optimized for hosting applications like Gitea, offering robust performance and security. You should have root or sudo access to your server.

Next, update your system packages to ensure everything is current:

sudo apt update && sudo apt upgrade -y

Gitea requires a few dependencies to run smoothly. Install them with:

sudo apt install -y git sqlite3 libsqlite3-dev nginx

While SQLite is suitable for small to medium setups, for larger deployments, consider installing MySQL or PostgreSQL. For simplicity, we'll use SQLite in this guide.

Downloading and Installing Gitea from Official Sources

Step 1: Download the Latest Gitea Binary

Visit the official Gitea downloads page to find the latest version. Use wget to download it directly to your server:

wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/latest/gitea--linux-amd64

Replace <version> with the latest version number, e.g., 1.20.4. Make sure the binary is executable:

sudo chmod +x /usr/local/bin/gitea

Step 2: Create a Gitea User and Directories

For security, run Gitea under its own user:

sudo adduser --system --group --shell /bin/bash --gecos 'Gitea' --disabled-password gitea

Create necessary directories:

sudo mkdir -p /var/lib/gitea/{custom,data,log} /etc/gitea
sudo chown -R gitea:gitea /var/lib/gitea /etc/gitea
sudo chmod -R 750 /var/lib/gitea /etc/gitea

Configuring Gitea for First-Time Setup and Securing Access

Step 1: Create a Systemd Service

To run Gitea as a service, create a systemd unit file:

sudo nano /etc/systemd/system/gitea.service

Insert the following configuration:

[Unit]
Description=Gitea
After=network.target

[Service]
User=gitea
Group=gitea
Type=simple
ExecStart=/usr/local/bin/gitea web -p 3000
Restart=always
Environment=USER=gitea HOME=/home/gitea

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl enable gitea
sudo systemctl start gitea

Step 2: Access Gitea Web Installer

Open your browser and navigate to http://your_server_ip:3000. You will see the Gitea web setup page. Follow the prompts to configure your database (SQLite is pre-selected), repository settings, and admin account.

Ensure you set a strong password for the admin account and note down your credentials.

Step 3: Securing Gitea with HTTPS

For secure access, set up a reverse proxy with Nginx and obtain an SSL certificate. We recommend using Let's Encrypt for free SSL certificates.

sudo apt install certbot python3-certbot-nginx

Configure Nginx as a reverse proxy:

sudo nano /etc/nginx/sites-available/gitea

Insert the following configuration, replacing <your_domain> with your actual domain:

server {
    listen 80;
    server_name <your_domain>;

    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;
    }
}

Enable the site and obtain SSL:

sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/
sudo certbot --nginx -d <your_domain>

Follow the prompts to complete SSL setup. Now, your Gitea instance is accessible securely via HTTPS.

Verifying Gitea Installation and Creating Your First Repository

Once everything is configured, log in to your Gitea web interface. You can now create repositories, manage users, and customize your Git hosting environment. This install gitea on debian 12 manual install guide ensures you have a robust, self-hosted Git solution tailored to your needs.

Troubleshooting Common Gitea Installation Issues on Debian

  • Gitea fails to start: Check the service status with sudo systemctl status gitea. Review logs in /var/log/gitea for errors.
  • Permission issues: Ensure the gitea user owns the directories and binaries.
  • Cannot access Gitea web interface: Verify your Nginx configuration and SSL certificates.
  • Database errors: Confirm your database configuration matches your setup, especially if switching from SQLite to MySQL or PostgreSQL.

Conclusion

Installing Gitea on Debian 12 manually provides a flexible and secure environment for managing your Git repositories. By following our step-by-step guide, you can set up a reliable self-hosted Git service tailored to your workflow. Whether you're a developer or a team leader, hosting your own Gitea instance gives you full control over your code. If you're interested in scalable hosting options, consider our VPS plans, optimized for applications like Gitea. Get started today and take control of your Git management!

Read more