windows 我可以有多个 php.ini 文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/350880/
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
Can I have multiple php.ini files?
提问by Zack Peterson
I want to set the include_path
variable in my php.inifile (C:\Windows\php.ini
).
我想include_path
在我的php.ini文件 ( C:\Windows\php.ini
) 中设置变量。
But, I want different include_path
values for different sites hosted on the same Windows server. How can I do this?
但是,我希望include_path
在同一 Windows 服务器上托管的不同站点具有不同的值。我怎样才能做到这一点?
回答by Bill Karwin
http://php.net/manual/en/configuration.file.phpsays:
http://php.net/manual/en/configuration.file.php说:
php.ini is searched for in these locations (in order):
. . .
在以下位置搜索 php.ini(按顺序):
. . .
You can review this list and see if one of the techniques helps in your case. For example, you can set the environment variable PHPRC
, or you can put a different php.ini file in each current working directory, assuming each virtual host has a distinct cwd.
您可以查看此列表,看看其中一项技术是否对您有帮助。例如,您可以设置环境变量PHPRC
,或者您可以在每个当前工作目录中放置不同的 php.ini 文件,假设每个虚拟主机都有不同的 cwd。
Note that when using Apache and mod_php, or other module embedding PHP in the web server (e.g. FastCGI), the php.ini file is read once, at web server startup. When you use PHP in a CGI manner, the php.ini file is read during every web request, so you have more opportunity to use a different php.ini.
请注意,当使用 Apache 和 mod_php 或其他在 Web 服务器中嵌入 PHP 的模块(例如 FastCGI)时,php.ini 文件会在 Web 服务器启动时读取一次。当您以 CGI 方式使用 PHP 时,php.ini 文件在每个 Web 请求期间都会被读取,因此您有更多机会使用不同的 php.ini。
回答by TJ L
You can set the php include_path from an .htaccess file, assuming you have the correct AllowOverride settings in your httpd.conf file. Here's an example how:
您可以从 .htaccess 文件设置 php include_path,假设您在 httpd.conf 文件中有正确的 AllowOverride 设置。这是一个示例:
.htaccess
.htaccess
php_value include_path "d:\path\to\include"
回答by OIS
As I understand the question, its more important to have individual include paths for each server/site then multiple php.ini files? Id say keep your code in PHP as far as possible.
正如我所理解的问题,为每个服务器/站点拥有单独的包含路径然后多个 php.ini 文件更重要?我说尽可能将您的代码保留在 PHP 中。
Then you can just set the include_path with set_include_path or ini_set
.
然后你可以只设置 include_path set_include_path or ini_set
。
In apache you can set it in virtual domain or .htaccess file with php_value include_path "<first path to look>:<second path>:<etc>:."
. IIS probably has a similar method.
在 apache 中,您可以将其设置在虚拟域或 .htaccess 文件中php_value include_path "<first path to look>:<second path>:<etc>:."
。IIS 大概也有类似的方法。
回答by Powerlord
Unfortunately, I don't think you can. However, some webservers can change PHP settings on an individual basis... Apache using mod_php has the php_value setting that you can set on various virtual hosts, IIS might have something similar, but I'm not sure.
不幸的是,我认为你不能。但是,一些网络服务器可以单独更改 PHP 设置...使用 mod_php 的 Apache 具有您可以在各种虚拟主机上设置的 php_value 设置,IIS 可能有类似的东西,但我不确定。
set_include_path
can also override the include path at runtime.
set_include_path
也可以在运行时覆盖包含路径。
P.S. TF2 Engineer for the win.
PS TF2 工程师获胜。