Hi all, I've recently just installed Drupal and think it's pretty nice to use after spending the last couple of days trying other options. Everything seems to be going fine - I was getting errors when trying to play with the themes and so they wouldn't work, but I have been styling the site up manually so that doesn't seem to be an issue. However, when I add new content to the site through the admin area, I am getting the following couple of errors:

* warning: fopen(): SAFE MODE Restriction in effect. The script whose uid is 10023 is not allowed to access /var/www/vhosts/shiclubs.org.uk/httpdocs/files owned by uid 48 in /var/www/vhosts/shiclubs.org.uk/httpdocs/includes/file.inc on line 117.

* warning: fopen(files/.htaccess): failed to open stream: Success in /var/www/vhosts/shiclubs.org.uk/httpdocs/includes/file.inc on line 117.

They both mean nothing to me, and so far they haven't kicked up a problem. The new content works in any case. I just wondered if anyone knew what the errors are referring to and if I have anything to worry about.

Thanks for the help

Kelly

Comments

nevets’s picture

It appears your service provider has safe mode enabled and drupal wants it to be off. A number of things will not work with safe mode including upload images and files.

Kelly Dyson’s picture

Hi Nevets, thanks for the information. I'll send them an email tomorrow and hopefully get that sorted out.

Take care

Kelly

gpk’s picture

This is a classic problem with safe mode. You (uid 10023) own the script index.php, which created the folder files, but since it was the webserver process that created files it is owned by the webserver (uid 48), so now your script can't access it. So in this scenario safe mode breaks pretty well any site that uploads content in this way. Safe mode is so problematic (or useless, depending on your perspective) that it is not present in PHP6. http://uk3.php.net/features.safe-mode

Assuming you can't persuade your host to turn it off either globally or for your account (if they allow user php.ini files then you might be able to turn it off that way), you could try:

- Creating the files directory by hand so it has the right UID. Sometimes this is "good enough" to get round the problem, i.e. as long as the containing directory is owned by the right user then all is well.
- Add your files folder to PHP's safe_mode_include_dir directive (see comments on turning off safe mode)
- Get your host to relax the safe mode setting so it only does a GID check (safe_mode_gid directive). The sticky bit will need to be set on all directories in and under your drupal folder and perhaps on your drupal folder also, so that all files created by the webserver process are group owned by you, not the webserver. I think this should work ...

But given the complexities of working round the problem like this, and given the accepted wisdom that safe mode is far more trouble than it is worth (just search for it on the web), you may be able to twist your host's arm ...

Good luck

gpk
----
www.alexoria.co.uk

Kelly Dyson’s picture

Hi gpk, that's really helpful, thank you. I submitted a support ticket to my host and within 15 minutes they had turned off safe mode (I'm on a shared server so I didn't have access to do it myself). No more errors and everythings working fine. Ta for the advice guys.

Take care

Kelly

chiburger’s picture

I completely agree with Kelly.

Thanks again to the entire Drupal support team/support posters. Every single problem I have had is answered (in-depth) by you guys, and to be honest, is the main reason I am very excited about my new Drupal site.

TYVM.

-Chi

riverspart’s picture

Many thanks to you for your solution. I just deleted it then created manually again through core FPT.^^
After that, It has been working fine!

kpluto’s picture

yeah gpk, super helpful. thanks!!

pspanya’s picture

Thank you. I had the same problem.
I just put a php.ini file to my root folder.
It solves the problem! Even the safe_mode is still "on".

Here is the content of the file (which i tried to fix the pdo problem before):
extension=pdo.so
extension=pdo_mysql.so

extension=pdo.dll
extension=pdo_mysql.dll

-----------------------------
PHP Configuration
Language Options safe_mode On

And I still don't know why?

ps. sorry for my English writing.

reboottees’s picture

I had the exact same error message. I emailed my hosting company and he turned off Safe Mode for my Drupal folder and that solved the problem.
Perhaps the Pre-Install documentation for Drupal could mention this.
Perhaps even a Drupal friendly list of webhosts would be cool too.

...peace, reboottees.com (looking to convert to a Drupal site)

gigfish’s picture

HI all thanks for the posts its great to see others have had the same issue. Though mine seems a little more extensive. Not sure what the issue is and Im not that much of a techie.. so please try to help me but dumb it down..

this is the error im getting

warning: fopen(): SAFE MODE Restriction in effect. The script whose uid is 10719 is not allowed to access /var/www/vhosts/gigfishenterprises.com/httpdocs/sites/default/files owned by uid 48 in /var/www/vhosts/gigfishenterprises.com/httpdocs/includes/file.inc on line 129.
warning: fopen(sites/default/files/.htaccess): failed to open stream: Success in /var/www/vhosts/gigfishenterprises.com/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 directory /tmp does not exist.

please help.. i tried copying the current .htaccess file on the server into the above directly but my server would not allow it..

can someone please help.

ps all fixed safe mode turned off by host

Kindest.

Brett

mark_r’s picture

Hi,

i run drupal on a plesk driven webserver with safe_mode ON

i installed the module xml sitemap and after enabling the module i got a error message. it said that drupal can't read a temp file what was just created by the server.

i came here through google and tryed some ideas mentioned here but i found no solution, so i search again.

i came across this website:
https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle&kb...

after setting the "setgid" bit on the directory "/httpdocs/sites/default/files" it works.

Maybe it would help some others too.

Sven H’s picture

You may be able to turn safe mode on/off yourself in the control panel of your website. This may require a bit of wandering though!

Sven

solomenikm’s picture

You can find this settings in /etc/apache2/apache2.conf by the safe_mode key.

WWWCur’s picture

RhiP’s picture

I solved this error by puting this line in my php.ini file.

safe_mode = Off