403 lines
9.3 KiB
Markdown
403 lines
9.3 KiB
Markdown
# 🔽 Nextcloud — Plateforme open source auto-hébergée de stockage, partage de fichiers et collaboration.
|
||
|
||
>- Documentation officielle => https://docs.nextcloud.com/server/latest/admin_manual/
|
||
>- Dépot GitHub => https://github.com/nextcloud/server
|
||
|
||
# :one: Installation Nextcloud sur Debian 12
|
||
|
||
## Notes de versions :
|
||
- Debian 12
|
||
- MariaDB 11.8
|
||
- Apache 2.4.66
|
||
- PHP 8.4
|
||
|
||
> ⚠️ Attention les credentials inscrit dans la procédure sont seulement à titre d'exemple, pensez à les modifier !!
|
||
|
||
## 1. Installation des paquets
|
||
|
||
1.1 Mise à jour liste des paquets et paquets
|
||
```
|
||
apt update && apt upgrade
|
||
```
|
||
|
||
|
||
1.2 Installation des paquets préalable (*non nécessaire depuis Debian 13*)
|
||
```
|
||
apt install ca-certificates apt-transport-https curl
|
||
```
|
||
|
||
|
||
1.3 Inscription du dépot pour MariaDB 11.8 (*non nécessaire depuis Debian 13*)
|
||
```
|
||
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-11.8"
|
||
```
|
||
|
||
|
||
1.4 Inscription du dépot pour PHP 8.4 (*non nécessaire depuis Debian 13*)
|
||
```
|
||
wget -O /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg`
|
||
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" \
|
||
> /etc/apt/sources.list.d/php.list' && apt update
|
||
```
|
||
|
||
|
||
1.5 Installation paquets (Apache2, MariaDB et PHP 8.4)
|
||
```
|
||
apt install apache2 mariadb-server php8.4 php8.4-common php8.4-curl php8.4-gd php8.4-intl php8.4-mbstring php8.4-xmlrpc php8.4-mysql php8.4-xml php8.4-cli php8.4-zip
|
||
```
|
||
|
||
|
||
1.6 Redémarrer le service apache
|
||
```
|
||
systemctl restart apache2
|
||
```
|
||
|
||
|
||
1.7 Contrôler que PHP 8.4 soit bien actif dans Apache2
|
||
```
|
||
a2enmod php8.4` résultat attendu `Module php8.4 already enabled
|
||
```
|
||
|
||
|
||
1.8 Activer l'extension PHP gd
|
||
```
|
||
phpenmod gd
|
||
```
|
||
|
||
|
||
1.9 Installation paquets (wget et unzip)
|
||
```
|
||
apt install wget unzip
|
||
```
|
||
|
||
|
||
## 2. Mise en place des sources
|
||
|
||
2.1 Télécharger la dernière version de Nextcloud depuis la source officielle
|
||
```
|
||
wget https://download.nextcloud.com/server/releases/latest.zip
|
||
```
|
||
|
||
|
||
2.2 Décompresser l'archive
|
||
```
|
||
unzip latest.zip
|
||
```
|
||
|
||
|
||
2.3 Déplacer le dossier extrait dans le répertoire "html"
|
||
```
|
||
mv nextcloud /var/www/html/
|
||
```
|
||
|
||
|
||
2.4 Définir Apache2 comme propriétaire du dossier nextcloud
|
||
```
|
||
chown -R www-data:www-data /var/www/html/nextcloud
|
||
```
|
||
|
||
|
||
## 3. Création de la base de données
|
||
|
||
3.1 Exécuter la procédure d'installation
|
||
```
|
||
mariadb-secure-installation
|
||
```
|
||
- Enter current password for root (enter for none): `taper touche entrée`
|
||
- Switch to unix_socket authentication [Y/n] `n`
|
||
- Change the root password? [Y/n] `Y`
|
||
- New password: `DefinePassword`
|
||
- Re-enter new password: `DefinePassword`
|
||
- Remove anonymous users? [Y/n] `y`
|
||
- Disallow root login remotely? [Y/n] `y`
|
||
- Remove test database and access to it? [Y/n] `y`
|
||
- Reload privilege tables now? [Y/n] `y`
|
||
Résultat attendu : All done! ... Thanks for using MariaDB!
|
||
|
||
|
||
3.2 Contrôler la version de MariaDB
|
||
```
|
||
mariadb -V
|
||
```
|
||
|
||
|
||
3.3 Se connecter à la db (pass root défini plus tôt DefinePassword)
|
||
```
|
||
mariadb -u root -p
|
||
```
|
||
|
||
|
||
3.4 Créer base de données (nom = dbnextcloud)
|
||
```
|
||
CREATE DATABASE dbnextcloud;
|
||
```
|
||
|
||
|
||
3.5 Créer utilisateur et lui octroyer les droits (user = usrnextcloud ; pass = Nextcloud13)
|
||
```
|
||
GRANT ALL ON dbnextcloud.* TO 'usrnextcloud'@'localhost' IDENTIFIED BY 'Nextcloud13';
|
||
```
|
||
|
||
|
||
3.6 Mise à jour des droits
|
||
```
|
||
FLUSH PRIVILEGES;
|
||
```
|
||
|
||
|
||
3.7 Quitter l'instance MariaDB
|
||
```
|
||
EXIT;
|
||
```
|
||
|
||
|
||
3.8 Contrôler la db
|
||
- Se connecter à MariaDB
|
||
```
|
||
mariadb -u root -p
|
||
```
|
||
- Afficher la db
|
||
```
|
||
show databases;
|
||
```
|
||
- Quitter
|
||
```
|
||
exit
|
||
```
|
||
|
||
|
||
## 4. Configuration de Nextcloud
|
||
|
||
4.1 Accéder à l'interface web de Nextcloud
|
||
```
|
||
http://ip.address.of.server/nextcloud
|
||
```
|
||
|
||
|
||
4.2 Créer l'utilisateur principal de Nextcloud
|
||
- User admin `AdminPrincipal`
|
||
- Pass admin `PassAdminPrincipal`
|
||
- User db `usrnextcloud`
|
||
- Pass db `Nextcloud13`
|
||
- Nom db `dbnextcloud`
|
||
- Hote db `localhost`
|
||
- Cliquer sur Install
|
||
|
||
|
||
4.3 Configurer le nom de domaine
|
||
> Par défaut Nextcloud permet d'accéder à sa webui uniquement via l'adresse ip du serveur
|
||
- Editer le fichier `/var/www/html/nextcloud/config/config.php` afin d'y renseigner le domaine associé (voir exemple `config/config.sample.php`)
|
||
```
|
||
'trusted_domains' =>
|
||
array (
|
||
0 => 'localhost',
|
||
1 => 'ip.address.of.server',
|
||
2 => 'my-domain.com',
|
||
3 => 'hostname'
|
||
),
|
||
```
|
||
|
||
|
||
## 5. Sécurité & renforcement
|
||
|
||
5.1 Connexion HTTPS
|
||
5.1.1 Déplacer les éléments de certificats
|
||
- Certificat public signé `/etc/ssl/certs/hostname.crt`
|
||
- Clé privé secrète `/etc/ssl/private/hostname.key`
|
||
- Conteneur texte base64 `/etc/ssl/certs/hostname.pem` (obsolète à partir de Apache 2.4.8)
|
||
|
||
|
||
5.1.2 Configurer les droits
|
||
```
|
||
chmod 600 /etc/ssl/private/hostname.key
|
||
chown root:root /etc/ssl/private/hostname.key
|
||
```
|
||
|
||
|
||
5.1.3 Editer le fichier `/etc/apache2/sites-available/nextcloud.conf`
|
||
```
|
||
<VirtualHost *:443>
|
||
DocumentRoot /var/www/html/nextcloud
|
||
ServerName hostname.domain.com
|
||
SSLEngine on
|
||
SSLCertificateFile /etc/ssl/certs/hostname.crt
|
||
SSLCertificateKeyFile /etc/ssl/private/hostname.key
|
||
SSLCertificateChainFile /etc/ssl/certs/hostname.pem
|
||
</VirtualHost>
|
||
```
|
||
|
||
|
||
5.1.4 Appliquer la configuration
|
||
```
|
||
a2enmod ssl rewrite headers
|
||
a2dissite 000-default.conf
|
||
a2ensite nextcloud.conf
|
||
apache2ctl configtest
|
||
systemctl restart apache2
|
||
```
|
||
|
||
|
||
5.2 Optimisations performance
|
||
Editer `/etc/php/8.4/cli/php.ini` et `/etc/php/8.4/apache2/php.ini`
|
||
- Limite de mémoire RAM pour PHP 
|
||
```
|
||
memory_limit = 512M
|
||
```
|
||
|
||
- Cache PHP de sortie 
|
||
```
|
||
output_buffering = off
|
||
```
|
||
|
||
- Taille du stockage des chaines internées 
|
||
```
|
||
opcache.interned_strings_buffer=10
|
||
```
|
||
|
||
## 6. Personnalisation des settings
|
||
|
||
6.1 Modifier les presets de quota utilisateurs
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ config:app:set files quota_preset --value="2 GB, 5 GB, 10 GB, 50 GB, 100 GB, 500 GB, 1 TB"
|
||
```
|
||
|
||
6.2 Réglage de la rétention du versionning `auto = gestion auto. par Nextcloud ; 7 = suppression après 7 jours`
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ config:system:set versions_retention_obligation --value="auto, 7"
|
||
```
|
||
|
||
6.3 Réglage de la rétention de la corbeille `7 = garder min. 7 jours ; 30 = garder max. 30 jours`
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ config:system:set trashbin_retention_obligation --value="7, 30"
|
||
|
||
```
|
||
|
||
## 7. Maintenance
|
||
|
||
7.1 Purger les versions et élément dans la corbeille déjà existant avec les nouvelles règles
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ versions:expire
|
||
sudo -u www-data php /var/www/html/nextcloud/occ trashbin:expire
|
||
```
|
||
|
||
7.2 Vider la corbeille `--all-users / NameUser / NameUser1 NameUser2`
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ trashbin:cleanup --all-users
|
||
```
|
||
|
||
7.3 Afficher la config occ active, ajouter `--private` pour afficher en clair les id/pass
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ config:list system
|
||
```
|
||
|
||
---
|
||
---
|
||
|
||
# :two: Montage des volumes
|
||
|
||
## 1. Dossier partagé SMB/CIFS
|
||
|
||
1.1 Installer les paquets necessaires
|
||
```
|
||
sudo apt update
|
||
sudo apt install cifs-utils
|
||
```
|
||
|
||
1.2 Créer le point de montage
|
||
```
|
||
sudo mkdir -p /mnt/files_versions
|
||
```
|
||
|
||
1.3 Montage manuel (test rapide)
|
||
```
|
||
sudo mount -t cifs //ip.address.of.server/files_versions /mnt/files_versions -o username=utilisateur,uid=33,gid=33
|
||
```
|
||
|
||
1.4 Stocker les identifiants de façon sécurisée
|
||
```
|
||
sudo nano /etc/smb/credentials
|
||
```
|
||
```
|
||
username=NameUser
|
||
password=PassUser
|
||
```
|
||
|
||
1.5 Sécuriser le fichier credentials
|
||
```
|
||
sudo chmod 600 /etc/smb/credentials
|
||
sudo chown root:root /etc/smb/credentials
|
||
```
|
||
|
||
1.6 Montage automatique au démarrage via `fstab`
|
||
```
|
||
sudo nano /etc/fstab
|
||
```
|
||
```
|
||
//ip.address.of.server/files_versions /mnt/files_versions cifs credentials=/etc/smb/credentials,uid=33,gid=33,iocharset=utf8,_netdev,nofail,rw 0 0
|
||
# Possibilité d'ajouter les options `file_mode=0777,dir_mode=0777` pour débogage
|
||
# uid et gid de "www-data"
|
||
```
|
||
|
||
1.7 Appliquer la configuration
|
||
```
|
||
sudo systemctl daemon-reload
|
||
sudo mount -a
|
||
```
|
||
|
||
1.8 Contrôles
|
||
```
|
||
dh -h
|
||
```
|
||
|
||
1.9 Test d'écriture dans le dossier partagé avec l'utilisateur www-data
|
||
```
|
||
sudo -u www-data touch /mnt/files_versions/test.tmp
|
||
```
|
||
|
||
## 2. Bind du dossier de versionning
|
||
|
||
2.1 Définir le versionning à partager `/var/www/html/nextcloud/data/<USER>/files_versions`
|
||
|
||
2.2 Définir le répertoire de montage `/mnt/files_versions/<USER>`
|
||
|
||
2.3 Mettre les droits sur le repertoire de montage
|
||
```
|
||
chown -R www-data:www-data /mnt/files_versions/<USER>
|
||
chmod -R 750 /mnt/files_versions/<USER>
|
||
```
|
||
|
||
2.4 Montage manuel (test rapide)
|
||
```
|
||
mount --bind /mnt/files_versions/<USER> /var/www/html/nextcloud/data/<USER>/files_versions
|
||
```
|
||
|
||
2.5 Editer le fstab
|
||
```
|
||
/mnt/files_versions/<USER> /var/www/html/nextcloud/data/<USER>/files_versions none bind,nofail,x-systemd.requires=/mnt/file_versions 0 0
|
||
```
|
||
|
||
|
||
|
||
|
||
## 🚧 Diagnostic
|
||
- Afficher la version de PHP utilisée
|
||
```
|
||
sudo -u www-data php --version
|
||
```
|
||
|
||
- Afficher l'emplacement du fichier de configuration utilisé
|
||
```
|
||
sudo -u www-data php -i | grep "Loaded Configuration File"
|
||
```
|
||
|
||
- Afficher la version de Nextcloud
|
||
```
|
||
sudo -u www-data php /var/www/html/nextcloud/occ -V
|
||
```
|
||
|
||
- Redémarrer le service apache2
|
||
```
|
||
systemctl restart apache2 && apache2ctl restart
|
||
```
|
||
|
||
|