Nextcloud
Prérequis
Bash |
---|
| apt update && apt install wget unzip -y
|
Apache2
Installation
Bash |
---|
| apt install apache2 libapache2-mod-php -y
|
Configuration
nextcloud.conf
Bash |
---|
| nano /etc/apache2/sites-available/nextcloud.conf
|
Text Only |
---|
| Alias / "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
</Directory>
|
Puis on active la configuration
Modules
Bash |
---|
| a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
a2enmod ssl
a2ensite default-ssl
|
Cacher la version du service
Bash |
---|
| sed -i.bak 's/ServerSignature On/ServerSignature Off/g' /etc/apache2/conf-enabled/security.conf
|
Désactiver la lisibilité des fichiers présents dans les dossiers
Bash |
---|
| echo -e "<Directory /var/www>\n\t\tOptions -Indexes\n</Directory>" >> /etc/apache2/conf-enabled/security.conf
|
Relancer le service
Bash |
---|
| systemctl restart apache2
|
Activer le service au démarrage
Bash |
---|
| systemctl enable apache2 --now
|
PHP
Installation
Bash |
---|
| apt install -y php php-gd php-curl php-zip php-dom php-xml php-simplexml php-mbstring php-mysql php-intl php-imagick -y
|
Configuration
date.timezone
Bash |
---|
| sed -i.bak 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php/7.4/apache2/php.ini
sed -i.bak 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php/7.4/cli/php.ini
|
Give PHP read access to /dev/urandom
Bash |
---|
| sed -i.bak 's/;open_basedir =/open_basedir = \/var\/www\/nextcloud:\/var\/lib\/nextcloud:\/tmp:\/proc\/meminfo:\/proc\/cpuinfo:\/proc\/uptime:\/dev\/urandom/g' /etc/php/7.4/apache2/php.ini
sed -i.bak 's/;open_basedir =/open_basedir = \/var\/www\/nextcloud:\/var\/lib\/nextcloud:\/tmp:\/proc\/meminfo:\/proc\/cpuinfo:\/proc\/uptime:\/dev\/urandom/g' /etc/php/7.4/cli/php.ini
|
memory_limit
Bash |
---|
| sed -i.bak 's/memory_limit = 128M/memory_limit = 1024M /g' /etc/php/7.4/apache2/php.ini
sed -i.bak 's/memory_limit = 128M/memory_limit = 1024M /g' /etc/php/7.4/cli/php.ini
|
Relancer le service
Bash |
---|
| systemctl restart apache2
|
MariaDB
Installation
Bash |
---|
| apt install mariadb-server -y
|
Configuration
Suivre le script en changeant le mot de passe root
Bash |
---|
| mysql_secure_installation
|
Base de données nextcloud
SQL |
---|
| CREATE USER 'nextclouddb'@'localhost' IDENTIFIED BY '';
CREATE DATABASE IF NOT EXISTS nextclouddb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextclouddb'@'localhost';
FLUSH PRIVILEGES;
EXIT;
|
Nextcloud
Installation
Bash |
---|
| cd /tmp
wget https://download.nextcloud.com/server/releases/latest-25.zip
unzip ./latest-25.zip
mv ./nextcloud /var/www/
|
On donne les droits à l'utilisateur web :
Bash |
---|
| chown -R www-data:www-data /var/www/nextcloud
|
Configuration
Bash |
---|
| mkdir -p /var/lib/nextcloud/data
chown -R www-data:www-data /var/lib/nextcloud
|
Se rendre à l'url suivante : https://cloud.exemple.fr
!!! Mettre la base de données dans /var/lib/nextcloud/data
Pretty URLs
Bash |
---|
| nano /var/www/nextcloud/config/config.php
|
On ajoute :
Text Only |
---|
| 'overwrite.cli.url' => 'https://cloud.exemple.fr',
'htaccess.RewriteBase' => '/',
|
Bash |
---|
| sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
|
default_phone_region
Bash |
---|
| nano /var/www/nextcloud/config/config.php
|
On ajoute :
Text Only |
---|
| 'default_phone_region' => 'FR',
|
trusted domains
Si un reverse proxy est utilisé, ajouter l'url dans le fichier suivant :
Bash |
---|
| nano /var/www/nextcloud/config/config.php
|
Et modifier la variable trusted_domains sous la forme :
Text Only |
---|
| 'trusted_domains' =>
[
'cloud.exemple.fr'
],
|
Puis redémarrer le service apache
Bash |
---|
| systemctl restart apache2
|
crontab
Dans les paramètres de base du système nextcloud, Taches de fond, sélectionner Cron à la place de AJAX
Puis, sur le serveur
Ajouter :
Text Only |
---|
| */5 * * * * php -f /var/www/nextcloud/cron.php
|