Forum Moderators: phranque

Message Too Old, No Replies

Looking for help

         

pylon42

2:51 am on Mar 22, 2005 (gmt 0)

10+ Year Member



Hello, i'm not sure if i'm asking this in the right place. I'm not a server-side person, but my server admin doesn't seem to be able to resolve my problem. Here it is:

I'm using linux Slackware10?, apache, php.

I have a user account set up: /home/name/web/

web is defined in apache as the public web folder.

(I don't know anything about what I just said, i'm basically repeating what the server guy told me.)

Now here's what I do know a lot about:

I have a completed website, that i'm porting over from another server. I use root-relative calls for the includes:
( /includes/include_name.html )

on the new system, root-relative calls to includes and ONLY includes don't work. I can call them with both absolute and relative paths no problem. But I need root relative to work, or I'll have to rebuild my whole site. I get the following error:

Warning: main(): Failed opening '/includes/include_name.html' for inclusion (include_path='.:/usr/local/lib/php') in /home/name/web/index.php on line 14

Can someone tell me if i need to change something in linux? apache? php? point me in the right direction? i'm at a loss...

Root relative calls to images and url's work fine. It's ONLY includes that don't work. And I've tried removing them from the "includes" directory, same thing.

The guy admin'ing the server has no idea why it doesn't work - If anyone can offer anything, please do - i'm at a loss.

thank you

sitz

2:34 pm on Mar 22, 2005 (gmt 0)

10+ Year Member



You didn't post the snippet of PHP that's generating the error, so we're flying a little blind here. My initial thought is that the directory structure prior to your 'includes' directory isn't in the PHP include path ([us3.php.net ]). If that's the case, you have two (well, four options counting the icky ones)

1) add the path to the global include_path in php.ini (not a good idea from a security standpoint if there are multiple sites hosted on this server; if you're the only site hosted by this apache instance (more specifically, if your apache instance is the ONLY site using this php.ini file), then this is ok.

2) add an ini_set ([us3.php.net ]) to each PHP file that needs to include files from your 'includes' directory.

(these next two are, IMO, a little icky)

3) have the admin drop a symlink from your serverroot into /usr/local/lib/php (the path specified in the error message you pasted in)

4) drop a symlink from your includes directory into each directory containing a PHP script which needs to include something (this /should/ work, since '.' is in the default include_path)

and, of course, there's always the "recode the php" option; in theory, you could just do a search/replace across your files.

pylon42

2:48 pm on Mar 22, 2005 (gmt 0)

10+ Year Member



Thank you for taking the time to reply, I have some new info:

I don't think this is a php thing - standard includes are doing the exact same thing.

I've been messing around with this and I got a / include to work by using the root of the actual server:

So this works:
<? include($DOCUMENT_ROOT."/home/username/web/include_name.html");?>

And this doesn't:
<? include($DOCUMENT_ROOT."/include_name.html");?>

Does that help at all?

pylon42

7:22 pm on Mar 22, 2005 (gmt 0)

10+ Year Member



So to sum things up:

These work:

<img src="/image.gif"> (note that /root is working for this one)
<a href="/index.html"> (note that /root is working for this one)
<!-- #include virtual="include.html" -->
<? include("include.html");?>

These do not:

<!-- #include virtual="/include.html" -->
<? include($DOCUMENT_ROOT."/includes.html");?>

I need to get either of those two working somehow...

Any thoughts?

pylon42

1:43 am on Mar 23, 2005 (gmt 0)

10+ Year Member



More progress:

This works:

<? include($DOCUMENT_ROOT."/home/username/web/include.html");?>

so. When using root relative calls to includes (and ONLY includes) it sees the root of the server, instead of the web root.

There must be something in some apache config file where I can fix this? Anyone? Please?

sitz

1:46 am on Mar 23, 2005 (gmt 0)

10+ Year Member



I imagine the first thing to do is figure out what $DOCUMENT_ROOT is being set to. =)

pylon42

1:58 am on Mar 23, 2005 (gmt 0)

10+ Year Member



Again, i'm not a server-side person - but isn't that a built-in global variable that points at whatever php thinks is the webroot? And if so - can someone tell me how to find out what php thinks is the webroot?

sitz

2:15 am on Mar 23, 2005 (gmt 0)

10+ Year Member



It's a variable like any other:

<?php
echo "My document root is $DOCUMENT_ROOT<br>\n";
?>

pylon42

2:39 am on Mar 23, 2005 (gmt 0)

10+ Year Member



Thank you for your help so far - i'm learning a lot here :)

when I put that code in the page, it generates:

My document root is <br>

is this a problem? Would I be able to fix my problem by somehow changing this variable to something like:

/home/username/web/ (or whatever?)

sitz

2:49 am on Mar 23, 2005 (gmt 0)

10+ Year Member



Mmmm. PHP may be configured to not set some of the global variables; Try:

echo "My DocumentRoot is ($_SERVER["DOCUMENT_ROOT"])<br>\n";

Alternatively, you can just dump out your entire PHP environment with:

<?php
phpinfo();
?>

Of course, this function may have been disabled... =)

pylon42

3:44 am on Mar 23, 2005 (gmt 0)

10+ Year Member



okay, i did the info one - I think this is what i'm looking for:

docref_root no value no value

that right? Should I be looking for anything else?

thanks

pylon42

3:45 am on Mar 23, 2005 (gmt 0)

10+ Year Member



There's also:

doc_root no value no value

sitz

5:21 am on Mar 23, 2005 (gmt 0)

10+ Year Member



We're kind of out of the realm of Apache and into the realm of PHP, for which there is another forum ([webmasterworld.com ]). That said, there should be a DOCUMENT_ROOT line in the phpinfo() output (several, actually). Search the phpinfo() page until you find them, then try them in your little echo "my docroot is [$VARIABLE]" script until you find what you need.

pylon42

1:22 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



Okay, thanks for all the help - i'm on the right track now