Hello,

I've recently installed Drupal and most functions seem to be working properly (e.g., I can add and remove users, change permissions, create content). However, when I try to configure themes (under Administer > Site Building > Themes > Configure), I get the following error:

* warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /var/www/vhosts//subdomains/drupal/httpdocs/includes/file.inc on line 129.
* Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your sites/default/files directory which contains the following lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

The reason I'm perplexed is that I have already copied the .htaccess file into the sites/default/files directory and adjusted the permissions in order to make it writable. Why would I be getting that error?

Also, if I am supposed to add those lines into the .htaccess file, I'm wondering what syntax I'm supposed to use.

Any advice would be much appreciated.

-Chris Jensen

Comments

zoo’s picture

Have you tried copying and pasting those lines at the end of the .htaccess? (I'm not an expert)

Bye

CarnubaWax’s picture

Hi zoo,

I tried just copying and pasting those lines into the .htaccess file, but it didn't do anything... That's why I was wondering whether there was a particular syntax that I needed to use.

That said, it still doesn't explain why I'd be a "permission denied" error (especially when I specifically set the .htaccess file to be writable.

Any other ideas?

matkeane’s picture

Hi,

Couple of things to check:

- How did you copy the .htaccess file to the server? If you FTP'd it to the server with the transfer mode set to Binary, the result is often that the file is unrecognized by the server. Some, but not all, FTP apps are smart enough to automatically transfer htaccess files in Text transfer mode. Also, if you have edited the file, you should make sure that it still uses Unix-style line feed characters - some text editors add extra line feed characters which can make the file unreadable to the server.

- Is the files directory itself writable? If so, you could try deleting the current htaccess file on the server and then visiting the 'file system' admin page, which seems to check for the presence of a htaccess file and generate one if it it missing (you might need to submit the settings form on that page to do this - I can't remember)

Hope that helps...

CarnubaWax’s picture

Hi MatKeane,

Thanks for the advice... Just to be on the safe side, I downloaded a program and checked the linefeed characters to make sure that they followed the UNIX standard after I edited the file. Also, I tried explicitly transferring the file in TEXT (ascii) mode. Unfortunately, neither of these things seemed to help.

In terms of file permissions, there is no reason that the files directory shouldn't be writable. For testing purposes, I chmodded the directory to 777, so any user *should* theoretically be able to write to it. That said, I actually can't use the 'file system' page either... When I try to make any changes, it throws the same errors:

* warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /var/www/vhosts/[my host name]/subdomains/drupal/httpdocs/includes/file.inc on line 129.
* Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your sites/default/files directory which contains the following lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

It also adds a new error:
* The directory sites/default/files/tmp does not exist
which is especially perplexing given that I have created this folder, and, as a result, know that it definitely exists!

Is there some way that Drupal might not be resolving my paths correctly?

The thing that I forgot to mention is that the entire site is on a Unix-based Plesk server. I'm not sure how that would make a difference, but maybe it would.

Anyway, I'd appreciate any additional insights. Also, thanks to everyone who has already responded.

-Chris Jensen

btopro’s picture

Bump

Also experiencing this issue. Very odd cause I've never seen it before.

swa3’s picture

I have experienced the same error message when installing a new theme.
To fix this I changed the permisions at /sites/default/files to 777
Everything is now working OK.

apdford’s picture

I had the same issue - changing the permission as mentioned in previous post worked for me - Thanks

tofuComputer’s picture

Is this a bug? I've seen several posts about this issue, most all with the same recommended solutions. But alas, nothing is working for me yet.

TC

tofuComputer’s picture

Ok, I got it working but I had to change the "files" folder to 777. Is that safe??? Doesn't seem so.

Thanks,

TC