TABLE OF CONTENTS
1. Read this first
This documentation is for the version 1.2 of MoinMoin!
The docs are in HelpOnInstalling/ApacheWithFastCgi and HelpOnInstalling/ApacheWithModPython, cause it could be used on any operating system on which mod_python and FastCGI run. This is at least Unix and Windows, and perhaps MacOS X. Basic installation and OS specific installation is the same as for a CGI, you just need the apache module and a different thing than the ScriptAlias directive to configure it.
2. mod_python execution process in a nut
Clarification of the mod_python run process:
- apache sees the .htaccess
- if the URI matchs the Files section, it is 'executed'
SetHandler tells apache to use mod_python for everything in the 'File'
PythonPath extends sys.path
PythonHandler tells mod_python what to do to handle requests. this is a module to import!
mod_python tries to import moin_modpy(.py) (so this must be in sys.path!)
moin_modpy.py imports some MoinMoin stuff (so moin_modpy needs a sys.path in which the MoinMoin package can be found)
- mod_python calls the method handler of moin_modpy
2.1. Questions & Answers
"Hello. I'm just following your Instructions on this Site. But i'm unable to show my Server (works fine with cgi-version of MoinMoin), from which place he should take the Instance of the new wiki (driven by mod-python-Handler). I couldn't understand, how the Handler works..."
At least someone who tries, thanks. What did you do? What version of moin, apache, and mod_python do you use?
- Using base SuSE 9.0 with:
- Apache 1.3.28
- mod_python 2.7.8
- Python 2.3+
MoinMoin 1.2 von 20040124
you should consider using mod_python 3.1.2b with apache 2.0.48 in combination with python 2.3.X. We had some problems with py 2.3 and mod_python versions below 3.1... but I don't think that this is your problem.
- Moved .htaccess-File to Root-Dir of ...
- Document-root of the apache-webserver AND
- "Root" of the wiki-instance, mostly named as "mywiki"
no, only one htaccess, please!
- I think, the "howto" is unclear, where i had to put the .htaccess. I mean, it must be the "root" of the wiki-instance.
no, the .htaccess must be in the path below which you instance should be, you don't need a path for it, cause it's only virtual.
Use the wrapper-script: moin_modpy.py, using the correct path
- Using base SuSE 9.0 with:
mod_python is correctly enabled and works (tested with Spyce )
Many greetings from Hannover... And please excuse my rotten-english
I'm german. greetings from Koblenz.... perhaps you could come into the irc for a more direct discussion? channel #moin on FreeNode server irc.freenode.net
- Thanx, maybe, that i would answer today evening... IRC is not allowed from my workplace and from my home-net too because of SECURITY. Do you have ICQ? Or should we use Mail?
yes, I have ICQ, mail me to <ograf AT rz DASH online DOT net>
- Thanx, maybe, that i would answer today evening... IRC is not allowed from my workplace and from my home-net too because of SECURITY. Do you have ICQ? Or should we use Mail?
- Some questions to you (these are the questions the doc ask you):
- where should your wiki could be found (URL and corresponding physical path)?
http://servername/TEST/ and /usr/share/moin/TEST/ as described in the MoinMoin-Install.html
where is the MoinMoin python package installed?
Does this question mean:
/usr/lib/python/site-packages/!MoinMoin (this is the Path under SuSE 9.0)
- this means: you don't need to specify the path for this in moin_modpy.py wrapper.
- where is the moin_modpy.py wrapper?
/usr/share/moin/TEST/
this path must be added in the PythonPath entry in the htaccess
- where is moin_config.py?
/usr/share/moin/TEST/
- already added in the last step.
Path of the Apache-Document-Root:
/srv/www/htdocs/
- Place of the .htaccess-file
correct. here should be the .htaccess. it should have an entry <Files TEST> so that you can access your wiki below TEST.
- where should your wiki could be found (URL and corresponding physical path)?
What has happened since this Dialog?
Why am i interested in "getting for flying faster versions of MoinMoin"?
- I try to build a great inhouse-intraweb-wikiweb-community for my company...
What did i do, to get MoinMoin running in faster Versions?
- Switched to Apache 2.0.48, newer mod_python version (shipped with SuSE 9.0 is 3.0.x)
Tried newest mod_python version 3.1.2b (can't compile this whith SuSE 9.0, i am an Apache-Newbie )
- Started to get FastCGI running
Works after 2 working nights!!
MoinMoin is very fast, didn't make a benchmark, only the feeling is very very fast!!!
Thank you, JH and OG and TW and all others for your work, i would try to develop with MoinMoin in this year...
My own Wiki (at home, behind t-dsl) is here: http://www.pronobis.net/KH/ (almost the old version whith "slow" Apache 1.3.x and normal CGI-Based MoinMoin, would update this next days )
Question: Do you have any corrections for the install docs above? Did you stumble over some errors? Or are there places where the docs are misleading? -- OliverGraf 2004-02-01 08:13:00
- I already added to the docs in moinmaster: In SUSE 9.0 (and I suppose in some other distributions too) reading of .htaccess is swiched of by default in http.conf with
* forbid access to the entire filesystem by default <Directory /> Options None AllowOverride None Qrder deny, allow Deny from all </Directory>
to allow reading .htaccess you have to add to http.conf (In suse it is in http.conf actually recommended to create a new http.conf.local and include it in /etc/sysconfig/apache2).<Directory "/src/www/htdocs" # this is the document root in Suse AllowOverride All # AllowOverride Options FileInfo might be work too </Directory>
--added by KonradBauckmeier 25.03.2004
If you are using somewhat like data_dir = './data', consider using an absolute path.
I'm so confused at this point as to what files need to be where and what needs to be edited. Perhaps most of all is the httpd.conf file. Using CGI I just used ScriptAlias /mywiki "D:/Moin/mywiki/moin.cgi" . Seeing as I'm now trying to use mod_python to run it, I'm not supposed to use this file anymore. Ok, fine, but what do I tell Apache to run instead? Everything I've been able to come up with hasn't worked. Any help would be much appreciated.
Did you read the docs? They where moved to HelpOnInstalling/ApacheWithModPython for the 1.2 release.
Yes, several times actually, trying to figure out if I was missing something. How does Apache know how to deal with the wiki under mod_python? That's the part I'm missing. Like I said, previously I used ScriptAlias, but if I still use that (and not use the cgi file), what do I put in its place?
hmmm... the docs tell you to use .htaccess... can you come into the MoinMoinChat?
Can't get into the chat while at work, which is where the wiki is. .htaccess, as I understand it is a directory specific configuration file for Apache. If I say ScriptAlias /mywiki "D:/Moin/mywiki/.htaccess" I get an error "Forbidden". Is there an example somewhere of a working mod_python httpd.conf file? Or at least the last few lines of it is all I need I suppose.
please show me the place in the docs that tell you to define an ScriptAlias. you don't need config in your httpd.conf. just the .htaccess file. The <Files> statement lists the name of your wiki. See the comments in those files.
In the basic MoinMoin installation is the ScriptAlias (for the cgi install). The mod_python version says to follow the basic installation, but don't copy the moin.cgi file as it isn't needed for mod_python. So, without ScriptAlias, what do I put where (I assume httpd.conf) to tell Apache how to deal with a request to http://myserver/mywiki ? I've tried Alias /mywiki 'D:/Moin/mywiki/.htaccess' . If you like, I can post some files and you can tell me what I have wrong. It's just that, IMO, the CGI installation is quite clear, with examples, as to what files to edit, what to add, etc. The mod_python installation just refers to some files and implies what needs to be added, no examples (except the fix to mod_python so as to run it without the wrapper).
- Thought I'd add some file excerpts:
- httpd.conf (since Apache needs to know how to deal with the inital request):
Alias /wiki/ "D:/apps/python23/share/moin/htdocs/" Alias /wikidata/ "d:/Moin2/wikidata" Alias /pdwiki "d:/Moin2/pdwiki/"
get rid of the last alias
- htaccess (located in d:\Moin2\pdwiki)
put this into d:\Moin2 (this should be your DocumentRoot)
<Files pdwiki> # Use mod_python as handler SetHandler mod_python # set the path to the MoinMoin package and to the moin_config.py PythonPath "['D:\\apps\\Python23\\Lib\\site-packages\\MoinMoin','D:\\moin2\\pdwiki']+sys.path" # choose the ModPy Request class as handler PythonHandler MoinMoin.request::RequestModPy.run </Files>
If this is modpy 2.7, use python-program instead of mod_python
Any other files I should include? Like I said, the error that I'm getting is 403 Forbidden
alternate: if you keep the alias and the position of .htaccess, you need to use http://localhost/pdwiki/pdwiki to access your wiki.
When you say "document root", is that a reference to the location of the wwwroot? http://localhost/ ?
yes DocumentRoot refers to the DocumentRoot apache configuration Directive.
- All that I've accomplished is that I'm listing the directory /pdwiki. It's behaving like it doesn't have anything to execute
My setup has no Alias at all. just one htaccess. If all paths a listed there everything should be fine... on Windoze it should be just the same way. What versions are you using?
Mine has the Alias because the DocumentRoot directory is d:\wwwroot and the MoinMoin directory is d:\moin2
Mhhhh.... I just saw that you tried to use the .htaccess with ScriptAlias. Perhaps you should first read the Apache config before trying to use mod_python for anything? .htaccess are used automagically by apache, at least if you don't switch this of (AllowOverride, Options)
OK, I'm giving up on getting mod_python to run MoinMoin with mod_python, at least for now. I've decided that the instructions necessary to accomplish this are extremely poor. Whoever wrote the instructions seriously needs to go back and redo them. Contrary to the belief, just making a couple editing changes is not going to get this to work (certainly not with little to know example documentation). I don't have the time at work to waste trying to get this going anymore. Getting the CGI version going was far easier, if far slower. Perhaps I will come back to this someday, but I don't have the time for it anymore.
Thanks! You are invited to extend the docs until you understand them. It seems I fail to understand the problems. Perhaps you could try twisted? But I'm not sure if it works with windows. FastCGI will get you into the same problems as mod_python, cause you need quite some apache knowledge to understand how it works. I don't aim at newbies with this setup, cause my understanding is that you should knwo what you use, cause usage of such a thing as a server without knowledge normally is very dangerous...
I've made so many changes to my setups I'm not even sure what's what anymore, and perhaps that's part of my problem. I have no idea what I'm supposed to type to actually access MoinMoin. I really do want this to get working, but I'm getting extremely frustrated with how this is behaving. I want to be able to type http://localhost/pdwiki and actually run this with mod_python. I can get that to work in any number of ways with CGI, but this seems a lot more picky. Now that I have actually created a pdwiki directory in the DocumentRoot directory, all I ever get is a directory listing. It's not so much that I've never used Apache before, it's that I've never used anything but some more or less stock CGI to get running. The mod_python is the really new part for me. I can get it to run simple scripts, but I always have to type the script name into the URL to get it running. What setup information would you need to know in order figure this out? Config files, directory locations, etc.? Sorry about my snippy attitude, I've just been getting extremely frustrated since I never have this much problem with computers.
Correct me if I'm wrong, but don't the installation instructions make the assumption that when I go to http://localhost/ that the wiki is supposed to run? I want to serve just regular HTML from that location, but when accessing http://localhost/pdwiki I want to see the wiki then.
Last try ...
Install moin lib to some place. This means lib\python\MoinMoin. Let's assume its in M:\Moin\lib
- Install moin share to some place. Let's assume M:\Moin\share. Inside is moin\cgi-bin and moin\htdocs and the default moin\data dir.
- Setup your wiki. Lets assume in M:\Moin\wiki. Inside you have a copy of the data dir and your moin_config.py
Note on moin_config.py: In contrast to a cgi installation data_dir = "./data" is not working. You need to change it to "M:\Moin\wiki\data".
Setup your docroot. This is the path configured with DocumentRoot apache directive. Let's assume it's in M:\Moin\www
- Copy everything from share\moin\htdocs to M:\Moin\www (one theme, classic for example, is enough for a test).
- NOTE: Easiest way to do this was use of Alias in httpd.conf for /wiki, as in the CGI installation
- Configure apache (I'm not sure if you need quotes around the values with windoze):
DocumentRoot M:\Moin\www
Copy the example moin_modpy.htaccess as .htaccess (not sure if you can make a .htaccess with windows. look into the apache docs how you must name it so that apache will accept it). Change <Files wiki> to <Files pdwiki>, cause there you want to have your wiki. If this is apache 1 and mod_py 2.7, change SetHandler mod_python to SetHandler python-program.
- It is possible to make .htaccess in windows, but it has to be done from the command-line (because that's intuitive)
Adapt the PythonPath setting in your .htaccess to list the path to the moin_modpy.py wrapper: M:\Moin\share\moin\cgi-bin The whole .htaccess should read:
<Files pdwiki> SetHandler python-program PythonPath "['M:\Moin\lib\python','M:\Moin\wiki','M:\Moin\share\moin\cgi-bin\']+sys.path" PythonHandler moin_modpy </Files>
Adapt moin_modpy.py wrappers path so it can find your moin_config.py and the MoinMoin package:
import sys sys.path[0:0]=['M:\Moin\wiki', 'M:\Moin\lib\python']
- This should work (no guarantee for the path stuff with those backslashes, cause windoze really sucks, as you should know...).
Got it! I made a couple modifications to your directions when I did it, but it does now work. Thanks a lot for the help! As soon as I get a chance, I'll try to update the directions. Perhaps some of it was a quirk with Windows. yes, I know it sucks, but I have no options at work. Of course, I only use it for games at home, I have Linux for everything else. As for the backslashes, it seems to me that it worked with either a double backslash or a single forward-slash.
*pfft*, now I'm happy Yep, sure, double backslashes in python strings. My fault. And yes, please try to update or write down your experiences, so the next one daring to use mod_python does not have to get annoyed by me, too ;-)
Works here on Windows as well (Apache 2.0.48, bug-fixed modpython 3.1.2b, MoinMoin 1.2.1). For me it took a while to figure out that data_dir in moin_config.py needs to be changed in contrast to cgi installations (see note added above). Another question:
Can I run several Wikis with mod_python on the same server. My initial experiments indicate that it is not possible. No matter which wiki I access, I allways get the FrontPage of the Wiki that I visited first after starting Apache. I still hope that I am wrong and that it is possible. -- DavidLinke
i'm having problems running moinmoin under FastCgi. On preview and other misc operations (e.g. UserPreferences) I see the full headers displayed on the webpage along with a big *OK* in the middle. The apache error logs show me:
[Fri Jul 9 16:43:11 2004] [error] [client 192.168.1.66] FastCGI: comm with server "/usr/local/share/moin/espresso-wiki/moin.fcg" aborted: protocol error: invalid version: 34 != FCGI_VERSION(1)
The number (34) varies from time to time. I've googled for the problem a bit and I understood the problem might be related with MoinMoin spewing output on stdout or stderr when it's not supposed to. Turning off fast cgi solves the problem, but slows down the wiki too much. Any idea?
Are you using custom macros incompatible with moin 1.2? Ones that output stuff with sys.stdout instead of using the request instance to do it? -- OliverGraf 2004-07-10 19:40:28
I don't think so. I will paste the content of the page in /BugExample That would be a fine explanation, however. -- TheAnarcat
That page does not invoke any macros, so it is not the problem... -- OliverGraf 2004-07-16 21:23:31
I know... but it still breaks. I have run more tests, and this is really odd. I have tried to put together a page that reliably breaks, but it doesn't seem to be working: the page sometimes breaks, sometimes doesn't. It's really odd. The problem is probably elsewhere. -- TheAnarcat 2004-07-16 21:33:30
Could you please give an exact version breakdown of all used components? Did you run the thing as cgi to see the the stuff that causes the problem? -- OliverGraf 2004-07-17 06:57:14
Okay.. I don't recall exactly the versions of everything, but it's MoinMoin 1.2.2, running on Apache 1.3.29 (iirc) and using some fastcgi version I will precise when I get back to work next week. Also, I have tried running moin as a simple CGI and it works fine. -- TheAnarcat 2004-07-17 16:38:30
- The cgi moin should get the same problems. You should get error pages and the error log should show something like invalid headers, if it is pre header output...
A good idea is to come to the MoinChat, but only if you have your buggy setup at hand, so we can find the problem with it.
- I don't get any errors using cgi moin. I am in #moin, but I don't have the buggy setup, although I have pretty good knowledge of how I set it up. Maybe we could meet there monday or something?
I am online every weekday from about 08:00 till 16:00 CEST (thats GMT+0200). -- OliverGraf 2004-07-17 17:48:36
- I don't get any errors using cgi moin. I am in #moin, but I don't have the buggy setup, although I have pretty good knowledge of how I set it up. Maybe we could meet there monday or something?
- The cgi moin should get the same problems. You should get error pages and the error log should show something like invalid headers, if it is pre header output...
Here is my detailed config:
LoadModule fastcgi_module libexec/apache/mod_fastcgi.so #... AddModule mod_fastcgi.c #... AddHandler fastcgi-script fcgi fcgi fpl fcg Alias /moinmoin/ "/usr/local/share/moin/htdocs/" Alias /moin/ "/usr/local/share/moin/espresso-wiki/moin.fcg/" <Location "/moin/"> Options +ExecCGI Order allow,deny Allow from all </Location>
Running moinmoin 1.2.2 + apache-mod_ssl 1.3.27+2.8.14 and mod_fastcgi 2.4.2.
ScriptAlias tells apache to handle moin.fcg as a cgi script. That is no good. Strip the Scirpt from the Alias. -- OliverGraf 2004-07-10 19:40:28
Done. I have modified the config to reflect the changes above. Thanks for the support, btw, it's really appreciated. -- TheAnarcat 2024-11-22 07:17:49
Where would be a good place to mention that mod_python is not available for Python24, and that fastcgi for Python doesn't work under Windows?
- Are you sure that it does not work? I found references that it should be possible.
Because those references were quite weak, I decided to implement it by myself. It is finished and should be in 1.3.2 if we cannot find any bugs. So you will be able to enjoy fastcgi support on Windows by running MoinMoin as an external fastcgi server.
I'm having constant problems doing searches in the wiki setup with FastCGI. I see this:
[Thu Aug 25 17:49:07 2005] [warn] FastCGI: (dynamic) server "/usr/local/www/wiki/koumbitwiki/moin.fcg" restarted (pid 31342) Traceback (most recent call last): File "/usr/local/www/wiki/koumbitwiki/moin.fcg", line 36, in ? fcg.run() File "/usr/local/lib/python2.4/site-packages/MoinMoin/support/thfcgi.py", line 577, in run (conn, addr) = self.sock.accept() socket.error: (35, 'Resource temporarily unavailable') [Thu Aug 25 17:49:07 2005] [error] [client 68.142.251.99] FastCGI: incomplete headers (0 bytes) received from server "/usr/local/www/wiki/koumbitwiki/moin.fcg" [Thu Aug 25 17:49:07 2005] [warn] FastCGI: (dynamic) server "/usr/local/www/wiki/koumbitwiki/moin.fcg" (pid 31342) terminated by calling exit with status '1'
Here is my fcgi setup:
<VirtualHost *:80> ServerName wiki.koumbit.net Alias /_static/ "/usr/local/share/moin/htdocs/" <Directory "/usr/local/share/moin/htdocs/> Order deny,allow Allow from all </Directory> RewriteEngine On RewriteLogLevel 0 ## static files are somewhere else? ok... RewriteRule ^/_static(.*)$ /usr/local/share/moin/htdocs/$1 [last] ## map everything else to moin.cgi/moin.fcg <IfModule !mod_fastcgi.c> RewriteRule ^(.*)$ /usr/local/www/wiki/koumbitwiki/moin.cgi$1 [type=application/x-httpd-cgi] </IfModule> <IfModule mod_fastcgi.c> RewriteRule ^(.*)$ /usr/local/www/wiki/koumbitwiki/moin.fcg$1 [type=application/x-httpd-fcgi] </IfModule> <Directory "/usr/local/www/wiki/koumbitwiki"> allow from all AllowOverride None Options ExecCGI FollowSymLinks order allow,deny SetHandler fastcgi-script </Directory> </VirtualHost>
I'm at a loss... I'm very tempted to switch to a twisted setup, but I don't want to run another webserver on the machine... -- TheAnarcat 2005-08-25 17:55:03
This is because the slow text search runs to long. You could either switch to a recent version with a search indexer (which has currently drawbacks, too) or you could raise the timeout value for that FastCgiServer (see the fastcgi docs how the option is called and set). -- OliverGraf 2005-08-25 18:04:12
- Hmm... That's just probably it! Searches are taking forever here (~22 secondes). I'll try to re-enable lupy and bump the timeout... It's the -idle-timeout we're talking about?
FastCgiConfig -idle-timeout 60
is that right? -- TheAnarcat 2005-08-25 18:24:05
Yep. Perhaps use FastCgiServer /path/to/your/fcg -idle-timeout 60 -processes 1. -- OliverGraf 2005-08-25 18:45:29
That seems to work pretty well! I have used a 90 second timeout just to be sure. I have yet to see a single warning, when before I was having a few per minute. I'll try to turn off lupy to see if it still holds. -- TheAnarcat 2005-08-25 19:15:27
- Hmm... That's just probably it! Searches are taking forever here (~22 secondes). I'll try to re-enable lupy and bump the timeout... It's the -idle-timeout we're talking about?