Hi All,
I just installed PHP on an OpenBSD box and I'm having a funky problem with PHP accessing the filesystem.
I'm trying to include/require files using an absolute file path "/var/www/htdocs/funclib.php". However, I'm getting an error saying there is no such file.
When I include with "funclib.php" it works.
The weird thing is that when I include "/htdocs/funclib.php", it works fine. There is no directory called htdocs at the root of this server.
Any ideas? I've always used filesystem paths when including files, but this seems to be a bastard union of a filesystem and an Apache document root path.
Thanks!
PHP using Apache's document root (maybe)
Moderator: General Moderators
PHP using Apache's document root (maybe)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Try this diagnostic code, and tell us the output:
Code: Select all
<?php
echo '/ expands to:'.realpath('/').'<br />';
echo 'funclib.php expands to:'.realpath('funclib.php').'<br />';
?>The output from that code is:
Is there a config I can set somewhere (either in apache or PHP) that tells it to not use virtual paths?
Code: Select all
/ expands to:/
funclib.php expands to:/htdocs/funclib.phpReal programmers don't comment their code. If it was hard to write, it should be hard to understand.
Well, I think I figured out what the problem is. Turns out that on OpenBSD, Apache runs in a chroot jail. What that means is that you can make Apache think that the root of the server is /var/www/, or any other directory. Unfortunately, that also sets up the mapping for PHP, of '/' to '/var/www/', effectively stopping any access to the /tmp directory or anything else below '/var/www/'.
I'm not the server admin for this particular server, so this can't be fixed today anyway. (Just ask me how frustrating THAT is
).
Thanks for your help guys.
- Dylan
I'm not the server admin for this particular server, so this can't be fixed today anyway. (Just ask me how frustrating THAT is
Thanks for your help guys.
- Dylan
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.