I can not enable the private folder getting the warning as below:

Warning: file_exists(): Unable to find the wrapper "private" - 
did you forget to enable it when you configured PHP? in file_save_htaccess() 
(line 365 of core/includes/file.inc).

It's Drupal 8.6.12, multisite config, other sites use private folders.

How can I fix it ?

  • What action are you taking to get that error message? – Clive Mar 15 at 13:36
  • 1
    The error might be a bit misleading by the way: it's Drupal that provides the private stream wrapper, not PHP itself, so the problem is in the site config rather than PHP config – Clive Mar 15 at 13:39
  • Just admin access like /admin/config – Paul Paku Mar 15 at 14:38

Here are the necessary steps:

  1. Create a directory on the server. This is typically done via SSH. For instance assuming Apache under Ubuntu, the following command can be used: sudo -u www-data mkdir -p /var/www/html/web/sites/default/files/private
  2. Tell Drupal about your directory by editing your settings.php file. You need to have a line like the following:

     $settings['file_private_path'] = '/var/www/html/web/sites/default/files/private';
  3. Important: clear the Drupal cache, for example with drush cr or by going to the page /admin/config/development/performance in your browser.

  4. In the browser's address bar, go to /admin/config/media/file-system. You should see "Private local files" in the "Default download method" option. If not, then please visit the /admin/reports/status page to see any error messages. Make sure that PHP can write in the directory. Often, for this to work, the directory has to be writable for the www-data user.

For more documentation, go to https://www.drupal.org/docs/8/core/modules/file/overview#private-file-system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.