Outils pour utilisateurs

Outils du site


nextcloud_dans_lxc

Ceci est une ancienne révision du document !


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

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

Il n'y a plus qu'à se rendre sur l'url qu'on a fait pointer sur le conteneur : https://(...)/setup-nextcloud.php

Le script renseigne quelques dépendances manquantes.

Dependencies not found.
The following PHP modules are required to use Nextcloud:
zip
dom
XMLWriter
libxml
mb multibyte
GD
SimpleXML
curl

À installer :

root@nextcloud:/var/www# apt install php-zip php-xml php-curl php-mbstring php-mysql

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
nextcloud_dans_lxc.1571674545.txt.gz · Dernière modification : 2020/08/09 12:59 (modification externe)