The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP5 - Can't get require_once to work across domains on the same server - permission denied
Discuss Can't get require_once to work across domains on the same server - permission denied in the PHP Development forum on Dev Shed. Can't get require_once to work across domains on the same server - permission denied PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 10th, 2012, 04:39 PM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
PHP5 - 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:
PHP Code:
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
Any help or further information required would be welcome...
Many thanks, Jim
|

December 10th, 2012, 04:46 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Time spent in forums: 2 h 3 m
Reputation Power: 0
|
|
|
Check that the open_basedir property is set properly in your php.ini file
|

December 10th, 2012, 05:04 PM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
|
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:
/var/www/vhosts/clientsite.co.uk/httpdocs:/var/www/vhosts/administrativesite.co.uk/httpdocs:/tmp
Jim
|

December 10th, 2012, 05:13 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Time spent in forums: 2 h 3 m
Reputation Power: 0
|
|
|
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:
require_once __DIR__.'/../../xxxxx.co.uk/httpdocs/domains/xxxxx.co.uk/faders/faderSwitches.php';
|

December 11th, 2012, 04:11 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by rstoll 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:
require_once __DIR__.'/../../xxxxx.co.uk/httpdocs/domains/xxxxx.co.uk/faders/faderSwitches.php'; |
I tried it, but it didn't help, thanks for the suggestion though... I tried it with an absolute server path:
require_once ('/var/www/vhosts/xxxxx.co.uk/httpdocs/domains/xxxxx.co.uk/faders/faderSwitches.php');
but it hates that too...
|

December 11th, 2012, 04:15 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
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, 04:49 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by requinix 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. |
I 777'd all the directories below httpdocs to the file (and the file itself) yes but no joy.
|

December 11th, 2012, 04:55 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Time spent in forums: 2 h 3 m
Reputation Power: 0
|
|
|
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, 05:00 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by rstoll 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). |
Yes, it is a Plesk system.
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, 06:38 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
|
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, 06:59 AM
|
 |
Square Peg in a Round Hole
|
|
Join Date: Oct 2007
Location: North Yorkshire, UK
|
|
Given that you have a plesk server then do this
go to the
/var/www/vhosts/clientsite.co.uk/conf/
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
Code:
/var/www/vhosts/clientsite.co.uk/httpdocs:/var/www/vhosts/administrativesite.co.uk/httpdocs:/var/www/vhosts/other-site.co.uk/httpdocs:/tmp
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, 07:07 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by Northie Given that you have a plesk server then do this
go to the
/var/www/vhosts/clientsite.co.uk/conf/
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
Code:
/var/www/vhosts/clientsite.co.uk/httpdocs:/var/www/vhosts/administrativesite.co.uk/httpdocs:/var/www/vhosts/other-site.co.uk/httpdocs:/tmp
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 |
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:
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, 07:12 AM
|
 |
Square Peg in a Round Hole
|
|
Join Date: Oct 2007
Location: North Yorkshire, UK
|
|
Quote: | Originally Posted by merrydown 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:
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 facaetious, I am very unfamiliar with this stuff... |
Yes, i did mean that.
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, 07:16 AM
|
 |
Square Peg in a Round Hole
|
|
Join Date: Oct 2007
Location: North Yorkshire, UK
|
|
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)
Code:
<Directory /var/www/vhosts/xxxxx.co.uk/httpdocs>
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"
</Directory>
|

December 11th, 2012, 07:26 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 15
Time spent in forums: 5 h 24 m 58 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by Northie 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)
Code:
<Directory /var/www/vhosts/xxxxx.co.uk/httpdocs>
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"
</Directory>
|
Hi 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?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|