I'm trying to include the following on a page on a subdomain, which is on the same server as the parent domain: <? include ("/home/httpd/vhosts/mydomain.com/httpdocs/file.php"); ?> PHP: Unfortunately the file doesn't open/execute, and the error I get when I check the error log is "Failed opening '/home/httpd/vhosts/mydomain.com/httpdocs/file.php' for inclusion". Again, since it's on a subdomain I'm just wondering if there's a permission issue or if there's something else that needs to be done that I'm just missing?
Probably has a directory restriction. What is the location of the file you are including from? Also, double check the permissions on the file you are trying to include.
Have you checked for proper permissions/ownership of the files in question? As jestep stated, knowing where you're trying to include from would likely be good to know as well.
Have you been able to resolve the issue. Also check if you server supports php short tags. I see you using that which is not best practice. Thanks
looks like you make a little mistake, i think the syntax should like : <?php include ("/home/httpd/vhosts/mydomain.com/httpdocs/file.php"); ?>
no its not a mistake. he is using php short tags but it is being discouraged to use them. further reading on them : http://php.net/manual/en/language.basic-syntax.phptags.php
of ../file.php? one directory lower? of you need more then do this for every lower directory ../ ../../../../file.php
If we knew the actual path of the file from the root, the directory this file (the one this code is in) is in and the actual directory of the document root of the web server, we could write you a statement that should work. Since there are some hosts that set things up in strange ways, we can't assume anything.
Are you using Plesk or a similar VPS control panel??? If you are on a subdomain the path to your httpdocs would be: /home/httpd/vhosts/mydomain.com/subdomains/subname/httpdocs/ if you are trying to include a file outside of your sundomains httpdocs (ie. in the main domain httpdocs: /home/httpd/vhosts/mydomain.com/httpdocs/file.php) you will need to reconfigure apache to allow this. Refer to this document: http://stackoverflow.com/questions/2370053/how-to-include-file-outside-document-root
Dimes to dollars you're running the nonsense known as suPHP which makes php execute with the user permissions of the account/main directory. This typically means that even subdomains get their own user, preventing cross-domain use of files -- even server side. I call it nonsense because the only thing suPHP does over fastCGI is run each php instance as the user for the domain; which means sure, you can't have hacks cross domains on the server, but it also means you might as well change the permissions of every file to 777. Security-wise it's the equivalent of shooting your dog because the neighbor's cat has fleas. Sure, let's open up a massive gaping security hole in every account to prevent an ultra-rare tiny hole over there. It's like plugging a crack in a dam with a wrecking ball. If that is indeed the case, you're pretty much SOL... my advice, copy the one file to the same domain/subdomain instead of trying to cross domains. Though if that file calls other files, those files wouldn't be in scope anyways so those too would fail... even if you're not on suPHP.