I initially set up a website on a LAMP server, but my employer needs it moved to a WISP (windows/iis/sql server/php .. I don't think this is a real term?) server, which I have done. I'm using IIS v 6, and I read that there is no SetEnv
equivalent where you can set _SERVER
variables. I rely on these variables for some configuration like the DB user/password and a site key for hashing. I'd strongly prefer to keep these out of the php code for security reasons.
The only solution I can think of is setting such variables with php.ini. I believe you can set a default DB connection, but I'd prefer not to do this anyway. Does php.ini have a SetEnv
equivalent?
If not, is this possible to do with IIS anyway?
For example I want to be able to use a custom _SERVER[db_user]
or _SERVER[site_key]
. In my current .htaccess I have
SetEnv db_user tandu
SetEnv site_key blocked_for_your_protection
You set server variables in your php.ini
file. Check the output of a phpinfo()
command where this file is on your server.
Have a look at the documentation about the php.ini settings.
To edit the _SERVER
settings, you have to set those directly in your server:
Apache: works with htaccess and SetEnv
IIS: http://www.php.net/manual/en/function.putenv.php in your *.php file or in the config:
<serverVariables>
<set name="db_user" value="abc" />
<set name="site_key" value="abc" />
</serverVariables>
See http://forums.iis.net/t/1171675.aspx
You can check your result on your phpinfo page. The variables must occur there!