Link to home
Start Free TrialLog in
Avatar of NIPPLES
NIPPLESFlag for Malaysia

asked on

Warning: Unknown(): open_basedir restriction in effect.

Hi Fellow Experts,

I am getting this php error on a LAMP setup on a shared hosting server...

Warning: Unknown(): open_basedir restriction in effect.

Using .htaccess or any other means, how can i overide this.  Its set in php.ini.

Could i drop a new php.ini in the directory? What lines could i put in .htaccess ... or is there any other way?

ini_set() function in php does not seem to be working at all.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of glcummins
glcummins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NIPPLES

ASKER

So there is no "black hat" method?  I don't want to wake up my sysadmin halfway around the world just switch on a setting in php.ini!
Avatar of NIPPLES

ASKER

Forgot to say that this is my server, running several sites - not a 3rd party.  So nothing naughty going on.

Cheers.
Avatar of Steve Bink
>>> So there is no "black hat" method?

That is contrary to the guidelines of EE.  Please refer:

https://www.experts-exchange.com/help.jsp#hi100

As glcummins explained, there are very good reasons that restriction is placed on a server, especially if it is a shared host.  I recommend you look at adjusting your code to account for it.  

Why do you feel you need to access outside of your directory tree?
There is no above-board method that would get this done for you without editing the main php.ini file and restarting Apache. Other, less scrupulous, methods may be available, but this is not the forum to discuss them.
LOL...wish I had refreshed before posting.  :)  That does change things.

You'll still have to edit where that restriction is being set.  It could be set in php.ini, or even in a <VirtualHost> container in Apache conf files.  I would recommend you see here:

http://www.php.net/manual/en/ini.php

Note that this setting is affected by PHP's safe mode.  You'll need to examine that setting as well.  Check here for more information:

http://www.php.net/manual/en/features.safe-mode.php
Avatar of NIPPLES

ASKER

Thanks for your help routinet,

>>> https://www.experts-exchange.com/help.jsp#hi100

"Hacks" are about 90% of the solutions on EE!  Without them (in the true definition of the word) there wont be many answers... lol...

Why do you feel you need to access outside of your directory tree?

1.  File uploads to the server.
2.  Secure areas to store usernames and passwords.
3.  Database connection strings.

But funny thing is i get errors even when i try to access INSIDE the directory tree... just because of this setting - and because the entire web app is using basename / basedir functions for file locations.

Mystery continues...
Avatar of NIPPLES

ASKER

>>> LOL...wish I had refreshed before posting.  :)  That does change things.

Heheh... could do with some ajax in here...

Ok i give up - will have to email a modified php.ini to my sysadmin.  Thanks for the brainstorming guys..

Points go to first correct answer - "it cant be done" by glcummins.
The basedir restriction make your site think that it exists in it's own world, completely separate from anything else on the server. So, if your site files reside in the absolute path:

 /home/sites/yoursite/web

and you have a directory named:

 /home/sites/yoursite/web/includes/functions.php

you would access it using

 /includes/functions.php

Your application knows nothing about '/home/sites/yoursite', so trying to reference that location will throw an error, even if it is within your 'allowed' area.
Avatar of NIPPLES

ASKER

glcummins,

Thanks for your time!  

>>> Your application knows nothing about '/home/sites/yoursite', so trying to reference that location will throw an error, even if it is within your 'allowed' area.

Yep that makes sense... Its alot of hard coded php to eat through to fix.  ill just have to get  the guy out of bed and edit php.ini (so kind to try so hard to fix it first in EE huh?)

Cheers!