Forum Moderators: phranque
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
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.
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?
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?
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?