Attempt to serve directory error from Drupal

I have several websites installed in subdirectories on my Mac laptop at /Users/davidnorman/Sites where I pointed the OS-included installation of Apache to use as my DocumentRoot. This weekend, I switched one of the sites installed in a subdirectory to use the root of my DocumentRoot as the source of the "File system path" setting at admin/settings/file-system.

Since the private setting, outside the expected installation of Drupal is supposed to be able to support writing files, I had to chmod my DocumentRoot directory as 777 to get the setting to save, even though I just wanted to read some files there, not write. Note: Though I did not do it recursively, chmodding the root of your web tree as 777 is is a BAD thing in most circumstances.

After setting the private file system path in the subdirectory Drupal 6 install, none of the PHP scripts anywhere in my DocumentRoot worked anymore. The chmod wasn't the problem though. One of the reasons the file system path has to be writable is that Drupal adds a .htaccess file to that directory which effectively disables script execution for security's sake.

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks
The result in the Apache /var/log/apache2/error_log was simply a mysterious, unhelpful bit:

[Sat Jan 08 21:08:16 2011] [error] [client 127.0.0.1] Attempt to serve directory: /Users/davidnorman/Sites/

That is the error I would get regardless of whether I tried to load http://localhost/, http://localhost/phpinfo.php, or http://localhost/drupalinstallation/.

The solution: Remove the .htaccess file that Drupal automatically added at /Users/davidnorman/Sites/.htaccess. Also, pick a different subdirectory, other than the web root for private files in your subdirectory installs of Drupal.

Let this serve as a reminder that chmodding your web directory, even in your sandbox, to 777 is a bad idea, and that the root of your web tree is not a good dumping ground for private file system path settings on subdirectory Drupal installations.


» deekayen's blog · Printer-friendly version Topics: ·

thank you sir

8 hrs of trying things and this helped me. my issue was I copied a .htaccess with password auth to my local environment home. I serve my sandbox sites from /home/user/workspace. This .htaccess was looking for a non-existent htpasswd file, so it broke everything. Thanks!

reply

nice solution, I had this

nice solution, I had this same error and I am new to Drupal so this helped me a lot.

reply

Post new comment

  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <hr /> <a> <p> <em> <strong> <cite> <code> <blockquote> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.