There is an option in Configuration > File system which let you define a path for private files. After setting a path in this field, the access for all users is restricted (including admin). I need to give the permission of accessing this directory and its files to some users. How?
The difference between the Drupal public and private file systems is whether the web server or Drupal handles accessing the files.
- With the public file system, Drupal doesn't do anything for accessing the files. The assumption is that the web server can access these files and they are within the web root of the site. Drupal just generates URLs that allow the web server to serve those files.
- With the private files system, things are different. They are served by Drupal, and Drupal gets to decide if the user has access to those files. In core, this happens when the file is attached to content the user has access to, if I'm not mistaken, but there are other ways to tell Drupal a user should get access to a file. Since Drupal should have full control over file access (through URL paths it serves), this means that the private file system should be in a directory outside the web root, as those files are not intended for direct access by the web server (theoretically you could also have the files within the web root and use some other means to restrict access through the web server, like .htaccess, but that's a more fragile solution).
Both directories should be readable and writable by Drupal (whatever user Drupal runs as, which would typically be something like
php, depending on your setup). The public file system should be within the web root, the private file system should really be outside it, if you ask me, but at the very least have some other way configured to not be accessible through the web server from the outside.