« PI GitLab » : différence entre les versions

De knowledge
Aller à la navigation Aller à la recherche
mAucun résumé des modifications
mAucun résumé des modifications
 
Ligne 26 : Ligne 26 :
* '''fcgiwrap''' : un petit démon qui “wrappe” les scripts CGI pour les exécuter via le protocole FastCGI.  → C’est ce qui permet à un serveur web (lighttpd, nginx, Caddy via reverse proxy) de lancer <code>cgit.cgi</code> proprement.
* '''fcgiwrap''' : un petit démon qui “wrappe” les scripts CGI pour les exécuter via le protocole FastCGI.  → C’est ce qui permet à un serveur web (lighttpd, nginx, Caddy via reverse proxy) de lancer <code>cgit.cgi</code> proprement.
* '''spawn-fcgi''' : un utilitaire pour démarrer <code>fcgiwrap</code> facilement (en créant un socket Unix ou TCP).
* '''spawn-fcgi''' : un utilitaire pour démarrer <code>fcgiwrap</code> facilement (en créant un socket Unix ou TCP).
==== Config de fcgiwrap ====
Créer une fichier <code>fcgiwrap.service</code> :<syntaxhighlight lang="ini">
[Unit]
Description=fcgiwrap FastCGI server
After=network.target
[Service]
ExecStart=/usr/bin/spawn-fcgi -s /var/run/fcgiwrap.socket -M 0660 -u www-data -g www-data /usr/sbin/fcgiwrap
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
</syntaxhighlight>Et utiliser le fichier d'installation install.sh :<syntaxhighlight lang="bash">
#!/bin/bash
sudo cp fcgiwrap.service /etc/systemd/system/.
sudo systemctl daemon-reload
sudo systemctl enable fcgiwrap.service
sudo systemctl start fcgiwrap.service
</syntaxhighlight>l'installation donne :<syntaxhighlight lang="text">
Synchronizing state of fcgiwrap.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable fcgiwrap
Created symlink '/etc/systemd/system/multi-user.target.wants/fcgiwrap.service' → '/etc/systemd/system/fcgiwrap.service'.
</syntaxhighlight>Et on peut vérifier par :<syntaxhighlight lang="bash">
systemctl status fcgiwrap.service
</syntaxhighlight>Qui nous réponds par un beau:
[[Fichier:Fcgiwrap.socket.status.png|sans_cadre|569x569px]]
J'ai pas pu résister à mettre une jolie copie d'écran avec du vert partout.
On a GIT installé sur le serveur et on a fcgi qui propose un acces a git en cgi-bin. Il faut maintenant installer un serveur http pour gérer le lien http avec le programme CGI.
==== Installation lighthttp ====
<syntaxhighlight lang="bash">
sudo apt install -y lighttpd
sudo lighttpd-enable-mod fastcgi
</syntaxhighlight>L'installation se fait normalement et ensuite le module fastcgi est activé:<syntaxhighlight lang="text">
Enabling fastcgi: ok
Run "service lighttpd force-reload" to enable changes
</syntaxhighlight>
==== Connexion avec cgit. ====
On modifie /etc/lighttpd/lighttpd.conf :
Dans les modules on doit trouver :<syntaxhighlight lang="text">
server.modules = (
        "mod_indexfile",
        "mod_access",
        "mod_alias",
        "mod_redirect",
        "mod_fastcgi"
)
</syntaxhighlight>et la définition du serveur :<syntaxhighlight>
server.document-root        = "/usr/share/cgit"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog            = "/var/log/lighttpd/error.log"
server.pid-file            = "/run/lighttpd.pid"
server.username            = "www-data"
server.groupname            = "www-data"
server.port                = 8080
</syntaxhighlight>Dans <code>/etc/lighttpd/conf-available</code> on crée 50-cgit.conf :<syntaxhighlight lang="text">
# Activer les modules nécessaires (en extension, pas en redéfinition)
server.modules += ( "mod_fastcgi", "mod_alias" )
# Déclarer cgit via FastCGI (socket systemd fcgiwrap)
# On mappe l'URL /cgit vers le CGI cgit.cgi
fastcgi.server += ( "/cgit" =>
  ((
    "socket"      => "/run/fcgiwrap.socket",
    "bin-path"    => "/usr/lib/cgit/cgit.cgi",
    "check-local"  => "disable",
    "mode"        => "responder"
  ))
)
# Servir les assets CSS / logo
alias.url += ( "/cgit-css/" => "/usr/share/cgit/" )
# Permettre que cgit soit servi comme page d'index
index-file.names += ( "cgit.cgi" )
</syntaxhighlight>On active le fichier de conf :<syntaxhighlight lang="bash">
sudo lighttpd-enable-mod cgit
</syntaxhighlight>On vérifie la syntaxe:<syntaxhighlight lang="bash">
sudo lighttpd -t -f /etc/lighttpd/lighttpd.conf
</syntaxhighlight>Qui doit nous répondre : <code>Syntax OK</code>
On crée le répertoire :<syntaxhighlight lang="bash">
sudo mkdir -p /srv/git
sudo chown -R www-data:www-data /srv/git
sudo mkdir -p /var/log/lighttpd
sudo chown www-data:www-data /var/log/lighttpd
</syntaxhighlight>Et on redémarre lighthttpd:<syntaxhighlight lang="bash">
sudo systemctl restart lighttpd
</syntaxhighlight>Et on teste:

Version actuelle datée du 26 décembre 2025 à 12:55

Installation

La base

On crée une carte standard avec Raspberry Pi Imager (Dernière version sans desktop et en activant l'acces ssh).

Plus un petit :

sudo apt update
sudo apt upgrade

Pour rattraper le retard de l'image sur le dépots.

Ensuite un sudo raspi-config pour :

  • Activer l'autologin que l'on utilisera en urgence si le frontal plante ou si on a oublie le mot de passe.
  • Le "expand file system" être sur de ne rien perdre.

On lui ajoute une adresse IP fixe sur le routeur : IP FIXE.

La partie spécifique

On commence par la base:

sudo apt install -y git 
sudo apt install -y cgit
sudo apt install -y fcgiwrap spawn-fcgi
  • fcgiwrap : un petit démon qui “wrappe” les scripts CGI pour les exécuter via le protocole FastCGI. → C’est ce qui permet à un serveur web (lighttpd, nginx, Caddy via reverse proxy) de lancer cgit.cgi proprement.
  • spawn-fcgi : un utilitaire pour démarrer fcgiwrap facilement (en créant un socket Unix ou TCP).

Config de fcgiwrap

Créer une fichier fcgiwrap.service :

[Unit]
Description=fcgiwrap FastCGI server
After=network.target

[Service]
ExecStart=/usr/bin/spawn-fcgi -s /var/run/fcgiwrap.socket -M 0660 -u www-data -g www-data /usr/sbin/fcgiwrap
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

Et utiliser le fichier d'installation install.sh :

#!/bin/bash
sudo cp fcgiwrap.service /etc/systemd/system/.
sudo systemctl daemon-reload
sudo systemctl enable fcgiwrap.service
sudo systemctl start fcgiwrap.service

l'installation donne :

Synchronizing state of fcgiwrap.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable fcgiwrap
Created symlink '/etc/systemd/system/multi-user.target.wants/fcgiwrap.service' → '/etc/systemd/system/fcgiwrap.service'.

Et on peut vérifier par :

systemctl status fcgiwrap.service

Qui nous réponds par un beau:

Fcgiwrap.socket.status.png

J'ai pas pu résister à mettre une jolie copie d'écran avec du vert partout.

On a GIT installé sur le serveur et on a fcgi qui propose un acces a git en cgi-bin. Il faut maintenant installer un serveur http pour gérer le lien http avec le programme CGI.

Installation lighthttp

sudo apt install -y lighttpd
sudo lighttpd-enable-mod fastcgi

L'installation se fait normalement et ensuite le module fastcgi est activé:

Enabling fastcgi: ok
Run "service lighttpd force-reload" to enable changes

Connexion avec cgit.

On modifie /etc/lighttpd/lighttpd.conf :

Dans les modules on doit trouver :

server.modules = (
        "mod_indexfile",
        "mod_access",
        "mod_alias",
        "mod_redirect",
        "mod_fastcgi"
)

et la définition du serveur :

server.document-root        = "/usr/share/cgit"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 8080

Dans /etc/lighttpd/conf-available on crée 50-cgit.conf :

# Activer les modules nécessaires (en extension, pas en redéfinition)
server.modules += ( "mod_fastcgi", "mod_alias" )

# Déclarer cgit via FastCGI (socket systemd fcgiwrap)
# On mappe l'URL /cgit vers le CGI cgit.cgi
fastcgi.server += ( "/cgit" =>
  ((
    "socket"       => "/run/fcgiwrap.socket",
    "bin-path"     => "/usr/lib/cgit/cgit.cgi",
    "check-local"  => "disable",
    "mode"         => "responder"
  ))
)

# Servir les assets CSS / logo
alias.url += ( "/cgit-css/" => "/usr/share/cgit/" )

# Permettre que cgit soit servi comme page d'index
index-file.names += ( "cgit.cgi" )

On active le fichier de conf :

sudo lighttpd-enable-mod cgit

On vérifie la syntaxe:

sudo lighttpd -t -f /etc/lighttpd/lighttpd.conf

Qui doit nous répondre : Syntax OK On crée le répertoire :

sudo mkdir -p /srv/git
sudo chown -R www-data:www-data /srv/git


sudo mkdir -p /var/log/lighttpd
sudo chown www-data:www-data /var/log/lighttpd

Et on redémarre lighthttpd:

sudo systemctl restart lighttpd

Et on teste: