简体   繁体   English

PHP FastCGI open_basedir 对 IIS 7 的限制

[英]PHP FastCGI open_basedir restriction on IIS 7

I have two environments on one server, which are separated via EnvironmenteVariable.我在一台服务器上有两个环境,它们通过 EnvironmenteVariable 分开。 That part works like a charm (two FastCGI pools with open_basedir has been set up to ApplicationHost这部分工作起来很有魅力(两个带有 open_basedir 的 FastCGI 池已设置到 ApplicationHost

<application fullPath="C:\\path\\to\\php\\php-cgi.exe" arguments="-d open_basedir=C:\\path\\to\\webroot\\ENV_DIR">

and related web.config和相关的 web.config

<add name="php" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\\path\\to\\php\\php-cgi.exe|-d open_basedir=C:\\path\\to\\webroot\\ENV_DIR" resourceType="Unspecified" requireAccess="Script" /> ). <add name="php" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\\path\\to\\php\\php-cgi.exe|-d open_basedir=C:\\path\\to\\webroot\\ENV_DIR" resourceType="Unspecified" requireAccess="Script" /> )。

Problem starts with open_basedir restriction for other folder(s) - like \\\\path\\to\\network\\folder or C:\\path\\to\\webroot\\FOLDER (which is outside the environment folder).问题始于对其他文件夹的 open_basedir 限制 - 例如\\\\path\\to\\network\\folderC:\\path\\to\\webroot\\FOLDER (位于环境文件夹之外)。 How to enable the access to these folder(s)?如何启用对这些文件夹的访问?

Have tried:试过:

  • separated php.ini files per environment with open_basedir="multiple;folders"使用 open_basedir="multiple;folders" 分隔每个环境的 php.ini 文件
  • add multiple folders to web.config and applicationHost file to arguments like following:将多个文件夹添加到 web.config 和 applicationHost 文件到如下参数:

'... open_basedir="C:\\path\\to\\webroot\\ENV_DIR;C:\\path\\to\\webroot\\FOLDER"'

Nothing seams to help.没有任何帮助。

Okay, found a solution.好的,找到了解决办法。 Maybe somebody else needs it as well.也许其他人也需要它。 Instead of using open_basedir, use doc_root (IIS only, if memory serves, PHP option).不要使用 open_basedir,而是使用 doc_root(仅限 IIS,如果没记错的话,PHP 选项)。 Here are examples:以下是示例:

applicationHost.conf file: applicationHost.conf文件:

<application fullPath="C:\\path\\to\\php\\php-cgi.exe" arguments="-d doc_root=C:\\path\\to\\webroot\\ENV_DIR">

and related web.config和相关的web.config

<add name="php" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\\path\\to\\php\\php-cgi.exe|-d doc_root=C:\\path\\to\\webroot\\ENV_DIR" resourceType="Unspecified" requireAccess="Script" />

In this way, you are able:通过这种方式,您可以:

  • set up instance-based environment variables (.env under Linux);设置基于实例的环境变量(Linux 下的 .env);
  • able to include and/or use directories outside instance root folder.能够包含和/或使用实例根文件夹之外的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM