How to Install and Configure Gitea from Binary on Ubuntu 24.04 VPS for Self-Hosting Git Repositories
Introduction
At ByteHosting, we understand the importance of having a reliable and self-hosted Git platform for your development workflows. Gitea is a lightweight, open-source Git service that’s perfect for small teams or individual developers who want full control over their repositories. In this tutorial, we’ll guide you through the process of installing Gitea from binary on Ubuntu 24.04 VPS, ensuring a quick and straightforward setup.
Prerequisites: VPS Setup and Required Packages
Before we begin, ensure you have a fresh Ubuntu 24.04 VPS. We recommend choosing one of our cost-effective KVM VPS plans in Frankfurt am Main, which provides excellent performance and reliability. You’ll need root or sudo privileges to install and configure Gitea.
Next, update your system packages to ensure everything is current:
sudo apt update && sudo apt upgrade -yInstall essential packages needed for the setup:
sudo apt install -y git sqlite3 wget ca-certificatesWe’ll use wget to download the Gitea binary, and git for repository management. SQLite is used as the default database, suitable for small to medium setups.
Download Gitea Binary from Official Source
Visit the official Gitea downloads page to find the latest binary release compatible with Linux. As of now, the latest version is 1.20.0, but always check for the newest release.
Use wget to download the binary:
wget -O /usr/local/bin/gitea https://dl.gitea.io/gitea/1.20.0/gitea-1.20.0-linux-amd64Make the binary executable:
sudo chmod +x /usr/local/bin/giteaThis approach allows us to install Gitea quickly without compiling from source, making it ideal for a fresh Ubuntu 24.04 VPS deployment.
Configure Gitea Service and Environment Variables
To run Gitea as a service, create a dedicated user:
sudo adduser --system --group --disabled-login --gecos "Gitea" giteaNext, create directories for Gitea’s data and configuration:
sudo mkdir -p /var/lib/gitea/{custom,data,log} /etc/giteaSet ownership:
sudo chown -R gitea:gitea /var/lib/gitea /etc/giteaNow, create a systemd service file to manage Gitea:
sudo nano /etc/systemd/system/gitea.serviceInsert the following configuration:
[Unit]
Description=Gitea
After=network.target
[Service]
User=gitea
Group=gitea
Type=simple
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.targetSave and close the file. Reload systemd and enable Gitea:
sudo systemctl daemon-reload
sudo systemctl enable gitea
Start Gitea and Access the Web Interface
Start the Gitea service:
sudo systemctl start giteaCheck if it’s running:
sudo systemctl status giteaOpen your browser and navigate to http://your-server-ip:3000. You should see the Gitea setup page. Follow the on-screen instructions to complete the initial configuration, including database setup and admin user creation.
Secure Gitea with SSL and Firewall Rules
For production, securing your Gitea instance is crucial. Use Certbot to obtain an SSL certificate:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.comConfigure your firewall to allow HTTP, HTTPS, and Gitea’s port (default 3000):
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 3000/tcp
sudo ufw enableRedirect Gitea to use HTTPS by configuring your web server accordingly.
Verify Installation and Create a Test Repository
Once secured, log into your Gitea web interface. Create a new repository to verify everything works smoothly. Clone it locally to test:
git clone http://yourdomain.com/yourusername/test-repo.gitThis confirms your self-hosted Gitea setup is operational and ready for use.
Troubleshooting Common Issues
- Permissions errors: Ensure the
giteauser owns all relevant directories. - Service not starting: Check logs with
journalctl -u giteaand verify the binary path and environment variables. - Web interface not accessible: Confirm firewall rules and SSL configuration are correct.
Conclusion
Installing Gitea from binary on Ubuntu 24.04 is a straightforward process that allows you to quickly set up a self-hosted Git platform. At ByteHosting, we provide reliable VPS hosting in Frankfurt am Main, making it easy to deploy and manage your own Gitea server. Whether you’re a developer or a team leader, hosting your repositories gives you full control and enhances your development workflow. Follow our guide, and you’ll have Gitea up and running in no time!