I have a pretty stable development machine set up running Apache and using virtual hosts to keep my projects separate, and running a dyndns.org service which I use to access them. Each VHost directive typically looks like this:
<VirtualHost *:80> ServerName [my_internal_subdomain].[my_dyndns_name].dyndns.org ServerAlias home DocumentRoot "D:/webserver/[projectDirectory]/httpdocs" php_admin_value open_basedir "c:/WINDOWS/TEMP;D:/webserver/[projectDirectory]/" ErrorLog "D:/webserver/[projectDirectory]/logs/error.log" TransferLog "D:/webserver/[projectDirectory]/logs/access.log" </VirtualHost>
Obviously [projectDirectory], [my_internal_subdomain] and [my_dyndns_name] are all values I know/change for each directive, just no need to post them here :)
One thing has always confounded me however, in PHP, if I want to require a file from say /includes/, I would expect to use:
Except doing so throws an open_basedir restriction error - because "/" is trying to go, presumably to the root of D:/ - whereas I would like each virtual host to recognise that the value of DocumentRoot is in fact where I would like PHP to go if I call a file by "/".
This is how my production server seems to work, and its a bit of a pain having to code everything to work out what the relative path to /includes/ is for the benefit of my dev machine.
I expect this is a fairly simple/obvious directive I'm missing but I can't find it. Can anyone help?
Do you mean this?
require($_SERVER['DOCUMENT_ROOT'] . '/includes/myfile.php');
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki