« NextCloud » : différence entre les versions
| Ligne 213 : | Ligne 213 : | ||
); | ); | ||
==== Memcache via Redis & APCu ==== | ==== Memcache via Redis & APCu ==== | ||
[https://bayton.org/docs/nextcloud/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-ssl-apache/#4-1-update-the-server-install-lamp-apcu-redis source] | |||
# apt install redis-server php-redis php-apcu | # apt install redis-server php-redis php-apcu | ||
# vi /etc/redis/redis.conf | # vi /etc/redis/redis.conf | ||
| Ligne 226 : | Ligne 227 : | ||
Enfin, on édite Nextcloud pour utiliser Redis : | Enfin, on édite Nextcloud pour utiliser Redis : | ||
# vi /var/www/nextcloud/config/config.php | # vi /var/www/nextcloud/config/config.php | ||
... | |||
'default_phone_region' => 'FR', | |||
<font color = green>'memcache.local' => '\OC\Memcache\APCu', | |||
'memcache.locking' => '\OC\Memcache\Redis', | |||
'memcache.distributed' => '\OC\Memcache\Redis', | |||
'redis' => [ | |||
'host' => '/var/run/redis/redis-server.sock', | |||
'port' => 0, | |||
'timeout' => 1.5, | |||
],</font> | |||
); | |||
Version du 13 avril 2021 à 18:26
LXC Ubuntu 20.04
Installation Serveur
# apt update && apt upgrade
Archive NextCloud
# apt install unzip # cd /tmp/ # wget https://download.nextcloud.com/server/releases/nextcloud-21.0.1.zip # unzip nextcloud-21.0.1.zip -d /var/www/ # rm nextcloud-21.0.1.zip # chown -R www-data. /var/www/nextcloud
Serveur SQL MariarDB
Installation :
# apt install mariadb-server
On lance le script pour attribuer un mot de passe root, virer l'utilisateur anonyme etc.
# mysql_secure_installation
Set root password? [Y/n] y
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 ... Success!
On créé la base de donnée pour NextCloud :
# mysql -U
MariaDB [(none)]> create database nextcloud; MariaDB [(none)]> create user nextcloud@localhost identified by 'motdepasse'; MariaDB [(none)]> grant all privileges on nextcloud.* to nextcloud@localhost IDENTIFIED BY 'motdepasse'; MariaDB [(none)]> flush privileges; MariaDB [(none)]> quit;
Installation de Apache2 & PHP7.4
# apt install imagemagick php-imagick libapache2-mod-php7.4 php7.4-common php7.4-mysql php7.4-fpm php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp
On créé le vhost local :
# vi /etc/apache2/sites-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
On active le site :
# a2ensite nextcloud.conf
On active quelques modules :
# a2enmod rewrite # a2enmod headers # a2enmod env # a2enmod dir # a2enmod mime
On active SSL :
# a2enmod ssl # a2ensite default-ssl # systemctl reload apache2
Configuration de NextCloud
On se rend sur l'adresse https://IP_NEXCLOUD/nextcloud/ et on rempli les champs indiqués puis ont clique sur "Terminer l'installation".
Si message d'erreur pas de panique, on retourne sur https://IP_NEXCLOUD/nextcloud/ pour vérifier que tout s'est bien déroulé.
Configuration Reverse-Proxy NGINX
VHost NextCloud
Exemple de vhost pour NextCloud :
server {
listen 80;
listen [::]:80;
server_name nextcloud.exemple.com;
# return 404;
return 301 https://$host$request_uri;
}
server {
server_name nextcloud.exemple.com;
error_page 403 https://nextcloud.exemple.com;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_pass https://IP_SERVEUR_NEXTCLOUD/nextcloud/;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/nextcloud.exemple.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nextcloud.exemple.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
add_header Strict-Transport-Security "max-age=31536000" always;
ssl_trusted_certificate /etc/letsencrypt/live/nextcloud.exemple.com/chain.pem;
ssl_stapling on;
ssl_stapling_verify on;
location ^~ /.well-known {
# The following 6 rules are borrowed from `.htaccess`
location = /.well-known/carddav { return 301 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
# Anything else is dynamically handled by Nextcloud
location ^~ /.well-known { return 301 /index.php$uri; }
try_files $uri $uri/ =404;
}
}
Configuration de Nextcloud
On modifie le fichier de configuration de NextCloud pour qu'il accepte le nom de domaine et le reverse proxy :
NextCloud ~# vi /var/www/nextcloud/config/config.php
...
'trusted_domains' =>
array (
0 => '12.34.56.789',
1 => 'nextcloud.exemple.com',
),
'trusted_proxies' =>
array (
0 => 'IP_PROXY',
),
'overwritewebroot' => '/',
...
Post-Installation
NextCloud est maintenant fonctionnel, mais si vous vous rendez, depuis la page de l'administrateur, sur Administrateur -> Paramètres -> Vue d'ensemble .
Il reste quelques réglages à effectués. (3 si vous avez suivie ce tutorial).
(optionnel) Jolie URL
# vi /var/www/nextcloud/config/config.php
... 'installed' => true, 'overwrite.cli.url' => 'https://nextcloud.exemple.com/nextcloud', 'htaccess.RewriteBase' => '/nextcloud', );
# cd /var/www/nextcloud/ # sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
Limite de mémoire PHP à 512 Mo
# vi /etc/php/7.4/apache2/php.ini
... memory_limit = 512M ...
# apache2ctl graceful
Préfixe de région par défaut
# vi /var/www/nextcloud/config/config.php
... 'htaccess.RewriteBase' => '/nextcloud', 'default_phone_region' => 'FR', );
Memcache via Redis & APCu
# apt install redis-server php-redis php-apcu # vi /etc/redis/redis.conf
Il faut activer les deux ligne suivantes en supprimant le "#" devant + modification des droits :
unixsocket /var/run/redis/redis-server.sock unixsocketperm 770
On désactive l'écoute TCP :
port 0
# usermod -a -G redis www-data # systemctl restart redis # systemctl restart apache2
Enfin, on édite Nextcloud pour utiliser Redis :
# vi /var/www/nextcloud/config/config.php
...
'default_phone_region' => 'FR',
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'redis' => [
'host' => '/var/run/redis/redis-server.sock',
'port' => 0,
'timeout' => 1.5,
],
);