Skip to content

Hur man installerar en HTTP Git-server med Nginx på Debian 11

Cloud Infrastructure Expert
Hur man installerar en HTTP Git-server med Nginx på Debian 11

 

Följ denna steg-för-steg-guide för att installera en HTTP Git-server på din server som kör Debian 11.

Steg 1: Uppdatera systemet

Innan du installerar programvara är det viktigt att uppdatera systemets paket:

sudo apt update && sudo apt upgrade -y

Steg 2: Installera nödvändiga paket

Installera Git och Nginx:

sudo apt install -y git nginx

Steg 3: Skapa ett Git-repository

Skapa en mapp för dina Git-repositories:

sudo mkdir -p /var/git/myrepo.git
cd /var/git/myrepo.git
sudo git init --bare

Steg 4: Konfigurera Nginx

Skapa en ny Nginx-konfigurationsfil för din Git-server:

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

Lägg till följande konfiguration:

server {
    listen 80;
    server_name your_domain.com;  # Byt ut mot din domän

    location / {
        root /var/git;
        index index.html;
    }

    location ~ \.git {
        deny all;
    }

    location ~ ^/myrepo.git {
        auth_basic "Git Åtkomst";
        auth_basic_user_file /etc/nginx/.htpasswd;
        proxy_pass http://localhost:8080;
    }
}

Aktivera konfigurationen:

sudo ln -s /etc/nginx/sites-available/git /etc/nginx/sites-enabled/

Steg 5: Konfigurera grundläggande autentisering

Installera Apache-verktyg för att skapa lösenordsfilen:

sudo apt install -y apache2-utils

Skapa lösenordsfilen och lägg till en användare:

sudo htpasswd -c /etc/nginx/.htpasswd username

Steg 6: Testa Nginx-konfigurationen

Kontrollera om det finns några fel i Nginx-konfigurationen:

sudo nginx -t

Steg 7: Starta om Nginx

Om testet lyckades, starta om Nginx:

sudo systemctl restart nginx

Steg 8: Klona repositoryt

Nu kan du klona repositoryt med följande kommando:

<co

Windows VPS Deutschland

Windows VPS España

Windows VPS Nederland

Windows VPS Italia

Windows VPS Portugal

VPS Windows Italia

Windows VPS

Windows VPS

Windows VPS Sverige

Windows VPS Norge

Windows VPS

Windows VPS Türkiye

Windows RDS (Remote Desktop Services)

Windows VPS

Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.