Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

toby's avatar
Level 31

Environment variables (SetEnv) on IIS 7.5

Hi everyone,

I'm (once again...) in the strange position where I have to deploy a (Laravel 5.2) application on a Windows Server 2008 R2 machine w/ IIS 7.5 installed. Everything is working correctly so far, but I can't figure out, how to use per site environment variables with IIS. On Apache, I used something like this to set environment variables:

<VirtualHost *:80>
    ServerName projecta
    ServerAlias localhost
    DocumentRoot "c:/www/projecta/public"

    <Directory "c:/www/projecta/public">
        Options Indexes FollowSymLinks ExecCGI
        Order allow,deny
        Allow from all
        AllowOverride All
        Require all granted
        SetEnv ENV production
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName projectadev
    DocumentRoot "c:/www/projecta/public"

    <Directory "c:/www/projecta/public">
        Options Indexes FollowSymLinks ExecCGI
        Order allow,deny
        Allow from all
        AllowOverride All
        Require all granted
        SetEnv ENV production
        SetEnv SHOW_PROFILER 1
    </Directory>
</VirtualHost>

Sure, I could use the .env-file, but the important thing I want to accomplish is, that I'll have two domains (intranet use only): http://project and http://projectdev and for each domain I want to set different values for some environment variables (note: I only want to edit the env-vars; the public root etc is the same)

Do you have any ideas?

Thanks in advance!

0 likes
2 replies

Please or to participate in this conversation.