Question

Okay, I've tried everything, this is by far the best place it seems, I want to make Document Root here httpdocs/[folder]/html and I have php include files that I want to go above the root (require '../[folder]/file.php'] but not be able to access further than /var/www/vhosts/example.com/httpdocs. I know I'm being limited by open_basedir because the value is still httpdocs/[folder]/html in phpinfo() but for the life of me I can't change that local value!

This is what I've tried so far: I've seen this - How to include file outside document root? - and created a 'vhost.conf' that is stil sitting in the conf directory, reconfigured the file, restarted apache...nothing. It's a good post but it seems a little out of date.

I edited php.ini itself to open_basedir = '/var/www/vhosts/example.com/httpdocs, uploaded it back up to where it was, reconfigured, restarted - nothing

I pulled out 'httpd.conf' edited it by adding the same lines from the other conf file,(vhost.conf), put it back in - nothing, I then tried to do what godaddy says here - http://help.godaddy.com/article/1616 and added the line php_admin_value open_basedir none' to 'httpd.conf - with no luck either.

It is now 0435 and I can barely keep my eyes open - this site is suppose to launch tomorrow at 2000! Thanks in advance to anyone who is willing/able to read and/or help.

Update: Thanks for a quick response, here are the best answers I can give you:

Does it give you an error?

Yes, I get a server error and through my server error log, specifically:

PHP Warning: require() [function.require]: open_basedir restriction in effect. File(/var/www/vhosts/[example.com]/httpdocs/[folder]/[folder where secure php files exist]/[file.php]) is not within the allowed path(s):

So I'm 99.99% sure its because of the open_basedir restriction.

Are you sure that your webserver is set as the owner of vhosts/ ?

I'm pretty sure, I'm kinda new to controlling servers and I don't really know what that means exactly but I have a virtual dedicated server through Godaddy, running Parallels Plesk v10.3.1, I did the above file moving going through Shell SSH.

In Plesk, I can change the 'Document root' to anything below /var/www/vhosts/example.com and Plesk will change the 'open_basedir' to anything I set. For example, If I set the document root to 'httpdocs' in Plesk then 'open_basedir' is changed to the same folder and everything works fine. The problem is I don't want public access to everything in /httpdocs/[folder]

My goal is I want to change 'document root' to /httpdocs/[folder]/html and 'open_basedir to /httpdocs but I can't change that local value in open_basedir for some reason. I want to do this for security purposes so people can only directly access the non important php files, but php itself I want to give more access to folders.

Are you trying to include using relative or absolute paths?

My paths in the php file that I'm trying to include/require to files above 'document root' looks exactly like this format:

require '../[folder where secure php files exist]/file.php';

If I'm understanding you correctly, I'm not using the entire path of the server.

Was it helpful?

Solution

ANSWER: (This was changed to the answer):

Apparently, in Plesk 10, Plesk's program sets whatever the 'document root' path will be, to the 'open_basedir' BUT there is no user friendly way to change 'open_basedir' in Plesk 10!!!

So instead it is a little bit of a hack, you have to first go here:

/usr/local/psa/admin/conf/templates/default/service/php.php

Then change both of these lines in the file, (line 11 and 29): echo "php_admin_value open_basedir {$OPT['dir']}/:/tmp/\n";

to this: echo "php_admin_value open_basedir /var/www/vhosts/[your.domain]/httpdocs/:/tmp/\n";

or to wherever you want the restriction to stop.

Then make sure your run these lines is SSH:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all

/etc/init.d/httpd stop

/etc/init.d/httpd start

But I'm having a new problem now. The 'document root' is pointing to the correct folder:

/var/www/vhosts/[my.domain]/httpdocs/[folder]/html

without any error however when the server gets to a: require '../[folder]/[file.php]';

It skips through it like its not even there! Not giving me an error msg or anything. It's also skipping all my embedded css files, js files, images, videos...its not going to any of the directories! I have a feeling it's a 'php.ini' setting or something weird that Plesk is doing.

Solved: The last issue was because I never worked with accessing files above the root. PHP is allowed to go above the root but you can't do this: src="../img/imagefile.jpg"

in HTML.

So after restructuring all my site files my website is now up and running! Thanks to all that helped, hopefully someone won't have to do that again. Also, I saw a post where Plesk is updating this because it is a big issue. Someone who works for Parallels said, http://forum.parallels.com/showthread.php?t=113236 this will be an option in the next version, so until then it's hack time!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top