December 10th, 2012, 05:39 PM
Can't get require_once to work across domains on the same server - permission denied
Hi. I have a server with several websites on it and am in the process of building an admin system on one domain that produces files that will be used by the code on the other domains.
They are all on the same server.
The folders containing the file I want to use is 777 permissions
The folders and files belong to the same ground on both admin site and other domains
The basedir restrictions have been set to allow both admin domain and website domain paths - I think this is set correctly.
The error given is of the form:
Any help or further information required would be welcome...
require_once(../../xxxxx.co.uk/httpdocs/domains/xxxxx.co.uk/faders/faderSwitches.php) [function.require-once]: failed to open stream: Permission denied in /var/www/vhosts/xxxxx.co.uk/httpdocs/includes/templates.php on line 22
Many thanks, Jim
December 10th, 2012, 05:46 PM
Check that the open_basedir property is set properly in your php.ini file
December 10th, 2012, 06:04 PM
I will check again but it appears to be - in phpinfo. The message it displayed previously about still being in effect has gone...
I presume setting a basedir entry on the 'client' domain allowing the remote folder (on the administrative domain) to be accessed from the client domain is the correct course of action to follow...
Currently I have:
December 10th, 2012, 06:13 PM
I do not really know in which file you are using your require_once. But maybe the problem has to do with the relative path.
try it with __DIR__ in front:
December 11th, 2012, 05:11 AM
I tried it, but it didn't help, thanks for the suggestion though... I tried it with an absolute server path:
Originally Posted by rstoll
but it hates that too...
December 11th, 2012, 05:15 AM
Does this script have read+execute (xx5 or xx7) permissions on every folder between ./ and faders/? Don't quote me on this but I'm pretty sure it's not just the target directory that matters.
December 11th, 2012, 05:49 AM
I 777'd all the directories below httpdocs to the file (and the file itself) yes but no joy.
Originally Posted by requinix
December 11th, 2012, 05:55 AM
I still believe it has to do with open_basedir. What system is used for your hosting? If plesk is used, than make sure that open_basedir is not just set correctly on the global config but also in the indiviual domain specific config (could be that the global config is overwriten in the domain specific one).
December 11th, 2012, 06:00 AM
Yes, it is a Plesk system.
Originally Posted by rstoll
The basedir I showed is from the local php.ini which displays in the phpinfo for the client domain. I wonder if I should set the global config to the same in case that aspect of the local php.ini is being ignored. Is that possible?
I'd be happy if I could just figure out a way for the admin domain to write the files to the client domain, but I can't seem to get past security any way.
Is it significant that I am running php as a fast-cgi? I mean the local .ini seems to be right, but if the global ini is different... Just tried it as an apache process instead - no difference.
I am starting to think that you are right about the settings not being correctly used or reported.
December 11th, 2012, 07:38 AM
Could it be the other way around (that the local config is being ignored in favour of the global one)?
There doesnt seem to be a basedir entry set globally though :/
December 11th, 2012, 07:59 AM
Given that you have a plesk server then do this
go to the
folder and create a file called vhost.conf (there will already be on called httpd.include - DO NOT EDIT this one)
in the new file put
replace the path fore the other-site.co.uk website with the path to where you want to include from
you will then want to get that new configuration recognised. You can do this by one of a number of methods. Often the easiest way is to log into plesk, go the domain in question, go to web hosting settings and click save.
Then, the plesk process scans all the files in the conf folder and knows to include your new file in future requests
December 11th, 2012, 08:07 AM
Hi, thanks for the suggestion. When you say to put: /var/www/vhosts/clientsite.co.uk/httpdocs:/var/www/vhosts/administrativesite.co.uk/httpdocs:/var/www/vhosts/other-site.co.uk/httpdocs:/tmp in the vhost.conf do you mean:
Originally Posted by Northie
open_basedir = /var/www/vhosts/clientsite.co.uk/httpdocs:/var/www/vhosts/administrativesite.co.uk/httpdocs:/var/www/vhosts/other-site.co.uk/httpdocs:/tmp
I am not being facetious, I am very unfamiliar with this stuff...
December 11th, 2012, 08:12 AM
Yes, i did mean that.
Originally Posted by merrydown
by all means look in the httpd.include one to see how the code is structured then copy and edit the relevant parts (into vhsot.conf).
The reason not to edit the existing one is that this is read and written to by plesk, and it is interned that you use the vhost.conf file to extend/overwrite the existing one
December 11th, 2012, 08:16 AM
Here's one of mine, on my plesk server which allows me to symlink a local folder (part of xxxx.co.uk) to a folder (zzzz) on another website (yyyy.co.uk)
php_admin_value open_basedir "/var/www/vhosts/xxxxx.co.uk/httpdocs:/var/www/vhosts/xxxx.co.uk/httpdocs/products/image/data/filemanager:/:/var/www/vhosts/yyyy.co.uk/httpdocs/new-site/filemanager/zzzz:/tmp"
December 11th, 2012, 08:26 AM
Originally Posted by Northie
I tried that but nothing has changed. I tied going to web hosting settings and clicking ok, I also tried clicking on the domain name at the bottom of advancedoptions for website and domains on the required domain and okaying those settings.
I really appreciate your help, particularly being Plesk specific. May I PM you with a few more specific details which might help?