• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

php include from subdomains

P

path2u

Guest
I am hoping someone can assist me with this. I have a dedicated server running around 10 domains. I have one primary domain, running a few subdomains under it as well. The issue I am having is, I want to create a standard set of headers and footers, and use php include statements to use them from the subdomains as well. I have tried all sorts of different configurations and methods of calling the paths, but I can not seem to get the include statements to function from the subdomains. For example, I have header file in mainsite.com/includes which I want to use as header on subdomain.mainsite.com
Is there some limitation on the subdomains by deafault, or is there a setting in the separate config files which can turn this on and off ?
any help would be wonderful,
thanks,
Jesse Goodman
 
maybe you're having permission problems.
what kind of error message do you get when you try to include the file?

if your subdomain is not using the same ftp user as your domain, you won't be able to include the file because the owner is different. you can change the file permissions to make it work, like executing a chmod 777 domain.com/includes/header.inc.php for example. just change 777 to any other permission that you prefer.

you may also want to check the php open_basedir restriction and safe_mode on the file domain.com/subdomains/subdomain/conf/httpd.include

if the file doesn't exist, you can create one using as a model the one in domain.com/conf

I hope this helps...
 
subdomain includes not working

thanks for the reply ...
I did think of the permissions aspect, and just for kicks tried everything with 777 perms to make sure that was not it.
Still nothing. They are different users so I can see how that could cause troubles.
I am not sure about the other parameter you mention ... I found this in the main config file ...
php_admin_value open_basedir (pathtotmp)
Could this be the one you mentioned or is there another one specifically calling out a restriction ?
Thanks again,
Jesse
 
Check your logs, I think it's indeed open_basedir that's restricting access in this case (and rightly so, you don't want all users to be able to read files from other users). Check the Knowledge Base for this one.
 
subdomain issues

thanks, I just verified that is it by adding include path to config file open_basedir. Is this a security issue now? I guess my question is ... is there a better wya to do what I am trying to do ?
Is there a way to have multiple sites on the same server all share same header,footer, and menu files without having to edit them in each location everytime I change something ?
thanks,
Jesse
 
Re: subdomain issues

thanks, I just verified that is it by adding include path to config file open_basedir. Is this a security issue now? I guess my question is ... is there a better wya to do what I am trying to do ?

By extending the open_basedir path your just giving a domain access to more directories. If those directories just contain files you want that domain to access then I there is no security problem really.

Is there a way to have multiple sites on the same server all share same header,footer, and menu files without having to edit them in each location everytime I change something ?

Plesk is not really designed to easily share between domains. Usually you want your users to not be able to touch eachother's files. You could extend each domain's open_basedir path automatically upon creation by including a vhost.conf in your skeleton or maybe write a script that distributes your files among domains, share a database from which you pull your info, etc., etc. There are numerous possibilities, but they all require some work on your part. Plesk won't really help you with this.
 
Not ideal but depending on how they are crafted you could just include them over http


include ("http://maindomain/header.php");

for example.

This wont be affected by any openbase and/or ownership permission issues this way.
 
Then you're just including the output of header.php. If that's enough, then indeed you're settled. Don't expect access to header.php's variables and functions though (which would be a MAJOR security issue)...
 
Back
Top