warning: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid is 10009 is not allowed to access /var/www/vhosts/gtthm.com/httpdocs/files owned by uid 48 in /var/www/vhosts/gtthm.com/httpdocs/includes/file.inc on line 117. .

warning: fopen(files/.htaccess) [function.fopen]: failed to open stream: Success in /var/www/vhosts/gtthm.com/httpdocs/includes/file.inc on line 117.

Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your files directory which contains the following lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

I've tried making both the files directory and the includes directory completely writeable with chmod 777 but still having problems.

Comments

cog.rusty’s picture

This is a common problem when PHP "safe mode" is enabled on your server, and I am not sure it can be solved. It is a matter of file ownership, not only permissions.

Even if Drupal writes as user apache, and 777 gives all permissions to everyone (including user apache), "safe mode" checks if the owner of the file or the directory is the same as the owner of the running script, otherwise it won't let it write.

If you are the owner of file.inc, but you let Drupal create the 'files' directory automatically (so, its owner is apache), "safe mode" won't allow writing in the 'files' directory.

Try to delete the 'files' directory, create it yourself (and all its subdirectories, if any), and then set them all to 777. This has worked for some people. If not, bug your host (or bag them), because you won't be able to upload files through Drupal either.

Barry Pretsell’s picture

druwatcha’s picture

I had the same problem: fopen() [function.fopen]: SAFE MODE Restriction in ... see my error below:

I checked the folder "sites/default"
and created the folder files within default and wihtin files I created then folder tmp manually via a ftp client.
I found out that the owner of the folder files and tmp was not my ftp user, it was something like wwwrun.
There was also a .htaccess file created also owned by wwwrun.
It was tricky to delete them. I deleted them with WinSCP (can be used if you have your own virtual server with shell access).
I renamed them, and created the files and tmp folders manually, downloaded the .htaccess, deleted the one on the server
and uploaded .htaccess via ftp, after that: files and tmp folder and file .htaccess were owned by my ftpuser.
CHMOD 775 is enough for the folders files and tmp. The option php safe mode ist still active and I do not get the error anymore.
I use a german translation, therefore I also created a folder lanugages within the files folder.

In result make sure that you have within the
sites/files folder
the folders tmp and languages. The owner of the files should not be wwwrun, it should be ideally your ftpuser.
The ftp user is shown e.g. in filezilla (ftpclient) when u scroll a little bit to right.

My error:
Die Datei konnte nicht erstellt werden.
Die Datei konnte nicht erstellt werden.
warning: fopen(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /srv/www/mydomaintesthere.de/httpdocs/sites/default/files/tmp owned by uid 30 in /srv/www/mydomaintesthere.de/httpdocs/includes/file.inc on line 129.
warning: fopen(sites/default/files/tmp/.htaccess): failed to open stream: Success in /srv/www/mydomaintesthere.de/httpdocs/includes/file.inc on line 129.
Sicherheitswarnung: Die Datei .htaccess konnte nicht geschrieben werden. Bitte erstellen Sie im Verzeichnis sites/default/files/tmp eine .htaccess Datei mit dem folgenden Inhalt:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks