Need to host MoinMoin under IIS? No problem.
This is a free, easy to install IIS extenstion, written in Python. With it MoinMoin should run as fast as with FastCGI or mod_python, and its configuration is much easier than those.
Current version: 3.
Prerequisites
- Python 2.4+
PythonWin extensions: http://sourceforge.net/project/showfiles.php?group_id=78018; build 205 or later
MoinMoin 1.3.5 or like. Problems found with 1.5, sorry!
Installation
Install MoinMoin as usual, using its intallation instructions. I recommend you check your installation using .cgi first, to be sure it's ok with it. Be sure you've created /wiki virtual folder. Check HelpOnInstalling/InternetInformationServer for details.
Download MoinIIS.py file from attachments: MoinIIS.py and put it in some directory. Make sure it has no spaces in the path name, it appears that MoinMoin 1.3.5 has some bug for that case. Copy your wikiconfig.py into the same directory and edit it if need.
It happened that the original file was somehow deleted off this page, so I put newer version; it should work slightly better with attachment files named with national characters. Avoid it, BTW, found some bad bugs in cgi module and, that's wose, in IE file download.
- Configure MoinIIS.py; there are 2 parameters in the beginning of the file:
- Install the ISAPI extension:
- From the command prompt, go to the directory mentioned above and run:
MoinIIS.py install
If you have virtual server, use instead
MoinIIS.py --server=my.server.net install
That's all. Now try to reach http://your.server.net/themoin.
Remove
Just the same, but use
MoinIIS.py remove
If you have virtual server, use instead
MoinIIS.py --server=my.server.net remove
Settings
You can change the settings in the wikiconfig.py and MoinIIS.py anytime, there is automatic realoading and caching.
Known bugs
Spaces in the physical path are not allowed. Somewher in the moinmoin code, or my own Request object is not as nice as I thought Write me if you need it fixed.
Contacts:
Sergey Chernov, <sergeych AT tancher DOT com>. Feel free to email me.
Comments
Please put your ideas, impressions and any other comments there. Put there what you want to see in the next version and I'll try to implement it.
WSL3 (2006-02-16): I followed the installation instructions, and received the error message below. The setup is Windows Server 2003, pretty standard install, except the Web site is running on port 4040 instead of port 80. MoinMoin works fine as a plain CGI. Any ideas?
c:\MoinISAPI>python MoinIIS.py install ItemNotFound: WebServer IIS://LocalHost/W3SVC/1: The system cannot find the path specified.
Sergey Chernov: Well, looks like you have to specify server name, one that you see in the IIS management console; try it like this:
MoinIIS.py --server <server-name> install
Usually one needs it when there is more than one server on the IIS; maybe the port number is a part of the server name?
WSL3 (2006-02-20): I tried a number of ways of specifying the server name, with and without the port number -- no luck. I'm pretty sure that it's a security issue with Win2003 Server and IIS, and I'll dig into it on that asis.
However, I'm having another issue: I installed the same wiki on a Win2K box, and got it running as a CGI. Works perfectly. Installing MoinISAPI showed no error messages. However, once MoinISAPI was installed, any request for a page on the Wiki returns the following error message:
File "C:\MoinISAPI\MoinIIS.py", line 94, in HttpExtensionProc r = RequestISAPI(ecb) File "C:\MoinISAPI\MoinIIS.py", line 161, in __init__ self.accepted_charsets = self.parse_accept_charset(ac) AttributeError: 'RequestISAPI' object has no attribute 'parse_accept_charset'
(MoinMoin version 1.5.2, MoinIIS v.3, win32api build 207, all Windows updates applied to Win2K and IIS.)
Unfortunately, MoinMoin 1.5 is quite different and incompatible iwth this script, built to work with 1.3.5. I'm thinking on rewriting the code to work with 1.5.
SB (20-03-2006) - I'm running MoinMoin 1.5 with this script. I commented out the parse_accept_charset line, set auth_http_enabled, and fiddled with a unicode error: MoinMoinBugs/UnicodeErrorWithISAPIAndMoinMoinBeta and it works. I've lost some functionality (unicode characters in page titles, at least), but I can live with that
Question: Should I remove the CGI virtual directories before installing MoinISAPI?
Question: Is it appropriate to drop MoinISAPI directly into the /mywiki directory and install it from there, or is it better to put it someplace else (and have two copies of wikiconfig.py?
Answer: MoinISAPI needs the same virtual directory as CGI, one that contain some resources. MoinISAPI could be absolutely anywhere, its data and underlay directories could be placed with it or somewhere else, all you need is to alter wikiconfog.py properly. Actually I see no need to keep CGI having MoinISAPI up and running.
Tinyfish at 29-03-2007
I've modified the script to make it work for MoinMoin 1.5.7. This version hasn't been tested for long time, but seems stable so far. Thanks Sergey Chernov for the good script. The modified vesion is here: MoinIIS_for_1.5.py
Comments to older versions
Current version is 3. Issues below are supposed to be fixed, but are tested only on a few platforms.
(KevinTucker) I downloaded your current version dated Nov 10, 05 and tried it on my 1.5.0b3 site on Windows XP. Python is v2.4.1
When I run "MoinIIS.py install" or with the --server flag, I get the following:
C:\KevinData\WikiRaima>MoinIIS.py --server=krt01 install Traceback (most recent call last): File "C:\KevinData\WikiRaima\MoinIIS.py", line 12, in ? sys.path.append('C:\Moin\Lib\site-packages') NameError: name 'sys' is not defined
I am running it in the same folder as my wikiconfig.py. Is there something else I'm missing?
I put "import sys" at the top of MoinIIS.py and got a different error:
C:\KevinData\WikiRaima>MoinIIS.py install Traceback (most recent call last): File "C:\KevinData\WikiRaima\MoinIIS.py", line 15, in ? from isapi import InternalReloadException ImportError: No module named isapi
Then I added "import isapi" and got this error:
C:\KevinData\WikiRaima>MoinIIS.py install Traceback (most recent call last): File "C:\KevinData\WikiRaima\MoinIIS.py", line 8, in ? import isapi ImportError: No module named isapi
sergeych: well I forget to put import sys above os.path.append. Looks like you have no windows extenstions package installed (its from where isapi module comes from)
- My platform is:
- Windows XP / IIS 5.1
- Python 2.4.2
MoinMoin 1.5.0b2
- moinmoin = C:\moinwiki, wiki instance = C:\moinwiki\mywiki, python = C:\python24:
In my experiences:
the installation in the mywiki directory raises the following error:
Traceback (most recent call last): File "MoinIIS.py", line 17, in ? from MoinMoin import config, wikiutil ImportError: No module named MoinMoin
Since I don't know how to specify the library path in windows, I just copied moinwiki\lib\site-packages\MoinMoin into python24\lib\site-packages\MoinMoin to resolve it.
- After installed, the following error was raised:
Traceback (most recent call last): File "\\?\C:\moinwiki\mywiki\MoinIIS.py", line 77, in HttpExtensionProc File "\\?\C:\moinwiki\mywiki\MoinIIS.py", line 149, in __init__ AttributeError: 'RequestISAPI' object has no attribute 'parse_accept_charset'
- After I comment out the line 149, the following error was raised:
Traceback (most recent call last): File "\\?\C:\moinwiki\mywiki\MoinIIS.py", line 77, in HttpExtensionProc File "\\?\C:\moinwiki\mywiki\MoinIIS.py", line 154, in __init__ File "c:\moinwiki\Lib\site-packages\MoinMoin\request.py", line 181, in _load_multi_cfg self.cfg = multiconfig.getConfig(self.url) File "c:\moinwiki\Lib\site-packages\MoinMoin\multiconfig.py", line 153, in getConfig config = _makeConfig(configName) File "c:\moinwiki\Lib\site-packages\MoinMoin\multiconfig.py", line 92, in _makeConfig module, mtime = _importConfigModule(name) File "c:\moinwiki\Lib\site-packages\MoinMoin\multiconfig.py", line 43, in _importConfigModule raise error.ConfigurationError(msg) ConfigurationError: OSError: [Errno 2] No such file or directory: '\\\\?\\C:\\moinwiki\\mywiki\\wikiconfig.pyc'
-- SeungikLee 2005-11-10 02:17:48
Try to upgrade to MoinMoin 1.3.5+; my IIS-specific Request object is intended to run under this version instanse of MoinMoin. It should also work with later releases too.
Anyway. looks like it can't access wikiconfig.py. It must be in the same folder as MoinIIS.py. And it should be a vlaid wikiconfig.py file, suitable to run for .cgi instanse.
-- Sergeych
Now it works well on Moin 1.3.5, after inserted
sys.path.append('C:/MoinWiki-1.3.5/Lib/site-packages')
into MoinIIS.py before importing some from MoinMOin. The performance comparison should be estimated compared with original ones, and FastCGI ones. One buggy thing is that some css style is not applied to the pages generated from this isapi. From the html source, I found that it omits.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
comparing to the conventional one. I don't know whether this is a clue for the problem, it should be patched. -- SeungikLee 2005-11-10 04:02:46
Performance Report: I've compared 3 of deployments on windows. And the followings are my rough estimation.
Windows XP, Python 2.4.2, MoinMoin 1.3.5
- Apache 2.0 with FastCGI: 1 (response delay; not sec.)
- IIS 5.1 with ISAPI (MoinIIS): 1.5 ~ 1.9
- IIS 5.1 with CGI: 3 ~ 5
In conclusion, I think that it's very helpful to the IIS users if this continues to be debugged and supported for 1.5 or later.
-- SeungikLee 2005-11-10 04:59:17
- Sergeych: following issues are fixed in v.3. Thanks for tracking and fixing them!
At least in earlier versions of iis, http status codes are not properly forwarded. The culprit is in the finish method, where it sets the response to "200 Ok" if the response has not been set. Um, the response never gets set
def finish(self): RequestBase.finish(self) headers = '\r\n'.join(self.all_headers).encode('utf8') # begin patch response = self.getHeader('Status') if response: self.response = response # end patch if not self.response: self.response = "200 Ok" self.ecb.SendResponseHeaders( self.response, headers ) ... def getHeader(self,name): name = name.lower()+': ' for x in self.all_headers: if x.lower().startswith(name): return x[len(name):] # raise "some string exception" return None
This grabs the response supplied by Moin if it is supplied, and sets our response code to it. --cwillu
- Also, there seems to be a general issue with uploading attachments: it looks like the multipart handling is broken.
Replacing setup_args with the following seems to make it work (note, this makes the drawing editor work too):
def setup_args(self, form=None): from StringIO import StringIO ecb = self.ecb headers = {} headers['content-type'] = ecb.ContentType assert 'REQUEST_METHOD' in self.env assert 'QUERY_STRING' in self.env assert 'content-type' in headers data = StringIO() data.write(ecb.AvailableData) while data.len < ecb.TotalBytes: data.write(ecb.ReadClient()) data.seek(0) if ecb.Method.upper() == "POST": form = cgi.FieldStorage(fp=data, environ=self.env, headers=headers) elif form==None: form = cgi.FieldStorage(fp=data, environ=self.env) return self._setup_args_from_cgi_form(form)
Of course this is really ugly and so deserves a cleanup; better than nothing.
--cwillu
Long term perspective
I found http://code.google.com/p/isapi-wsgi/ - if that works it could be a good long term alternative, as moin will move more and more in the WSGI direction.
As moin 1.6.3+ already supports WSGI, no need to wait, you can start trying it right now.
-- ThomasWaldmann 2008-04-26 22:12:36
Confirmation:
- just tested isapi-wsgi 0.3 running moin 1.6.3 on IIS6.0 with python 2.5.1 (+extensions build 210) installed
- seems to speed things up pretty well