Gitea is a lightweight, self-hosted Git service that provides a simple and easy way to manage your Git repositories. In this guide, we will walk through the steps to install Gitea with PostgreSQL on Debian 11.
Step 1: Update Your System
Start by ensuring your system is up to date:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Packages
Install necessary packages including PostgreSQL and Git:
sudo apt install -y postgresql postgresql-contrib git
Step 3: Configure PostgreSQL
Start the PostgreSQL service and enable it to run at startup:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Log in to PostgreSQL and create a user and database for Gitea:
sudo -u postgres psql
CREATE DATABASE gitea;
CREATE USER giteauser WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE gitea TO giteauser;
\q
Replace your_password
with a strong password of your choice.
Step 4: Download Gitea
Download the latest version of Gitea:
wget https://dl.gitea.io/gitea/1.18.1/gitea-1.18.1-linux-amd64
Make the Gitea binary executable:
chmod +x gitea-1.18.1-linux-amd64
sudo mv gitea-1.18.1-linux-amd64 /usr/local/bin/gitea
Step 5: Create Gitea User
Create a dedicated user to run Gitea:
sudo adduser --system --shell /bin/bash --gecos 'Gitea' --group --disabled-password --home /home/git git
Step 6: Create Gitea Directory
Create the necessary directories for Gitea:
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea/
sudo chmod -R 750 /var/lib/gitea/
Step 7: Create Gitea Configuration File
Create a Gitea configuration file:
sudo nano /etc/systemd/system/gitea.service
Add the following configuration:
[Unit]
Description=Gitea
After=network.target
[Service]
User=git
Group=git
WorkingDirectory=/home/git
ExecStart=/usr/local/bin/gitea web
Restart=always
Environment=USER=git HOME=/home/git
[Install]
WantedBy=multi-user.target
Step 8: Start Gitea
Enable and start the Gitea service:
sudo systemctl enable gitea
sudo systemctl start gitea
Step 9: Configure Firewall
If you have a firewall enabled, allow the necessary ports for Gitea:
sudo ufw allow 3000/tcp
sudo ufw reload
Step 10: Access Gitea Web Interface
Now you can access Gitea by navigating to:
http://your_domain.com:3000
Follow the on-screen instructions to complete the setup.
Conclusion
You have successfully installed Gitea with PostgreSQL on Debian 11. This lightweight Git service will help you manage your repositories easily.
If you're looking for a reliable hosting solution for your Gitea installation, consider using Windows VPS UK. With Windows VPS, you can efficiently host your applications and ensure high performance. Whether you need VPS UK Windows or Windows Virtual Private Servers, you'll find a solution that fits your requirements.
For larger deployments or enterprise needs, explore Windows Virtual Dedicated Server Hosting or Virtual Private Server Hosting Windows. Whether you're located in the UK, Italy, or elsewhere, Windows VPS Italy and UK VPS Windows offer reliable hosting options. Visit Windows VPS Hosting UK to discover the best hosting solutions for your development needs.