Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep Power
    0

    Question 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 streamPermission 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
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0
    Check that the open_basedir property is set properly in your php.ini file
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep 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
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep 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';
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep Power
    0
    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...
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,249
    Rep Power
    9400
    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.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep Power
    0
    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.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep 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).
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep Power
    0
    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.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep 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 :/
  20. #11
  21. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4124
    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
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep Power
    0
    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...
  24. #13
  25. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4124
    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
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  26. #14
  27. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4124
    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>
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    16
    Rep Power
    0

    Red face


    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?
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo