I setup an NFS mount for the Drupal files directory using the following tutorial and everything seems to work perfectly:
http://www.howtoforge.com/setting-up-an-nfs-server-and-client-on-ubuntu-...

However, the file_prepare_directory() function is not behaving properly and is preventing file uploads to my site. When this function is called, the PHP is_writable() function returns back FALSE when the &$directory parameter is a public stream wrapper (public://...).

This is exactly the line 417 of file.inc that returns false:
$writable = is_writable($directory);

If I make a small modification to use the deprecated drupal_realpath() function to unpack the stream wrapper, then the function returns TRUE as expected:
$writable = is_writable(drupal_realpath($directory));

Does anybody else have the same problem or know a solution?
NFS seems to be a common solution for running Drupal 7 on a cluster, so I can't believe I am the first person to discover this issue!?!?

Comments

gabrimonfa’s picture

In our setup a virtual machine with Drupal 7 has the files directory (which is mapped to public:// stream) exposed via NFS4.
Directory permissions are the following

drwxr-xr-x 8 nobody nogroup

The directory is writable by web server user (www-data).

is_writable(PATH_OF_THE_FILES_DIRECTORY) returns true
is_writable('public://') returns false

To be noted that in another (older) setup we used NFS3 mapping uid and guid between host server and guest virtual machine, and no issues arose.

dooug’s picture