Dossier de téléchargement sur stockage externe (Plesk)

Dossier de téléchargement sur stockage externe (Plesk)

Prérequis

  • Avoir un symlink /storage qui pointe vers le disque externe de stockage. Par exemple :
ln -s /home /storage

Variables utilisées

  • Subscription name : (ex.: jmcouillard.com)
  • Domain name : (ex.: jmcouillard.com)
  • user:group : (ex.: jmcouillard:psacln)

Étape 1 : Copier le dossier de fichier

Drupal

mkdir /storage/var/www/vhosts/<subscription>/
mkdir /storage/var/www/vhosts/<subscription>/<domain>/
mkdir /storage/var/www/vhosts/<subscription>/<domain>/files/
cp -R /var/www/vhosts/<subscription>/httpdocs/<domain>/sites/default/files/** /storage/var/www/vhosts/<subscription>/<domain>/files/
chown -R <user:group> /storage/var/www/vhosts/<subscription>/
rm -Rf /var/www/vhosts/<subscription>/httpdocs/<domain>/sites/default/files
ln -s /storage/var/www/vhosts/<subscription>/<domain>/files/ /var/www/vhosts/<subscription>/httpdocs/<domain>/sites/default/files
chown -R <user:group> /var/www/vhosts/<subscription>/httpdocs/<domain>/sites/default/files

Wordpress

mkdir /storage/var/www/vhosts/<subscription>/
mkdir /storage/var/www/vhosts/<subscription>/<domain>/
mkdir /storage/var/www/vhosts/<subscription>/<domain>/uploads/
cp -R /var/www/vhosts/<subscription>/httpdocs/<domain>/wp-content/uploads/** /storage/var/www/vhosts/<subscription>/<domain>/uploads/
chown -R <user:group> /storage/var/www/vhosts/<subscription>/
rm -Rf /var/www/vhosts/<subscription>/httpdocs/<domain>/wp-content/uploads/
ln -s /storage/var/www/vhosts/<subscription>/<domain>/uploads/ /var/www/vhosts/<subscription>/httpdocs/<domain>/wp-content/uploads
chown -R <user:group> /var/www/vhosts/<subscription>/httpdocs/<domain>/wp-content/uploads/

Étape 2 : Autorisation open_dir PHP

Dans les configurations PHP, ajouter :

open_basedir = {WEBSPACEROOT}{/}{:}{TMP}{/}{:}/storage/var/www/vhosts/<subscription>/

Avec Plesk, on peu alternativement permettre à PHP d'écrire dans le dossier. Dans Plesk, au paramètre open_basedir, inscrire {WEBSPACEROOT}{/}{:}{TMP}{/}{:}{/}home{/}{WEBSPACEROOT}{/}