Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
infrastructure:services:cloud:nextcloud:installation [27/04/2023 06:36] – Stéphane Paillet | infrastructure:services:cloud:nextcloud:installation [27/04/2023 09:47] (Version actuelle) – Stéphane Paillet | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
===== Installation Nextcloud ====== | ===== Installation Nextcloud ====== | ||
{{tag> | {{tag> | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | Ce mode opératoire est en cours de rédaction et n'est pas finalisé. | ||
+ | </ | ||
+ | |||
+ | |||
Nextcloud est une application de stockage de fichiers en ligne. | Nextcloud est une application de stockage de fichiers en ligne. | ||
Ligne 31: | Ligne 37: | ||
Nous créons le fichier vHost | Nous créons le fichier vHost | ||
< | < | ||
- | sudo vi / | + | sudo vi / |
</ | </ | ||
Ligne 39: | Ligne 45: | ||
server unix:/ | server unix:/ | ||
} | } | ||
+ | |||
+ | # Set the `immutable` cache control options only for assets with a cache busting `v` argument | ||
+ | map $arg_v $asset_immutable { | ||
+ | "" | ||
+ | default " | ||
+ | } | ||
+ | |||
server { | server { | ||
listen 80; | listen 80; | ||
- | server_name cloud.grohub.org; | + | server_name cloud.example.com; |
- | # enforce https | + | |
- | return 301 https://$host$request_uri; | + | |
+ | server_tokens off; | ||
+ | |||
+ | # Enforce HTTPS | ||
+ | return 301 https://$server_name$request_uri; | ||
} | } | ||
Ligne 50: | Ligne 67: | ||
listen 443 ssl http2; | listen 443 ssl http2; | ||
server_name cloud.grohub.org; | server_name cloud.grohub.org; | ||
- | | + | |
- | # Path to the root of your installation | + | # Path to the root of your installation |
root / | root / | ||
- | | + | |
access_log | access_log | ||
error_log | error_log | ||
- | | + | |
# Use Mozilla' | # Use Mozilla' | ||
# https:// | # https:// | ||
- | | + | ssl_certificate |
- | | + | ssl_certificate_key /etc/nginx/ssl/ |
- | ssl_certificate_key /etc/ssl/private/ | + | |
- | # Add headers to serve security related headers | + | # Prevent nginx HTTP Server Detection |
- | | + | |
- | # topic first. | + | |
- | #add_header Strict-Transport-Security " | + | # HSTS settings |
- | # | + | |
# WARNING: Only add the preload option once you read about | # WARNING: Only add the preload option once you read about | ||
# the consequences in https:// | # the consequences in https:// | ||
Ligne 74: | Ligne 89: | ||
# in all major browsers and getting removed from this list | # in all major browsers and getting removed from this list | ||
# could take several months. | # could take several months. | ||
- | add_header | + | |
- | add_header X-XSS-Protection "1; mode=block"; | + | |
- | add_header X-Robots-Tag none; | + | |
- | add_header X-Download-Options noopen; | + | |
- | add_header X-Permitted-Cross-Domain-Policies none; | + | |
- | add_header Referrer-Policy no-referrer; | + | |
- | | + | # set max upload size and increase upload timeout: |
- | fastcgi_hide_header X-Powered-By; | + | |
- | + | ||
- | location = /robots.txt { | + | |
- | allow all; | + | |
- | log_not_found off; | + | |
- | access_log off; | + | |
- | } | + | |
- | + | ||
- | # The following 2 rules are only needed for the user_webfinger app. | + | |
- | # Uncomment it if you're planning to use this app. | + | |
- | #rewrite ^/ | + | |
- | #rewrite ^/ | + | |
- | + | ||
- | # The following rule is only needed for the Social app. | + | |
- | # Uncomment it if you're planning to use this app. | + | |
- | #rewrite ^/ | + | |
- | + | ||
- | location = / | + | |
- | return 301 $scheme:// | + | |
- | } | + | |
- | location = / | + | |
- | return 301 $scheme:// | + | |
- | } | + | |
- | + | ||
- | | + | |
client_max_body_size 512M; | client_max_body_size 512M; | ||
+ | client_body_timeout 300s; | ||
fastcgi_buffers 64 4K; | fastcgi_buffers 64 4K; | ||
Ligne 116: | Ligne 102: | ||
gzip_min_length 256; | gzip_min_length 256; | ||
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; | gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; | ||
- | gzip_types application/ | + | gzip_types application/ |
- | # Uncomment | + | # Pagespeed is not supported by Nextcloud, so if your server is built |
- | # This module is currently not supported. | + | # with the `ngx_pagespeed` module, uncomment this line to disable it. |
#pagespeed off; | #pagespeed off; | ||
- | location / { | + | |
- | | + | # See https:// |
+ | # for tunning hints | ||
+ | client_body_buffer_size 512k; | ||
+ | |||
+ | # HTTP response headers borrowed from Nextcloud `.htaccess` | ||
+ | add_header Referrer-Policy | ||
+ | add_header X-Content-Type-Options | ||
+ | add_header X-Download-Options | ||
+ | add_header X-Frame-Options | ||
+ | add_header X-Permitted-Cross-Domain-Policies " | ||
+ | add_header X-Robots-Tag | ||
+ | add_header X-XSS-Protection | ||
+ | |||
+ | # Remove X-Powered-By, | ||
+ | fastcgi_hide_header X-Powered-By; | ||
+ | |||
+ | # Add .mjs as a file extension for javascript | ||
+ | # Either include it in the default mime.types list | ||
+ | # or include you can include that list explicitly and add the file extension | ||
+ | # only for Nextcloud like below: | ||
+ | #include mime.types; | ||
+ | #types { | ||
+ | # application/ | ||
+ | #} | ||
+ | |||
+ | # Specify how to handle directories -- specifying `/ | ||
+ | # here as the fallback means that Nginx always exhibits the desired behaviour | ||
+ | # when a client requests a path that corresponds to a directory that exists | ||
+ | # on the server. In particular, if that directory contains an index.php file, | ||
+ | # that file is correctly served; if it doesn' | ||
+ | # the front-end controller. This consistent behaviour means that we don't need | ||
+ | # to specify custom rules for certain paths (e.g. images and other assets, | ||
+ | # `/updater`, `/ | ||
+ | # `try_files $uri $uri/ / | ||
+ | # always provides the desired behaviour. | ||
+ | index index.php index.html / | ||
+ | |||
+ | # Rule borrowed from `.htaccess` to handle Microsoft DAV clients | ||
+ | | ||
+ | | ||
+ | return 302 /remote.php/webdav/$is_args$args; | ||
+ | } | ||
} | } | ||
- | location | + | location |
- | | + | |
+ | log_not_found off; | ||
+ | access_log off; | ||
} | } | ||
- | | + | |
- | | + | # Make a regex exception for `/ |
+ | # access it despite the existence of the regex rule | ||
+ | # `location ~ / | ||
+ | # for `/ | ||
+ | location ^~ / | ||
+ | | ||
+ | # in `.htaccess` that concern `/ | ||
+ | |||
+ | location = / | ||
+ | location = / | ||
+ | |||
+ | location / | ||
+ | location / | ||
+ | |||
+ | # Let Nextcloud' | ||
+ | # requests by passing them to the front-end controller. | ||
+ | return 301 / | ||
} | } | ||
- | location ~ ^\/ | + | |
- | fastcgi_split_path_info ^(.+? | + | |
+ | location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) | ||
+ | |||
+ | # Ensure this block, which passes PHP files to the PHP process, is above the blocks | ||
+ | # which handle static assets (as seen below). If this block is not declared first, | ||
+ | # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` | ||
+ | # to the URI, resulting in a HTTP 500 error response. | ||
+ | location ~ \.php(?:$|/) { | ||
+ | # Required for legacy support | ||
+ | rewrite ^/(?!index|remote|public|cron|core\/ | ||
+ | |||
+ | fastcgi_split_path_info ^(.+? | ||
+ | set $path_info $fastcgi_path_info; | ||
+ | |||
+ | try_files $fastcgi_script_name =404; | ||
include fastcgi_params; | include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
- | fastcgi_param PATH_INFO $fastcgi_path_info; | + | fastcgi_param PATH_INFO $path_info; |
fastcgi_param HTTPS on; | fastcgi_param HTTPS on; | ||
- | # Avoid sending the security headers twice | + | |
- | fastcgi_param | + | fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice |
- | | + | fastcgi_param |
- | fastcgi_param front_controller_active true; | + | |
fastcgi_pass php-handler; | fastcgi_pass php-handler; | ||
+ | |||
fastcgi_intercept_errors on; | fastcgi_intercept_errors on; | ||
fastcgi_request_buffering off; | fastcgi_request_buffering off; | ||
- | } | ||
- | location ~ ^\/ | + | fastcgi_max_temp_file_size 0; |
- | try_files $uri/ =404; | + | |
- | index index.php; | + | |
} | } | ||
- | | + | location ~ \.(?: |
- | # Make sure it is BELOW the PHP block | + | |
- | | + | |
try_files $uri / | try_files $uri / | ||
- | add_header Cache-Control " | + | add_header Cache-Control " |
- | | + | |
- | # have those duplicated to the ones above) | + | |
- | # Before enabling Strict-Transport-Security headers please read into | + | |
- | # this topic first. | + | |
- | #add_header Strict-Transport-Security " | + | |
- | | + | |
- | # WARNING: Only add the preload option once you read about | + | |
- | # the consequences in https:// | + | |
- | # will add the domain | + | |
- | # in all major browsers and getting removed from this list | + | |
- | # could take several months. | + | |
- | add_header X-Content-Type-Options nosniff; | + | |
- | add_header X-XSS-Protection "1; mode=block"; | + | |
- | add_header X-Robots-Tag none; | + | |
- | add_header X-Download-Options noopen; | + | |
- | add_header X-Permitted-Cross-Domain-Policies none; | + | |
- | add_header Referrer-Policy no-referrer; | + | |
- | | + | |
- | | + | |
+ | } | ||
} | } | ||
- | location ~ \.(?: | + | location ~ \.woff2?$ { |
try_files $uri / | try_files $uri / | ||
- | # Optional: Don't log access to other assets | + | expires 7d; |
- | | + | access_log off; # Optional: Don't log access to assets |
+ | } | ||
+ | |||
+ | # Rule borrowed from `.htaccess` | ||
+ | location /remote { | ||
+ | | ||
+ | } | ||
+ | |||
+ | location / { | ||
+ | try_files $uri $uri/ / | ||
} | } | ||
} | } | ||
Ligne 191: | Ligne 240: | ||
< | < | ||
cd / | cd / | ||
- | sudo ln -s / | + | sudo ln -s / |
</ | </ | ||
- | ===== Installation | + | Nous testons et rechargeons la configuration |
+ | < | ||
+ | sudo nginx -t | ||
+ | sudo systemctl reload nginx | ||
+ | </ | ||
+ | |||
+ | ===== Install / conf PHP ===== | ||
+ | |||
+ | ==== Installation PHP ==== | ||
Nous installon PHP-fpm et les différents modules dont nous aurons besoin | Nous installon PHP-fpm et les différents modules dont nous aurons besoin | ||
< | < | ||
- | sudo aptitude | + | sudo apt install php-common |
</ | </ | ||
- | ===== Tuning ===== | + | ==== php.ini |
Nous réglons le temps maximal d' | Nous réglons le temps maximal d' | ||
< | < | ||
Ligne 206: | Ligne 265: | ||
</ | </ | ||
- | Dans le fichier / | + | Nous activons opcode. Toujours dans le fichier / |
+ | < | ||
+ | opcache.enable=1 | ||
+ | opcache.interned_strings_buffer=8 | ||
+ | opcache.max_accelerated_files=10000 | ||
+ | opcache.memory_consumption=128 | ||
+ | opcache.save_comments=1 | ||
+ | opcache.revalidate_freq=1 | ||
+ | </ | ||
+ | |||
+ | ==== PHP pool ==== | ||
+ | |||
+ | Dans le fichier / | ||
< | < | ||
[nextcloud] | [nextcloud] | ||
Ligne 230: | Ligne 301: | ||
</ | </ | ||
- | Nous activons opcode. Toujours dans le fichier / | + | ===== Postgresql ===== |
+ | |||
+ | ==== Installation Postgresql ==== | ||
< | < | ||
- | opcache.enable=1 | + | sudo apt install postgresql php8.2-pgsql |
- | opcache.interned_strings_buffer=8 | + | </ |
- | opcache.max_accelerated_files=10000 | + | |
- | opcache.memory_consumption=128 | + | ==== Création base / utilisateur ==== |
- | opcache.save_comments=1 | + | |
- | opcache.revalidate_freq=1 | + | < |
+ | create database nextcloud; | ||
+ | create user nextcloud with encrypted password ' | ||
+ | grant all privileges on database nextcloud to nextcloud; | ||
+ | </ | ||
+ | |||
+ | ===== Redis ===== | ||
+ | |||
+ | ==== Installation Redis ==== | ||
+ | |||
+ | < | ||
+ | sudo apt install redis-server php8.2-redis | ||
+ | </ | ||
+ | |||
+ | ==== Configuration Nextcloud ==== | ||
+ | |||
+ | Nous éditons le ficher de configuration Nextcloud pour ajouter la configuration de Redis | ||
+ | < | ||
+ | sudo vi / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | array ( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ), | ||
+ | </ | ||
+ | |||
+ | ===== Tuning ===== | ||
+ | |||
+ | ==== Tâches cron ==== | ||
+ | |||
+ | Nous configurons cron | ||
+ | |||
+ | < | ||
+ | sudo -u www-data crontab -e | ||
+ | </ | ||
+ | |||
+ | Nous ajoutons ceci à la fin du fichier | ||
+ | |||
+ | < | ||
+ | # Add the following line to the end of the file: (will call the cron script every 5 minutes) | ||
+ | */5 * * * * / | ||
+ | </ | ||
+ | |||
+ | ==== Pour gérer les thèmes ==== | ||
+ | |||
+ | Si la gestion des thèmes est configurée, | ||
+ | |||
+ | < | ||
+ | sudo apt install libmagickcore-6.q16-6 libmagickcore-6.q16-6-extra | ||
</ | </ | ||
===== Liens ===== | ===== Liens ===== | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// |