如何启用虚拟目录支持 php?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25415628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:49:01  来源:igfitidea点击:

How to enable the Virtual Directory Support php?

phpvirtual-directory

提问by Mehmet Kaynak

I see "Virtual Directory Support" is disabled in phpinfo.php, how can I enable it ?

我看到 phpinfo.php 中的“虚拟目录支持”被禁用,我该如何启用它?

回答by johannes

In short: You can't easily. And you should not.

简而言之:你不能轻易。你不应该。

Longer story: PHP is supposed to provide a shared nothing environment. In this context this means if two scripts are running in parallel they should not interfere. In most cases this is no issue as different scripts use different processes. (Apache module with mod_prefork, FastCGI, fpm etc.)

长话短说:PHP 应该提供一个无共享环境。在这种情况下,这意味着如果两个脚本并行运行,它们不应该相互干扰。在大多数情况下,这不是问题,因为不同的脚本使用不同的进程。(带有 mod_prefork、FastCGI、fpm 等的 Apache 模块)

But in some scenarios people use PHP as a module in a threaded environment. (Microsoft IIS module, Apache mod_mpm module etc.) If that is the case PHP can't rely on the operating system to separate context but has to do it itself.

但在某些情况下,人们在线程环境中使用 PHP 作为模块。(Microsoft IIS 模块、Apache mod_mpm 模块等)如果是这种情况,PHP 不能依赖操作系统来分离上下文,而必须自己完成。

One relevant area is the current working directory. The option you mentioned is about that and the name is misleading: it is not "Virtual Directory Support" but "Virtual Current WorkingDirectory Support". It is an abstraction for file system operations.

一个相关区域是当前工作目录。您提到的选项与此相关,并且名称具有误导性:它不是“虚拟目录支持”,而是“虚拟当前工作目录支持”。它是文件系统操作的抽象。

So when having two PHP requests in different threads and code like include "./foo.php";, you want that to be relative to the request's main script and not the global state of the environment. VCWD support does that. As it is only relevant for threaded environments enabling/disabling is bound to the setting whether PHP is built thread safe or not, which is done at compile time. Unless you need to, this is off.

因此,当在不同的线程和代码中有两个 PHP 请求时include "./foo.php";,您希望它与请求的主脚本相关,而不是与环境的全局状态相关。VCWD 支持做到了这一点。由于它仅与线程环境相关,因此启用/禁用与 PHP 是否构建线程安全的设置绑定,这是在编译时完成的。除非你需要,否则这是关闭的。

As a user you shouldn't care about it - it is not related to the ability to use streams or something from your PHP script.

作为用户,您不应该关心它 - 它与使用流或 PHP 脚本中的某些内容的能力无关。

回答by Florian Fida

Compiling with --enable-maintainer-ztsshould do it.
But make sure you know what it does, here is an explanation.

编译--enable-maintainer-zts应该这样做。
但请确保您知道它的作用,这里有一个解释