Add nextcloud conf
This commit is contained in:
parent
2b5840dc1d
commit
8e5d4a0423
|
@ -0,0 +1,195 @@
|
|||
---
|
||||
title: Serveur nextcloud
|
||||
---
|
||||
|
||||
{{<hint info>}}
|
||||
Cette documentation est inspirée de la [documentation officielle](https://docs.nextcloud.com/server/19/admin_manual/)
|
||||
{{</hint>}}
|
||||
|
||||
# Mettre en place un serveur Nextcloud
|
||||
|
||||
{{<hint warning>}}
|
||||
On suppose que PostgreSQL est déjà installé sur la machine, de même pour Nginx
|
||||
{{</hint>}}
|
||||
|
||||
## Créer la base de données
|
||||
|
||||
On commence par créer un utilisateur
|
||||
|
||||
```
|
||||
CREATE ROLE nextcloud WITH LOGIN PASSWORD '<mot de passe fort>';
|
||||
```
|
||||
|
||||
puis on crée la BDD :
|
||||
|
||||
```
|
||||
CREATE DATABASE nextcloud WITH OWNER nextcloud;
|
||||
```
|
||||
|
||||
## Installer PHP
|
||||
|
||||
Nextcloud est écrit en PHP, un langage interprété, il faut donc installer tout ce qui est nécessaire (voir la documentation), par exemple sur un système basé sur Debian
|
||||
|
||||
```
|
||||
sudo apt install php php-gd php-fpm php-curl php-imagick php-intl php-mbstring php-zip php-gmp php-bcmath php-xml
|
||||
```
|
||||
|
||||
## Installer Nextcloud
|
||||
|
||||
On va se placer dans `/DATA` pour installer nextcloud dans `/DATA/nextcloud`, on va télécharger une archive contenant Nextcloud et la décompresser puis supprimer l'archive
|
||||
|
||||
```
|
||||
cd /DATA
|
||||
wget https://download.nextcloud.com/server/releases/nextcloud-<VERSION>.zip
|
||||
unzip nextcloud-<VERSION>.zip
|
||||
rm nextcloud-<VERSION>.zip
|
||||
```
|
||||
|
||||
On va commencer par créer un site Nginx pour nextcloud, dans mon infra les sites sont dans `/DATA/nginx` je fais donc `nano /DATA/nginx/nextcloud.conf` et j'y met la config (des détails sont dispos sur la doc officielle)
|
||||
|
||||
```
|
||||
upstream php-handler {
|
||||
server unix:/var/run/php/php7.3-fpm.sock;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name cloud.example.com;
|
||||
|
||||
return 301 https://$server_name:443$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name cloud.example.com;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/cloud.rdelaage.ovh/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/cloud.rdelaage.ovh/privkey.pem;
|
||||
|
||||
error_log /var/log/nginx/nextcloud.error.log;
|
||||
access_log /var/log/nginx/nextcloud.access.log;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Download-Options "noopen" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
add_header X-Robots-Tag "none" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
fastcgi_hide_header X-Powered-By;
|
||||
|
||||
root /DATA/nextcloud;
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /.well-known/carddav {
|
||||
return 301 $scheme://$host:$server_port/remote.php/dav;
|
||||
}
|
||||
|
||||
location = /.well-known/caldav {
|
||||
return 301 $scheme://$host:$server_port/remote.php/dav;
|
||||
}
|
||||
|
||||
client_max_body_size 512M;
|
||||
fastcgi_buffers 64 4K;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_comp_level 4;
|
||||
gzip_min_length 256;
|
||||
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
|
||||
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
|
||||
|
||||
location / {
|
||||
rewrite ^ /index.php;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
|
||||
deny all;
|
||||
}
|
||||
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
|
||||
set $path_info $fastcgi_path_info;
|
||||
try_files $fastcgi_script_name =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $path_info;
|
||||
fastcgi_param HTTPS on;
|
||||
|
||||
fastcgi_param modHeadersAvailable true;
|
||||
|
||||
fastcgi_param front_controller_active true;
|
||||
fastcgi_pass php-handler;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_request_buffering off;
|
||||
fastcgi_read_timeout 300;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
|
||||
try_files $uri/ =404;
|
||||
index index.php;
|
||||
}
|
||||
|
||||
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
add_header Cache-Control "public, max-age=15778463";
|
||||
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Download-Options "noopen" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
add_header X-Robots-Tag "none" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ensuite on ouvre son navigateur sur l'URL du serveur et on suit les instructions de l'assistant d'installation.
|
||||
|
||||
Il peut être nécessaire d'ajuster le temps avant un timeout en cas d'erreur lors de l'installation, dans la conf nginx
|
||||
|
||||
```
|
||||
fastcgi_read_timeout 300;
|
||||
```
|
||||
|
||||
et dans la conf php-fpm `/etc/php/7.3/fpm/pool.d/www.conf`
|
||||
|
||||
```
|
||||
request_terminate_timeout = 300
|
||||
```
|
||||
|
||||
# Administrer le serveur en ligne de commande
|
||||
|
||||
Un exécutable est situé à `/DATA/nextcloud/occ` pour administrer le serveur. Il peut s'agir d'opérations de maintenance, sur les utilisateurs, ...
|
||||
|
||||
Pour l'exécuter on lance
|
||||
|
||||
```
|
||||
sudo -u www-data php occ
|
||||
```
|
||||
|
||||
# Mise à jour du serveur
|
||||
|
||||
La procédure est assez simple, il suffit de se connecter à l'aide du compte administrateur et d'aller dans les paramètres d'administration. Le serveur vérifie alors si une nouvelle version est disponible, auquel cas il propose la mise à jour. Il suffit de cliquer sur `Télécharcher et installer` et un assistant s'ouvre automatiquement et fait seul la mise à jour.
|
Loading…
Reference in New Issue