I want to learn DOCUMENT_ROOT in startup.pl, but the best I can do is to learn server_root:
use Apache2::ServerUtil ();
$server_root = Apache2::ServerUtil::server_root();
which is quite useless. I can set an environment variable with
SetPerlEnv DOCUMENT_ROOT /path/to/www
but I don’t like extra configuration if possible.
Is there a way to get DOCUMENT_ROOT by other means?
See Apache2::Directive. For example, on my development system:
created a file
C:/bzzzt.txtwith the contents"E:/srv/unur/deploy/htdocs"after I discovered that I had to specify my virtual hosts usingrather than
<VirtualHost *:8080>. Otherwise, each<VirtualHost *:8080>section was overwriting the previous one.This is annoying. I would have thought each
VirtualHostentry would have been keyed by theServerNameused.As for if there is an easier way, I am afraid there isn’t if you want to do this in
startup.pl. However, I am not sure if it is necessary to do it instartup.pl. You can find out the document root while processing a request as well using Apache2::RequestUtil::document_root.If you are running Registry scripts, and want to change to
DOCUMENT_ROOT, then you should be able to add:to the script instead of having to mess around with
startup.pland handlers etc.