Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
floss:config_ubuntu_server_rpi3 [2020/02/15 13:16] – villersd | floss:config_ubuntu_server_rpi3 [2024/04/16 09:34] (Version actuelle) – villersd | ||
---|---|---|---|
Ligne 7: | Ligne 7: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * janvier 2024 : The simplest way is to use the [[https:// | ||
+ | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[: | ||
+ | * liens adaptés pour Ubuntu 22.04.3 : | ||
+ | * [[https:// | ||
+ | |||
+ | ===== Installation ===== | ||
+ | * démarrer le Raspberry Pi 3 avec la carte flashée préalablement | ||
+ | * user : ubuntu | ||
+ | * mdp : ubuntu (à modifier dès le 1er démarrage !!) | ||
+ | * relever l'IP du serveur par la commande "ip a" (le clavier peut être qwerty) | ||
+ | * Connexion à partir d'une autre machine : ssh ubuntu@ip_adress (remplacer ip_adress par la valeur relevée) | ||
+ | * Clé SSH | ||
+ | * générer sur le PC connecté une paire de clés privée/ | ||
+ | * copier la clé publique sur le serveur | ||
+ | * ssh-copy-id -i ~/ | ||
+ | * tester la connexion qui doit fonctionner sans mdp : ssh ubuntu@ip_adress | ||
+ | * mises à jour : | ||
+ | * sudo apt-get update | ||
+ | * sudo apt-get upgrade | ||
+ | * redémarrage : sudo reboot | ||
+ | * arrêt : sudo halt | ||
+ | * Utiliser/ | ||
+ | * [[wp> | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | <code yaml 50-cloud-init.yaml> | ||
+ | # / | ||
+ | network: | ||
+ | ethernets: | ||
+ | eth0: | ||
+ | dhcp4: true | ||
+ | optional: true | ||
+ | version: 2 | ||
+ | # wifi setup informations | ||
+ | wifis: | ||
+ | wlan0: | ||
+ | optional: true | ||
+ | access-points: | ||
+ | " | ||
+ | password: " | ||
+ | dhcp4: no | ||
+ | addresses: [192.168.1.251/ | ||
+ | gateway4: 192.168.1.1 | ||
+ | nameservers: | ||
+ | addresses: [192.168.1.1, | ||
+ | |||
+ | </ | ||
+ | |||
+ | À ce stade, le Raspberry Pi est connecté par wifi avec l' | ||
+ | |||
+ | * Installation du serveur LA(M)P sur base de [[config_ubuntu_server]] | ||
+ | * [[https:// | ||
+ | * **sudo apt install apache2** | ||
+ | * test du serveur apache : [[http:// | ||
+ | * **sudo apt install php libapache2-mod-php** | ||
+ | * **sudo nano / | ||
+ | * La configuration de PHP se fait via un fichier php.ini localisé sous Focal Fossa (Ubuntu 20.04) ici : / | ||
+ | * Paquets PHP souvent utiles (des modules additionnels pourront être installés en fonction des logiciels installés sur le serveur ainsi que leurs extensions/ | ||
+ | * **sudo apt install php-curl php-gd php-intl php-json php-mbstring php-xml php-zip** | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * ajouter l' | ||
+ | |||
+ | ==== Compléments d' | ||
+ | |||
+ | * [[https:// | ||
+ | * **sudo apt install msmtp msmtp-mta** | ||
+ | * Configuration pour l' | ||
+ | * vérification (doc.ubuntu-fr) ls -la / | ||
+ | * test : echo ' | ||
+ | |||
+ | <note tip> | ||
+ | |||
+ | * [[http:// | ||
+ | * **sudo a2enmod rewrite** | ||
+ | * **sudo systemctl restart apache2** | ||
+ | * Paquets additionnels (options) : | ||
+ | * **sudo apt-get install unison** (FIXME : compatibilité avec 18.04) | ||
+ | |||
+ | ==== Ajustement de la timezone ==== | ||
+ | * réf : [[https:// | ||
+ | * ls -l / | ||
+ | * timedatectl | ||
+ | * sudo unlink / | ||
+ | * sudo ln -s / | ||
+ | * ls -l / | ||
+ | * timedatectl | ||
+ | |||
+ | ==== Installation type sur un serveur LA(M)P : DokuWiki ===== | ||
+ | * cf. [[dokuwiki|DokuWiki]] | ||
+ | * Connexion et identification sur le serveur : ssh username@dns or username@ip_address (ou via les paramètres de PuTTY); | ||
+ | * se placer dans le répertoire web : **cd / | ||
+ | * créer un répertoire pour le wiki : **sudo mkdir wiki00** | ||
+ | * s’y placer : **cd wiki00** | ||
+ | * télécharger la dernière version de DokuWiki : **sudo wget https:// | ||
+ | * décompresser l’archive : **< | ||
+ | * effacer l’archive : **sudo rm dokuwiki-stable.tgz** | ||
+ | * owner & permissions ([[https:// | ||
+ | * **sudo chown -R www-data: | ||
+ | * **cd / | ||
+ | * fichiers : **sudo find . ! -type d -exec chmod 660 {} \;** | ||
+ | * répertoires : **sudo find . -type d -exec chmod 770 {} \;** | ||
+ | * on peut à présent régler la configuration de base de DokuWiki via un navigateur web, en pointant sur [[http:// | ||
+ | * **Wiki Name** | ||
+ | * **Enable ACL** | ||
+ | * **Superuser** | ||
+ | * **Full Name** | ||
+ | * **E-Mail** | ||
+ | * **Password** | ||
+ | * **Once Again** | ||
+ | * **Initial ACL policy** | ||
+ | * **Allow users to register themselves** | ||
+ | * **sudo rm install.php** (effacement du script d' | ||
+ | |||
+ | Le wiki est pré-configuré et (presque) opérationnel ! Réglages complémentaires de la configuration via le menu d’administration - " | ||
+ | * choisir la langue de l’interface language fr | ||
+ | * mode de création des répertoires : choisir 02770 (au lieu de 0755) (set gid, cf. [[http:// | ||
+ | * mode de création des fichiers : choisir 0660 (au lieu de 0644) | ||
+ | * Dans les paramètres d’authentification, | ||
+ | * pour le délai avant indexation (paramètres anti-spam), vous pouvez vous contenter de 60*5 plutôt que 60*60*24*5, qui contraint à une attente de 24H après édition, avant que l’indexation par un robot de moteur de recherche ne redevienne possible | ||
+ | * Si comme administrateur vous souhaitez être averti à chaque modification effectuée par un autre utilisateur, | ||
+ | * ensuite, vous pouvez aussi activer l’abonnement aux pages, ce qui aura pour effet de générer un envoi par email notifiant la modification. Le délai peut être réglé par l’option suivante (“Délai après lequel les listes d’abonnement …”) | ||
+ | * Mentionner dans ce dernier cas l’expéditeur des notifications par courriel du wiki (paramètres avancés) | ||
+ | |||
+ | ===== Exploitation ===== | ||
+ | * mises à jour : | ||
+ | * sudo apt-get update | ||
+ | * sudo apt-get upgrade | ||
+ | * sudo apt-get dist-upgrade | ||
+ | * [[https:// | ||
+ | * erreurs disques : enlever la carte mémoire, la placer dans un lecteur de carte microSD sur un autre ordinateur, et tenter la correction via ces deux commandes : | ||
+ | * < | ||
+ | * < | ||
+ | |||
+ | |||
+ | ==== Dispositif USB externe ==== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * une clé USB insérée dans un PC → ligne finale de /etc/mtab : | ||
+ | * /dev/sdg1 / | ||
+ | * la commande "ls -l / | ||
+ | * La même clé USB dans le Raspberry, permettant de détecter la chaîne " | ||
+ | * la commande "ls -l / | ||
+ | * création du point de montage : | ||
+ | * sudo mkdir /media/usb | ||
+ | * propriétaire et droits (ajuster l' | ||
+ | * sudo chown -R pi:pi /media/usb | ||
+ | * test du montage et démontage en mode manuel (ajuster l' | ||
+ | * sudo mount /dev/sda1 /media/usb -o uid=pi, | ||
+ | * cd /media/usb | ||
+ | * ls | ||
+ | * sudo umount /media/usb | ||
+ | * montage récurrent : ajouter une ligne à la fin du fichier /etc/fstab (ajuster l' | ||
+ | * sudo nano /etc/fstab | ||
+ | * UUID=0133-98D2 /media/usb vfat auto, | ||
+ | * redémarrer : sudo reboot | ||
+ | |||
+ | ==== Script de sauvegarde et automatisation via crontab ==== | ||
+ | |||
+ | === Script de sauvegarde === | ||
+ | * → ajuster l' | ||
+ | * Backup sur l' | ||
+ | * Le script bash backup.sh doit être exécutable. Après sa création, il faudra exécuter "chmod +x backup.sh" | ||
+ | * doc : | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * Création d'un lien symbolique : | ||
+ | * ln -s / | ||
+ | |||
+ | <code backup.sh> | ||
+ | #!/bin/bash | ||
+ | THESITE=" | ||
+ | THEDB=" | ||
+ | THEDBUSER=" | ||
+ | THEDBPW=" | ||
+ | THEDATE=`date +%F-%T` | ||
+ | # backup de la base de données NON UTILISÉ | ||
+ | #mysqldump -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > ~/ | ||
+ | # backup des fichiers du site | ||
+ | #tar -czf ~/ | ||
+ | tar -czf / | ||
+ | # éliminer les fichier vieux de plus de 5 jours | ||
+ | find ~/ | ||
+ | find ~/ | ||
+ | </ | ||
+ | |||
+ | Version après élimination d' | ||
+ | |||
+ | <code backup.sh> | ||
+ | #!/bin/sh | ||
+ | THESITE=" | ||
+ | THEDATE=`date +%F-%H%M%S` | ||
+ | # backup des fichiers du site | ||
+ | tar -czf / | ||
+ | </ | ||
+ | |||
+ | Test du backup : | ||
+ | < | ||
+ | ./backup.sh | ||
+ | </ | ||
+ | |||
+ | Part of bash (version >=4.2) script to remove files in a given directory, older than 8 days, but leave files dated the first day of each month : | ||
+ | |||
+ | < | ||
+ | # Set the directory to clean up | ||
+ | DIR=" | ||
+ | |||
+ | # Calculate the cutoff date | ||
+ | CUTOFF=$(date -d "8 days ago" +%s) | ||
+ | |||
+ | # Loop through the files in the directory | ||
+ | for FILE in " | ||
+ | do | ||
+ | # Check if the file is older than 8 days | ||
+ | if [[ -f " | ||
+ | then | ||
+ | # Check if the file's date is the first day of the month | ||
+ | if [[ $(date -r " | ||
+ | then | ||
+ | echo " | ||
+ | else | ||
+ | echo " | ||
+ | rm " | ||
+ | fi | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | </ | ||
+ | |||
+ | Here's how the script works: | ||
+ | - Set the DIR variable to the directory you want to clean up. | ||
+ | - Use the date command to calculate the cutoff date. This will be 8 days ago from today. | ||
+ | - Loop through each file in the directory using a for loop. | ||
+ | - Check if the file is a regular file (-f) and if its modification time is older than the cutoff date. If it is not, then skip to the next file. | ||
+ | - If the file's modification time is older than the cutoff date, check if the file's date is the first day of the month. If it is, then skip to the next file. | ||
+ | - If the file's date is not the first day of the month, then delete the file using the rm command. | ||
+ | |||
+ | Références sur les formats de date : | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | Références sur les scripts de backup | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | ==== Configuration de base du DokuWiki ==== | ||
+ | * Extensions et gestion système | ||
+ | * upgrade plugin | ||
+ | |||