-1

I have chosen a hosting provider to put my multi-site system online. I have uploaded the files and databases and have achieved limited functionality. However, a mysterious problem is occurring.

My hosting provider instructed me to implement the sites by creating subdomains of the subdomain they created for my account. So the URL for site1.com at this stage is site1.newsites.a2hosted.com.

The site includes an "About" page whose alias is "About_Site1" and which includes a php call to include a file "about.php".

When I attempt to load the "About" page (via site1.me.a2hosted.com/About_Site1), I get this error:

Fatal error: require_once(): Failed opening required '/sites/Site1/_/about.php'

To check if it's looking in the right place, I inserted

echo($_SERVER['DOCUMENT_ROOT']);

and this immediately before the call to require_once().

So the code is now:

echo('doc root: "' . $_SERVER['DOCUMENT_ROOT'] . '"');
require_once('/sites/Site1/_/about.php'); 

and the result is:

doc root: "/home/newsites/public_html" Fatal error: require_once(): Failed opening required '/sites/Site1/_/about.php' (include_path='.:/opt/alt/php55/usr/share/pear:/opt/alt/php55/usr/share/php') in /home/newsites/public_html/modules/php/php.module(80) : eval()'d code on line 3

The tech support agent at my hosting provider reported: "I have checked the file and folder permissions, and this file is definitely readable by the system. While this is possibly a development issue related to the way Drupal is handling these subdomains internally, I have opened this ticket to further review the situation and ensure that nothing server-side is causing an issue."

The site is set up as a subdomain because that's how my hosting provider told me to implement multi-site on their system.

While they are looking into the problem, does anyone have any insights on what might be going on?

closed as off-topic by Scott Joudry, Krishna Mohan, Mołot, Pierre.Vriens, kiamlaluno Jun 12 '15 at 6:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on programming, PHP, SQL, etc. that do not relate directly to Drupal are off-topic here, but can be asked on Stack Overflow." – Scott Joudry, Krishna Mohan, Mołot, Pierre.Vriens, kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is this even a Drupal site? Drupal has very specific ways of including files via modules and themes. You really shouldn't just be using require_once() on a page. – RoloDMonkey Jun 1 '15 at 16:19
  • Yes, I know this is not the Drupal Way. It's a stopgap measure to allow me to get the sites up now because I need them, and I will have to work on implementing them via modules in due course. In the meantime, the server should be able to find its files. It's working fine on my local computer. – NewSites Jun 1 '15 at 16:52
  • @Pierre.Vriens - Pierre, are you a moderator on here, or does anyone have the ability to edit questions? This is the second time you have edited a question of mine in a way that changes its content, and I don't appreciate it. I don't have time to go through and undo what you've done, so I'm not going to bother, but unless you're a moderator, I object to you doing this. Please express you're problems with what I've written without defacing it. – NewSites Jun 12 '15 at 4:14
  • Actually, @Pierre.Vriens just changed the formatting, and made the question easier to read. Everybody, on Stack Exchange, can edit other users' posts, as long as they reach the right reputation. – kiamlaluno Jun 12 '15 at 6:53
  • @kiamlaluno : thank you for confirming what I thought was OK to do, because of what is written in drupal.stackexchange.com/help/privileges/edit also. Moreover, be aware that in a previous comment I "suggested" something like "this looks too much like free promotion, consider re-editing ...". That never happened, so I exercised my rights, and then deleted my obsoleted comment (suggestion). 1 more thing: "question of mine" is not how Drupal.SE works, because the OPer does not "own" the question ... – Pierre.Vriens Jun 12 '15 at 7:38
1
echo('doc root: "' . $_SERVER['DOCUMENT_ROOT'] . '"');
require_once('/sites/Site1/_/about.php'); 

Is sort of half-and-half; what you need is

require_once DRUPAL_ROOT . '/sites/Site1/_/about.php'; 

Or PHP will be looking in the root of the file system.

  • Bingo! That worked. I don't understand why it worked because I checked DRUPAL_ROOT and it's the same as $_SERVER['DOCUMENT_ROOT'], but it did work, so thank you. – NewSites Jun 2 '15 at 0:59
  • Oh, just a minute. Maybe I understand it now. You said PHP would be looking in the file root. So I guess you're saying that PHP include functions interpret the initial slash as pointing to the file root instead of the document root. Is the file root the value given for the public file folder in "Configuration > File System"? – NewSites Jun 2 '15 at 1:14
  • By the way, it doesn't work that way on my local computer. The code that was giving the error in my question works without error locally. So locally, require() does interpret the initial slash as the doc root (= Drupal root). I'm changing all my code to specify DRUPAL_ROOT to eliminate this ambiguity. – NewSites Jun 2 '15 at 1:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.