| Drupal
Creating a Drupal 8 Private File System

An OSTraining member asked how they could set up a Drupal 8 private file system.

In Drupal 7 you could do this from the configuration at Administrator > Configuration > Media > File System.

In Drupal 8, we have to set the private path manually.

  • Create a directory for the private files to be saved in:

Create a directory for the private files

You may want to use a name that won't be considered important. For this tutorial, I have simply called it 'private'. 

  • Go to your sites/default/settings.php. On line 533 you should find the setting we need to edit hashed out:

Settings.php file in Drupal

  • Remove the hash and enter the path for your private directly. In my case, this is 'sites/default/files/private':


  • Save and close settings.php file
  • Flush the cache, which you can find in Administration > Configuration > Development > Performance:

Flush the Drupal cache

  • Go to the File System and see if Drupal is detecting the private file storage: Administrator > Configuration > Media > File system

Is private file storage working in Drupal

  • Select the private directory and save this configuration.

Drupal should automatically include a new .htaccess file inside the folder.

Now you have a private directory to store your files in.

About the author

Daniel is a web designer from UK, who's a friendly and helpful part of the training community.