How to enable the Virtual Directory Support php?

Mehmet Kaynak picture Mehmet Kaynak · Aug 21, 2014 · Viewed 41k times · Source

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

Answer

johannes picture johannes · Aug 21, 2014

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.)

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.

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 Working Directory 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.

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.