Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Let's Configure Windows 2000 IIS with CGI Scripts ( Python, Perl, PHP...etc )

Okay, first just a teenie weenie plug. If you have any ideas for another help page let me know and I'd be happy to create it. Now, on with the show!

I assume that you already have IIS working correctly, that http://localhost or http://127.0.0.1 runs the Microsoft html files correctly, and now you are looking to run it with CGI scripts. This is not for Windows 2000 Server where issues of permissions take place. This is just a test system for your scripts.

This is my version update of the document "Howto configure IIS or PWS for Python/CGI scripts" but instead I'll be using the IIS program.

Windows 2000 offers the capability to setup multiple server scripts without resorting to regedit fixes. Personally, I'd never want to go in there if I can help it. The registry is a nightmare to troubleshoot, and any errors you make gives the OS the potential to happily kill it off for you. So don't go there. You should find this process listed below quick and painless.

If you're in a hurry, read here

Hey! Quick scroller! Follow the screenshots and click the buttons as indicated up to figure 6, (5 seconds) read a bit (30 seconds), then follow screenshots again up to figure 8 (1 second), read forward from here until the end of the document (3 minutes). You're done!

Details...

This will work with any CGI engine that has a Windows API version, for example: Python, PHP, and I'm assuming Perl Win32 (ActiveState). I tried to get this to run with Cygwin's version of Python, but it would not allow Windows2000 to see all the files (+4000) in the Cygwin /usr/bin directory. Rats. Oh well. So I loaded the Windows version from the official Python website. It works just fine. Here we go!

Step by Step Setup of IIS CGI's

Start | Programs | Administrative Tools | Internet Services Manager |
or
Start | Settings | Control Panel | Administrative Tools | Internet Services Manager |

figure 1

Right-click on Default Web Site | Properties |

figure 2

Home Directory Tab |

figure 3

Configuration Button |

figure 4

Add Button |

figure 5

Browse to your script engine to enter stuff here
*see troubleshooting notes below for this item

figure 6

After your Browse has entered the C:\PYTHON\PYTHON.EXE (or whatever you called it) into the box, append %S %S to it so it reads C:\PYTHON\PYTHON.EXE %S %S. These %S's are only required in Python and maybe Perl. PHP.EXE does not require this. I also added .CGI as the extention (normally .PY but can be whatever you like). For example, if this was a setup for PHP.EXE, I would set the extention to .PHP . Apply | OK everything.

*troubleshooting correction on case:
It's possible that this is case sensitive. One user reported an error with this. The fix was to do the setup all over again from scratch, and use small %s's instead. As my path and everything is in caps, I didn't have a problem. It really shouldn't make a difference, however to be on the safe side just make it all lowercase or try matching your case with the path information. If at the end of all this you have errors, remember to remove it and try again in small case letters.

*troubleshooting correction on spaces in filename
If rewritten as "C:\PYTHON\PYTHON.EXE" -u "%S" "%S" these quotes prevent errors in scripts with a space in the filename. The -u switch avoids extra CRs put in the newlines of a scripts' output (specifically a binary file). Lowercase -u is important here. This doesn't matter if you're outputting HTML.

Onward. One more major thing to do.

Go back to main window

figure 7

Right Click on Defaut Web Site | New | Virtual Directory

figure 8

Wizard

This will run a Wizard. The alias is however you want the server to call your working directory as a URL. So if you enter python here, in your browser it will be http://localhost/python/

The directory is where your working directory is located. This just points the server to your real files on the computer, which could be anywhere.

At some point you get to the permissions menu.

figure 9

If your test system is not connected to the Internet at all, just select everything. You must click on Browse so that you can see your working directory folder files. There may be an issue about blindly giving write access. This is only needed if your CGI files require to write.

So that you don't have to come back to this again, just turn it all on. It's not like you'll be running your website from your modem or DSL connection. If you are, then more documentation on the effects of these settings should be looked into.

That's it. Next | OK everything and you're done the Setup. Now test it. (Rerun the IIS server if you're having any problems.
Open the Command Prompt: Start | Run | cmd [[Enter]] or OK )

figure 10

Make a test script in vi or Notepad....
#!c:\python\python.exe

# Tell the browser how to render the text
print "Content-Type: text/plain\n\n"

print "Hello, Python!"  # print a test string

figure 11

Run it.

figure 12

I'm done. Good Luck!

If you found this useful please consider a donation in appreciation to Save Walter. Sorry to ask but I need some help. Thank you very much. If you have any more ideas for a help page tutorial please let me know and I'd be happy to create it.

Cheers

Walter Spicer

Modified January 5, 2003

contributors and troubleshooting notes:

If you have any suggestions or fixes please email (faqs at urbanware dot com) and I will place it below, and above in the appropriate text area. Thanks!

links

go back to last page
Save Walter
Python
ActiveState
NedstatBasic website stats

document history:

faq content copyleft © 2003 urbanware  
THE MATERIALS PUBLISHED HERE ARE PRESENTED "AS IS", WITHOUT WARRANTY OF ANY KIND TO THE EXTENT PERMITTED BY APPLICABLE LAW, AND WITHOUT ANY PROMISE OF VALIDITY AND/OR ACCURACY.