如何在mod_perl2下的startup.pl中学习DOCUMENT_ROOT?
我想学习startup.pl中的DOCUMENT_ROOT,但我能做的最好的就是学习server_root:
use Apache2::ServerUtil ();
$server_root = Apache2::ServerUtil::server_root();
这是毫无用处的。我可以设置环境变量,
SetPerlEnv DOCUMENT_ROOT /path/to/www
但如果可能的话,我不喜欢额外的配置。
有没有办法通过其他方式获取DOCUMENT_ROOT?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅 Apache2::Directive。例如,在我的开发系统上:
在我发现之后创建了一个文件
C:/bzzzt.txt
,其内容为"E:/srv/unur/deploy/htdocs"
我必须使用
来指定我的虚拟主机。否则,每个
部分都会覆盖前一个部分。这很烦人。我本以为每个
VirtualHost
条目都会由所使用的ServerName
键入。至于是否有更简单的方法,如果您想在
startup.pl
中执行此操作,恐怕没有。但是,我不确定是否有必要在startup.pl
中执行此操作。您还可以在处理请求时找到文档根目录 Apache2::RequestUtil::document_root 。如果您正在运行注册表脚本,并且想要更改为
DOCUMENT_ROOT
,那么您应该能够将:添加到脚本中,而不必与
startup.pl
和处理程序等混在一起。See Apache2::Directive. For example, on my development system:
created a file
C:/bzzzt.txt
with 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
VirtualHost
entry would have been keyed by theServerName
used.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.pl
and handlers etc.