installation/nextcloud_itopie.md: [nextcloud] various fixes authored by Luca Capello's avatar Luca Capello
This complements 9966d86754fb355c923936c2242dfa66a4efe42d,
fc62fd65e1db7454e002c3876c218696428113f7 and
c256080bb19370dcede045fcbc9335a76809934e, and fixes
<https://odoo.itopie.ch/web#id=281&action=491&active_id=2&model=project.task&view_type=form&cids=&menu_id=323>.
......@@ -17,7 +17,7 @@
1. Installation des paquets php nécessaires pour Nextcloud \
**NB**, pour vérifier les modules installés : `php -m | grep -i <module_name>`
```
# apt install php8.2-{apcu,bcmath,cli,common,ctype,curl,dom,exif,fpm,ftp,gd,gmp,imagick,imap,intl,ldap,mbstring,pgsql,posix,redis,smbclient,xml,xsl,zip}
# apt install php8.2-{bcmath,cli,common,ctype,curl,dom,exif,fpm,ftp,gd,gmp,imagick,imap,intl,ldap,mbstring,posix,smbclient,xml,xsl,zip}
```
1. Éditer la configuration de PHP FPM : `etc/php/8.x/fpm/php.ini`
- _A modifier_ : **paramètres opcache**, **tiemzone** et **la limite mémoire**.
......@@ -333,22 +333,24 @@
### Installation de PostgreSQL
1. Installer les paquets : `# apt install postgresql postgresql-client`
1. Créer la base de données et l'utilisateur
1. Installer les paquets : `# apt install postgresql postgresql-client php8.2-pgsql`
1. Créer l'utilisateur et la base de données (cf. <https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/linux_database_configuration.html#postgresql-database>) :
```
# sudo -u postgres psql
postgres=# create database nextcloud;
postgres=# create user ncadmin with encrypted password '${ncadmin_DB_PASSWORD}';
postgres=# grant all privileges on database nextcloud to ncadmin;
postgres=# CREATE USER ncadmin
WITH ENCRYPTED PASSWORD '${ncadmin_DB_PASSWORD}';
postgres=# CREATE DATABASE nextcloud
WITH OWNER ncadmin;
postgres=# GRANT ALL PRIVILEGES
ON DATABASE nextcloud
TO ncadmin;
postgres=# exit
#
```
1. Configurer la connexion en socket (et mapping) :
```
# cat <<EOF >>/etc/postgresql/15/main/pg_hba.conf
### Connexion en socket
local nextcloud all ident map=nextcloud
EOF
# sed -i -e '/local all postgres peer/a local nextcloud all ident map=nextcloud' \
/etc/postgresql/15/main/pg_hba.conf
# cat <<EOF >>/etc/postgresql/15/main/pg_ident.conf
nextcloud www-data ncadmin
EOF
......@@ -365,47 +367,93 @@
### Installation de Nextcloud
1. Télécharger et décompresser les fichiers
```
# cd /srv
# wget https://download.nextcloud.com/server/releases/latest-28.tar.bz2
# tar xvf latest-28.tar.bz2
# chown -R www-data:www-data /srv/nextcloud
```
1. Compléter l'installation avec la commande OCC
```
# cd /srv/nextcloud
# sudo -u www-data php occ maintenance:install --database "pgsql" --database-host "localhost:/run/postgresql" --database-name "nextcloud" --database-user "ncadmin" --database-pass "${ncadmin_DB_PASSWORD}" --admin-user "${ADMINUSER}" --admin-pass "${ADMINUSER_PASSWORD}"
Nextcloud was successfully installed
```
1. Corriger la configuration générée
```
# nano /srv/nextcloud/config/config.php
```
- Remplacer localhost par ${WEBSITENAME.TLD}, puis se connecter à Nextcloud via son navigateur\
**ATTENTION**, le data directory se trouve en dehors du dossier racine nextcloud !\
**ATTENTION**, il faut créer les dossiers /run/redis & /srv/nextcloud/apps2 !\
**ATTENTION**, il faut configurer redis pour communiquer en socket !
```
# nano /etc/redis/redis.conf
```
- Ajouter :
```
unixsocket /run/redis/redis.sock
unixsocketperm 775
```
- Changer les permissions des dossiers créés
```
# chown -R redis:www-data /run/redis
```
1. Télécharger et décompresser les fichiers :
```
# cd /srv
# wget https://download.nextcloud.com/server/releases/latest-28.tar.bz2
# wget https://download.nextcloud.com/server/releases/latest-28.tar.bz2.sha512
# sha512sum -c latest-28.tar.bz2.sha512
# tar xvf latest-28.tar.bz2
# chown -R www-data:www-data /srv/nextcloud
```
1. Compléter l'installation avec la commande OCC :
```
# cd /srv/nextcloud
# sudo -u www-data \
php occ maintenance:install --database "pgsql" \
--database-host "localhost:/run/postgresql" \
--database-name "nextcloud" \
--database-user "ncadmin" \
--database-pass "${ncadmin_DB_PASSWORD}" \
--admin-user "${ADMINUSER}" \
--admin-pass "${ADMINUSER_PASSWORD}" \
--admin-email "it@${TLD}"
```
1. Corriger la configuration générée : \
**ATTENTION**, le data directory se trouve en dehors du dossier racine `/srv/nextcloud/`, pourquoi ?
```
# systemctl stop nginx.service
# cd /srv/nextcloud
# mv -i data/ ../nextcloud-data
# sed -i -e "s/\(0 =>\) 'localhost',/\1 '${WEBSITENAME.TLD}',/" \
-e "s/\('datadirectory' =>\) '\/srv\/nextcloud\/data',/\1 '\/srv\/nextcloud-data',/" \
-e "s/\('overwrite.cli.url' =>\) 'http:\/\/localhost',/\1 'http:\/\/${WEBSITENAME.TLD}',/" \
./config/config.php
# systemctl start nginx.service
```
1. Se connecter à l'adresse <https://${WEBSITENAME.TLD}> pour confirmer que tout est OK
#### Installation de Redis et APCu
1. Installer les paquets : `# apt install redis php8.2-apcu php8.2-redis`
1. Stopper le service : `# systemctl stop redis.service`
1. Ajouter l'utilisateur `www-data` au groupe `redis` afin que Nextcloud puisse accéder au socket (cf. <https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#id2>) : \
**ATTENTION**, une meilleure solution serait d'utiliser `systemd-tmpfiles` en ajoutant une ACL pour l'utilisateur `www-data` à la volée quand le socket apparaître !
```
# adduser www-data redis
# systemctl restart php8.2-fpm.service
#
```
# chown -R www-data: /srv/nextcloud/apps2
1. Configurer le logiciel pour communiquer en socket :
```
- Redémarrer le service redis
# cat <<EOF >>/etc/redis/redis.conf
### Nextcloud
include /etc/redis/local_socket.conf
EOF
# cat <<EOF >/etc/redis/local_socket.conf
### Nextcloud
unixsocket /run/redis/redis-server.sock
unixsocketperm 770
EOF
#
```
# systemctl restart redis.service
1. Redémarrer le service : `# systemctl restart redis.service`
1. Configurer Nextcloud pour utiliser Redis et APCu :
```
# cd /srv/nextcloud/
# vi config/config.php
[ajouter à la fin before la dernière ");":
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'redis' =>
array (
'host' => '/run/redis/redis-server.sock',
'port' => 0,
'timeout' => 0.0,
),
]
#
```
- Exemple du fichier config.php :
#### Exemple du fichier `config.php`
**ATTENTION**, pourquoi le besoin d'un deuxième dossier pour les applications, _i.e._ `/srv/nextcloud/apps2` ?
```
<?php
$CONFIG = array (
......@@ -485,15 +533,18 @@
);
```
#### Configuration du cron
```
# nano /etc/cron.d/nextcloud
```
- Ajouter:
```
*/5 * * * * www-data php -f /srv/nextcloud/cron.php
# cat <<EOF >/etc/cron.d/local_nextcloud
### <https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron>
### <https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#id1>
*/5 * * * * root su -s /bin/sh -c 'php -f /srv/nextcloud/cron.php --define apc.enable_cli=1' www-data
EOF
```
### TOTP
- Configurer le TOTP
......
......