Installation

Installation processes will vary from server to server and application to application. Currently, IIS6 (Server 2003) and IIS7 (Vista & Server 2008) are officially supported, although Cassini (Visual Studio development server) will work as well, seeing as that's what I use for development.

Installation in general is quite simple:
  • Create application directory
  • Mark as application
  • Copy files
  • Edit web.config
It's the details of those steps that vary from server to server.

There are two supported scenarios: IIS Classic and IIS7 Integrated. IIS Classic is used when running on IIS 6, IIS 7 Classic pipeline mode, or IIS 7 without NWSGI installed. IIS7 integrated mode is available when NWSGI is installed on the server. IIS7 Integrated is the easiest scenario to deploy to as the NWSGI assembly does not need to be copied, the configuration is simpler, and it can be managed using the IIS 7 Management Console; however, it requires that the server administrator install NWSGI. IIS Classic requires the NWSGI assembly be included in the web site and a bit more configuration, with no management UI.

NWSGI works in medium trust, with two caveats: debug must be "false" (the default), and many existing Python libraries won't work in medium trust.

Steps

First, create a directory that your application will be installed. This directory will hold at least the .wsgi file that runs the application and (possibly) the NWSGI and IronPython binaries. Copy the .wsgi file into this directory.

Next, the web server needs to know that this is an application. This can be done from the UI for IIS6 and IIS7, but IIS7 has a very nice command line:
 appcmd add app /site.name:"Default Web Site" /path:/<apppath> /physicalPath:<diskpath>

Replace <apppath> with the url you wish to use, and <diskpath> with the path to the folder created in step 1.

For IIS Classic, create a bin folder and copy NWSGI.dll, Microsoft.Scripting.dll, Microsoft.Scripting.Core.dll, Microsoft.Scripting.ExtensionAttribute.dll, IronPython.dll, and IronPython.Modules.dll into it.

For IIS7 Integrated mode, create a bin folder and copy Microsoft.Scripting.dll, Microsoft.Scripting.Core.dll, Microsoft.Scripting.ExtensionAttribute.dll, IronPython.dll, and IronPython.Modules.dll into it. Unfortunately the IronPython and Microsoft.Scripting assemblies are not installed in the GAC, so they must be copied with the app.

If you are running IIS6, it needs a script mapping for *.wsgi that forwards it to the ASP.NET ISAPI dll.

Finally, edit web.config to contain:
IIS Classic:
<?xml version="1.0"?>
<configuration>
    <system.web>
        <httpHandlers>
            <add verb="*" path="*.wsgi" type="NWSGI.WsgiHandler" />
        </httpHandlers>
    </system.web>
    <system.webServer>
        <handlers>
            <add name="WsgiHandler" path="*.wsgi" verb="*"
                type="NWSGI.WsgiHandler, NWSGI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=41e64ddc1bf1fc86" 
                resourceType="Unspecified" />
        </handlers>
        <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
</configuration>

IIS7 Integrated:
    <system.webServer>
        <handlers>
            <add name="WsgiHandler" path="*.wsgi" verb="*"
                type="NWSGI.WsgiHandler, NWSGI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=41e64ddc1bf1fc86" 
                resourceType="Unspecified" />
        </handlers>
    </system.webServer>
NOTE: You must use the four part name for the type attribute if NWSGI is installed in the GAC.

You should now be able to hit http://localhost/<apppath>/<whatever>.wsgi/ and see your application.

Others

Most other ASP.NET servers (Cassini and Mono's xsp2) follow the IIS Classic instructions.

Last edited Oct 3, 2009 at 5:45 PM by jdhardy, version 6

Comments

No comments yet.