Re: wfastcgi on IIS ... no more wfastcgi.py script?

5,016 views
Skip to first unread message
Message has been deleted

Tim Richardson

unread,
Dec 13, 2015, 11:45:21 PM12/13/15
to web2py-users


On Monday, 14 December 2015 13:36:05 UTC+11, Tim Richardson wrote:
wfastcgi is now a module on PyPi

after installing it, the scripts directory has wfastcgi.exe and an enable executable:  wfastcgi-enable.exe
There is no wfastcgi.py

However, running wfastcgi-enable.exe from an Admininistrator command prompt makes a change to IIS configuration.
It adds a handler for fastcgi which points to  site-packages/wfastcgi.py 

But from IIS I get: 


HTTP Error 500.0 - Internal Server Error 
<handler> scriptProcessor could not be found in <fastCGI> application configuration



OK. So I updated web.config like so:


 <system.webServer>
 
<handlers>
           
<add name="Python FastCGI"
           
path="*"
           
verb="*"
           
modules="FastCgiModule"
           
scriptProcessor="e:\python27_32\python2.7.exe|e:\python27_32\lib\site-packages\wfastcgi.pyc"
           
resourceType="Unspecified"
           
requireAccess="Script" />
   
</handlers>

and allowed the text file to update handlers (Server node->Feature Delegation -> Handler Mappings to Read/Write).
This means that IIS will read the text file and store the configuration it finds, so that I now see under the site which I call web2py 
handlers -> Handler Mappings

there is a value under Executable (optional) matching the scriptProcessor value above. 

Now I get 

HTTP Error 500.0 - Internal Server Error

<handler> scriptProcessor could not be found in <fastCGI> application configuration

Message has been deleted

Tim Richardson

unread,
Dec 14, 2015, 12:21:47 AM12/14/15
to web2py-users
Ok. Some tips to a future me if I have to do this again.

wfastcgi is now a module. So currently the deployment instructions in the web2py book give a download link. It's not necessary any longer. But some paths have changed, and the configuration process is more automated.
 

1) install it with pip

2) as administrator command prompt, run the executable PYTHON_ROOT/Scripts/wfastcgi-enable.exe 
This will update your IIS config. It seems to change the FastCGI setting at the server level of the config

It also sends some output to standard output, as described in the readme at the pypi page above.

If you follow the deployment instructions in the web2py book, you will have a web.config file at the root of your web2py folder. 

To finish updating the IIS configuration, you could copy the settings from https://pypi.python.org/pypi/wfastcgi into the web.config page. 
This meant, for me, adding a section like this:

<system.webServer>
 
<handlers>
           
<add name="Python FastCGI"
           
path="*"
           
verb="*"
           
modules="FastCgiModule"
           
scriptProcessor="e:\python27_32\python2.7.exe|e:\python27_32\lib\site-packages\wfastcgi.pyc"
           
resourceType="Unspecified"
           
requireAccess="Script" />
   
</handlers>

    I didn't have the handlers section in the existing file. The scriptProcessor value involves a pipe. You can copy that value from the output of step (2). 
When IIS starts, it will read from the file and update its configuration. But it can only do that if you change Feature Delegation -> Handler Mappings to Read/Write. It defaults to Read, which means the server gives errors at start up which look like this: "The requested page cannot be accessed because the related configuration data for the page is invalid"

Get that sorted, and IIS will copy into its configuration the correct setting. You can observe by going to the site setting for your web2py app in IIS configuration, and views Handler Mappings. There you will see a handler Python FastCGI configured according to the path above. You could bypass the text file and set this up in IIS settings directly, per screen shot. If you have existing IIS setup, you could probably just change the path. I didn't know what I was doing so I didn't take this shortcut. 







 

Massimo Di Pierro

unread,
Dec 18, 2015, 3:01:02 AM12/18/15
to web2py-users
Could you put this in the book? Thanks Tim.

Johann du Preez

unread,
Apr 4, 2017, 9:33:15 AM4/4/17
to web2py-users
This helped me a lot. Thanks. Do you know if the 'scriptProcessor' can be set relatively?

Marcelo Huerta

unread,
Feb 14, 2018, 2:07:15 PM2/14/18
to web2py-users

El viernes, 18 de diciembre de 2015, 5:01:02 (UTC-3), Massimo Di Pierro escribió:
Could you put this in the book? Thanks Tim.



I think that in spite of your request this has not yet been updated in the book. I still see a mention of a script called "wfasctgi.py" (sic), and nothing about this new methodology. 

Pbop

unread,
Feb 14, 2018, 7:59:12 PM2/14/18
to web2py-users
For what it is worth, I have web2py deployed under IIS using the ISAPI recipe and web2py screams in speed. The only requirement is the code has to be thread safe and have not yet run into thread safe problems in how we deploy web2py. If it is, you will get much faster performance over fastcgi. 

Dustin Esposito

unread,
Jul 23, 2019, 11:27:23 PM7/23/19
to web2py-users
How would you move a site from a python web server to IIS 8?
Reply all
Reply to author
Forward
0 new messages