Table des matières
Nextcloud dans un conteneur LXC
Article détaillé sur l'installation de nextcloud 17 dans un conteneur lxc.
Je pars d'une Debian Buster.
# lxc-create -t download -n nextcloud -- --dist debian --release buster --arch amd64
Configuration (on rajoute le démarrage automatique) :
# vim /var/lib/lxc/nextcloud/config # cat /var/lib/lxc/nextcloud/config lxc.start.auto = 1 # Distribution configuration lxc.include = /usr/share/lxc/config/common.conf lxc.arch = linux64 # Container specific configuration lxc.rootfs.path = dir:/var/lib/lxc/nextcloud/rootfs lxc.uts.name = nextcloud # Network configuration lxc.net.0.type = veth lxc.net.0.link = lxcbr0 lxc.net.0.flags = up lxc.net.0.hwaddr = 00:16:3e:c8:1b:05
Pour l'IP fixe :
# vim /etc/lxc/dnsmasq.conf (...) dhcp-host=nextcloud,10.0.3.4
On redémarrer le service :
# systemctl restart lxc-net
Et on démarre le conteneur :
# lxc-start nextcloud # lxc-ls -f NAME STATE AUTOSTART GROUPS IPV4 IPV6 UNPRIVILEGED (...) nextcloud RUNNING 1 - 10.0.3.4 - false
Installation des prérequis
# lxc-attach nextcloud root@nextcloud:/# apt install nginx php-fpm mariadb-server wget curl unzip
Script "setup-nextcloud.php"
root@nextcloud:/# mkdir /var/www/nextcloud root@nextcloud:/# cd /var/www/nextcloud root@nextcloud:/var/www/nextcloud# wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
Il faut changer la version de nextcloud dans le script parce que par défaut elle est encore en 16.0.3 à l'heure où j'écris ces lignes.
root@nextcloud:/var/www/nextcloud# vim setup-nextcloud.php (...) // Nextcloud version define('NC_VERSION', '17.0.0'); (...) root@nextcloud:/var/www/nextcloud# cd .. root@nextcloud:/var/www# chown -R www-data:www-data nextcloud/
Il faut configurer nginx pour qu'il pointe sur ce dossier :
root@nextcloud:/var/www# cat /etc/nginx/sites-enabled/default server { listen 80 default_server; root /var/www/nextcloud; # Add index.php to the list if you are using PHP index index.html index.htm index.php; server_name _; location / { try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.3-fpm.sock; } }
On relance nginx :
root@nextcloud:/var/www# systemctl reload nginx
J'ai voulu utiliser le script “setup-nextcloud.php” mais j'ai eu d'abord pas mal de timeout (j'ai augmenté les temps sur le proxy et sur le nginx du container) et puis à la fin j'arrive sur une 404 donc quelque chose se passe mal. Je laisse la procédure pour mémoire :
À installer :
root@nextcloud:/var/www# apt install php-zip php-xml php-curl php-mbstring php-mysql
Création de la DB
root@nextcloud:/var/www# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 36 Server version: 10.3.17-MariaDB-0+deb10u1 Debian 10 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE nextcloud; Query OK, 1 row affected (0.001 sec) MariaDB [(none)]> CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'monGrosPassword'; Query OK, 0 rows affected (0.002 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'monGrosPassword'; Query OK, 0 rows affected (0.002 sec)
Problèmes rencontrés
Problèmes de droits pour MariaDB
J'ai eu un problème avec MariaDD qui ne pouvait pas démarrer parce que le service ne pouvait pas écrire dans “ibdata1” :
root@nextcloud:/var/www# systemctl status mysql ● mariadb.service - MariaDB 10.3.17 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-10-21 16:06:27 UTC; 3min 20s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 11940 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS) Process: 11941 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 11943 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited , status=0/SUCCESS) Process: 11991 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE) Main PID: 11991 (code=exited, status=1/FAILURE) Status: "MariaDB server is down" Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [ERROR] Plugin 'InnoDB' init function returned error. Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [Note] Plugin 'FEEDBACK' is disabled. Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [ERROR] Unknown/unsupported storage engine: InnoDB Oct 21 16:06:27 nextcloud mysqld[11991]: 2019-10-21 16:06:27 0 [ERROR] Aborting (...)
Résolution (source) :
root@nextcloud:/var/www# chown -R mysql /var/lib/mysql/ root@nextcloud:/var/www# chgrp -R mysql /var/lib/mysql/ root@nextcloud:/var/www# ls -alh /var/lib/mysql/ total 109M drwxr-xr-x 4 mysql mysql 4.0K Oct 19 18:32 . drwxr-xr-x 16 root root 4.0K Oct 19 18:32 .. -rw-r----- 1 mysql mysql 16K Oct 19 18:32 aria_log.00000001 -rw-r----- 1 mysql mysql 52 Oct 19 18:32 aria_log_control -rw-r--r-- 1 mysql mysql 0 Oct 19 18:32 debian-10.3.flag -rw-r----- 1 mysql mysql 976 Oct 19 18:32 ib_buffer_pool -rw-r----- 1 mysql mysql 48M Oct 19 18:32 ib_logfile0 -rw-r----- 1 mysql mysql 48M Oct 19 18:32 ib_logfile1 -rw-r----- 1 mysql mysql 12M Oct 19 18:32 ibdata1 -rw-r----- 1 mysql mysql 0 Oct 19 18:32 multi-master.info drwx------ 2 mysql mysql 4.0K Oct 19 18:32 mysql -rw-r----- 1 mysql mysql 16 Oct 19 18:32 mysql_upgrade_info drwx------ 2 mysql mysql 4.0K Oct 19 18:32 performance_schema root@nextcloud:/var/www# systemctl start mysql root@nextcloud:/var/www# systemctl status mysql ● mariadb.service - MariaDB 10.3.17 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2019-10-21 16:13:00 UTC; 2s ago (...)
"Infinite loop" on login
Il y a un problème de droits sur le dossier /var/lib/php/ alors php ne sait pas créer de session :
root@nextcloud:/var/www/nextcloud# chown -R www-data:www-data /var/lib/php/ root@nextcloud:/var/www/nextcloud# ls -al /var/lib/php/sessions/ total 8 drwx--x--t 2 www-data www-data 4096 Oct 19 18:32 . drwxr-xr-x 4 www-data www-data 4096 Oct 19 18:32 ..
Quand on se connecte :
root@nextcloud:/var/www/nextcloud# ls -al /var/lib/php/sessions/ total 8 drwx--x--t 2 www-data www-data 4096 Oct 22 10:00 . drwxr-xr-x 4 www-data www-data 4096 Oct 19 18:32 .. -rw------- 1 www-data www-data 0 Oct 22 10:00 sess_27fb89n013eghaa8k8g0b01lir