我可以配置环境特定内容吗? [英] Can I configure environment specific content?

查看:116
本文介绍了我可以配置环境特定内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与基于浏览器类型生成特定内容的方式相同,是否有一种基于运行PHP的服务器生成特定内容而无需引用服务器或站点名称的方法?

In the same way that you can generate specific content based on browser type is there a way to generate specific content based on the server running PHP without reference to the server or site name?

例如,PHP可以自动检测其所处的环境并配置数据库连接,ini_set等错误等方式,具体取决于它是开发,ITS,UAT还是生产环境。

For example, a way for PHP to automatically detect the environment it was in and configure things like DB connections, ini_set for errors etc. depending if it was a development, ITS, UAT or production environment.

我想到的两种方法是识别指示开发和QA环境的HTTP标头,或者在php.ini中拥有自定义属性。

The 2 ways I thought of were to recognise an HTTP header indicating development and QA environments or to have custom properties in php.ini.

我已经稍微醒来并发现了php函数来读取http标题,但php会覆盖我在Web服务器中设置的任何内容,我不知道它们是否可以在php.ini中设置。

I have woken up slightly and found out the php function to read the http headers but php overrides anything I set in the web server and I do not know if they can be set in php.ini at all.

我不知道是否可以向php.ini添加自定义值,但我有一个测试而ini_get找不到它(我在更改php.ini后重启了web服务器)当然)。

I have no idea if it is possible to add custom values to php.ini but I had a test and ini_get would not find it (I had restarted the web server after changing php.ini of course).

推荐答案

在IIS上使用FastCGI可以设置环境变量。它们似乎不适用于$ _ENV,但可以使用getenv(varname)检索。

Using FastCGI on IIS you can set Environment variables. They do not seem to be available to $_ENV but can be retrieved with getenv("varname").

要在IIS 5或6中配置FastCGI环境变量,您需要编辑:
C:\%systemdrive%\system32 \inetsrv\fcgiext.ini

To configure FastCGI environment variables in IIS 5 or 6 you need to edit: C:\%systemdrive%\system32\inetsrv\fcgiext.ini

例如:

[Types]
php=d:\Dev\PHP\php-cgi.exe
php:1=PHP Site 1
*=Wildcard Mapping

[d:\Dev\PHP\php-cgi.exe]
QueueLength=999
MaxInstances=20
InstanceMaxRequests=500

[PHP Site 1]
ExePath=d:\Dev\PHP\php-cgi.exe
EnvironmentVars=PHPRC:d:\Dev\PHP\,SiteType:Developer

在这个例子中它是IIS 5所以有只有一个站点,站点ID为1,如[类型]第2行所示。

In this instance it is IIS 5 so there is only one site and the site ID is 1 as indicated in line 2 of [Types].

在IIS 6上,您可能有多个站点,以下链接告诉您如何找到站点ID: http://weblogs.asp.net/owscott/archive/2005/07/29/how-to -find-the-siteid-in-iis5-and-iis6.aspx

On IIS 6 you may have multiple sites and the following link tells you how to find the Site ID: http://weblogs.asp.net/owscott/archive/2005/07/29/how-to-find-the-siteid-in-iis5-and-iis6.aspx.

一旦管理包用于显示管理包,就可以通过UI配置IIS 7已安装IIS 7.

IIS 7 can be configured via the UI apparently once the Administration Pack for IIS 7 has been installed.

这篇关于我可以配置环境特定内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆