Contents
- url.com versus url.com/wiki problem
- How to make RECENT CHANGES go back further in time
- MoinMoin with Fedora 14
- Invalid escape
- Farmconfig matching
- Moving several wikis to a wiki farm - (Problem)
- Standalone server - TCP Interfaces
- Invalid syntax error after editing wikiconfig.py
- Customising quick links and the available actions
- Default User Preferences
- EOL while scanning single-quoted string
- Where is moin_config.py?
- Another port for the DesktopEdition
- Troubleshooting Configuration
- Farm with Desktop Edition
- Force User Logout On Browser Close
- How to configure a wiki farm running MoinMoin via Apache with mod_python
- How to get spaces in the page_front_page
- Disable ErrorLogs in webbrowser, enable only in flat files
- Even when I edit wikiconfig.py, surge protection won't turn off
- wikiconfig.py doesn't seem to be loading
- CGI-Fehler
- Supress URLs
- Trying to enable discussion pages
- Preventing the script name from appearing when using mod_python
- navi_bar and spaces in page names
- Question: How do I remove the Quick links form from the preferences page?
- How can I redirect the wiki pages from http to https?
- Cyrillic pages names
- Macro names appearing in rendered pages
- wiki.py missing
- Configure MoinMoin to use a different server for static stuff
- Configure MoinMoin standalone to run as www-data on port 80
- URL prefix with CGI on IIS
url.com versus url.com/wiki problem
Dear friends, our sysadmin has moinmoin working great at xyz.com/wiki
But, how to get it working at xyz.com ??
(For example, http://moinmo.in/ works perfectly ... it does not redirect to http://moinmo.in/wiki )
Thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You may want to read the comments in the moin.wsgi file -- ReimarBauer 2012-07-17 19:37:35
How to make RECENT CHANGES go back further in time
I would like the RECENT CHANGES to go back more than a couple of months. Actually I would like it to go back a year. How do I configure MOINMOIN to do this? I don't see this in the documentation.
MoinMoin with Fedora 14
I've installed MoinMoin and mod_python on my Fedora 14 box. I used yum to install both packages.
moin-1.9.3-2.fc14.noarch mod_python-3.3.1-14.fc14.i686
I've configured the wiki but when I try to access the main page I get what looks like an FTP style directory listing, showing the wiki root folder and all sub-folders. Any idea as to why this occurs? Additionally, will this version of MoinMoin work with the version of python offerred by Fedora 14.
python.i686-2.7-8.fc14.1
Invalid escape
I´ve done everything as described at http://moinmoin.wikiwikiweb.de/HelpOnInstalling/ApacheOnWin32. When opening http://127.0.0.1/mywiki I get the Message "Import of configuration file "wikiconfig.py" failed because of ValueError: invalid \x escape (...)".
- Please paste your configuration.
Farmconfig matching
Trying to get farm_config working if anyone has an example I would appeciate it.
- See .../wiki/config/farmconfig.py - that is an example for a working farmconfig setup
I have been working with that farm config. I've added ("adminwiki", r"^adminwiki/.*$"), to the wikis array in farmconfig.py and I keep getting an error saying:
Could not find a match for url: "adminwiki".
Obviously, r"^adminwiki/.*$"does not match "adminwiki". Which URL did you request?
The URL I type in is http://adminwiki, but by the time I see it working, it's http://adminwiki/moin.cgi/. I just now got it to work by changing the match string to: r"^adminwiki$" instead.
Moving several wikis to a wiki farm - (Problem)
Suppose I have two different wikis located under a common base-folder:
- base/wiki1
- base/wiki2
Running moin.py in my "base/wiki1"-Directory works fine and gives access to my "wiki1" content. For example, requesting
http://myserver:8080/NewPage
will try to access "NewPage" in my base/wiki1/data/pages directory. But if I try to turn my two different wikis to a single wiki-farm by using farmconfig.py:
#farmconfig.py: wikis = [ ("wiki1", r"^myserver:8080/wiki1/.*$"), ("wiki2", r"^myserver:8080/wiki2/.*$") ]
requesting
http://myserver:8080/wiki1/NewPage
will end up accessing "wiki1(2f)NewPage" in my base/wiki1/data/pages directory. Why?
I have dealt with a similar issue (I believe). You need to go into MoinMoin Request.init and edit the base request. MoinMoin needs PathInfo and ScriptName to look like so:
PathInfo = "/NewPage..." ScriptName = "/wiki1"
In your case instead I believe they look like this:
PathInfo = "/wiki1/NewPage..." ScriptName = "/"
so you need to put in some code to switch it around so it looks like the former.
you should not needed to edit any moinmoin intern files to setup a correct farmwiki. maybe beside the farmwiki.py you have still the wikiconfig.py file in your directory or something else missed... you may also have to check your server configration (e.g. if it's apache with mod-wsgi that your aliases are correct; for example I do for every wiki this stuff in my apache config: WSGIScriptAlias /wikixy /var/www/moinmoin/server/moin.wsgi)
Standalone server - TCP Interfaces
I am trying to make the standalone server accept connections from a limited number of IPs only. To do this I am editing the "interface" field in the moin.py file in the following way "interface = 'some.ip.is.here' ".
- Check if you are binding to an invalid IP, to an invalid port (check that one as well). Especially, look if you want to bind to a port below 1024 and if you run standalone as a root application.
Have the same problem. Trying to make the standalone server accept connections from a limited number of IPs only. To do this I am editing the "interface" field in the wikiserverconfig.py file in the following way "interface = '192.168.1.51' ". IP address is right. I get next error when trying to launch wikiserver.py: "socket.gaierror (11001, "getaddrinfo failed").
Invalid syntax error after editing wikiconfig.py
Import of configuration file "wikiconfig.py" failed because of SyntaxError: invalid syntax (wikiconfig.py, line 123).
Solution
In most cases, you broke the file by adding tab characters. MoinMoin configuration files are Python modules, and does not work with a mix of tabs and spaces. Uses only spaces when you edit moin files.
Customising quick links and the available actions
- Is there any way to totally disable the quick links at the top of the page? (front page is all I need and that I can get from the logo).
see HelpOnConfiguration, try navibar = [] (or None).
- is there any way to tailor what appears in the grey footer at the bottom? (I don't want the spellchecker which is there, and I would like the rename-page facility, which is not there).
- you can simply remove the spellcheck action from action/ directory (or make your own theme to not show it)
some actions must be enabled, e.g. allowed_actions = ['DeletePage', 'AttachFile', 'RenamePage',]
Default User Preferences
Is there a way to set the default options for the anonymous user and for all new users?
You can set some basic options, see HelpOnConfiguration (this includes the theme default, the question marks in front of the links etc.; in MoinMoin 1.2 and 1.3). A few options cannot be set in a global way, though.
EOL while scanning single-quoted string
Import of configuration file "wikiconfig.py" failed because of SyntaxError: EOL while scanning single-quoted string (wikiconfig.py, line ...).Goto line ... and check if you have a backslash at the end of the string. If so, try to avoid it. If it still does not work, paste the line here.
Where is moin_config.py?
moin_config.py was replaced in 1.3 with wikiconfig.py. Please read HelpOnInstalling.
Another port for the DesktopEdition
I can't see an option for changing the port.
Solution
Read the page DesktopEdition/HowToConfigure.
Troubleshooting Configuration
We are having issues with the configuration of MoinMoin. This is the error log. We are setting up a single wiki on the intranet. The farmconfig in moin.cgi is commented out. We have changed the 404 errors as suggested for IIS. We still cannot add NEW PAGES. We are using Moin 1.3.5 Python 2.4.2 and Windows NT. We appreciate your help.
- It looks like your configuration file is not indented correctly. Please upload it in the wiki if you cannot file the fault by yourself.
Farm with Desktop Edition
You may wonder why would anyone need to run a wikifarm on a DesktopEdition but the truth is that I would like to keep my personal wiki and my work wiki completely separate (work wiki can then be synchronized with a remote server, my personal stuff can stay my own). Can anyone give me a brief outline (provided it is possible to run this with the DesktopEdition on Windows) of how to accomplish this? I am a total newbie with python so instructions as simple as the like of "open eye, insert fork, twist, call 911" would be greatly appreciated. Ivaylo, 2006-02-07
Solution
Solution working for Windows XP SP2 / MoinMoin Desktop Edition 1.5.3
Let's suppose you want to create a farm of 2 wikis: wiki_biz and wiki_perso
Step 1: create a wiki instance for each wiki
Create a copy of C:\Program Files\moin-desktop\wiki\data with all its subfolders at
C:\Program Files\moin-desktop\wiki\data_biz
C:\Program Files\moin-desktop\wiki\data_perso
Step 2: create a config file for each wiki
Save these 2 files and farmconfig.py (step 3) under C:\Program Files\moin-desktop\
wiki_biz.py
# -*- coding: iso-8859-1 -*- from farmconfig import FarmConfig class Config(FarmConfig): sitename = 'Wiki Biz' data_dir = 'C:\Program Files\moin-desktop\wiki\data_biz'
wiki_perso.py
# -*- coding: iso-8859-1 -*- from farmconfig import FarmConfig class Config(FarmConfig): sitename = 'Wiki Perso' data_dir = 'C:\Program Files\moin-desktop\wiki\data_perso'
Step 3: create farmconfig.py
# -*- coding: iso-8859-1 -*- wikis = [ ("wiki_biz", r"^wiki_biz.*$"), ("wiki_perso", r"^wiki_perso.*$"), ] from MoinMoin.multiconfig import DefaultConfig class FarmConfig(DefaultConfig): # put here the config you want to share among all your wikis in the farm. For example: tz_offset = 9.0
Step 4: add entries in your hosts file
edit the hosts file at C:\WINDOWS\system32\drivers\etc\hosts
- replace the following line
127.0.0.1 localhost
with
127.0.0.1 localhost wiki_biz wiki_pers
Using the farm
Start the Wiki engine (moin.py)
Now, you should be able to access your 2 wikis by using the following address:
Force User Logout On Browser Close
System: Ubuntu 5.10, latest MoinMoin, Apache, and Python packages. Currently, users that log in remain logged in between browser sessions. Due to the way we will be using this wiki, I'd like to set the cookie so that it expires when the browser closes. I have no idea how to do this. Any suggestions? Thanks, Thane
- You can use a low cookie_lifetime value, so the cookie expires when there is some time no activity. This has nothing to do with whether the window is open or closed, though. Maybe one could somehow catch window close with javascript and remove the cookie?
How to configure a wiki farm running MoinMoin via Apache with mod_python
I have checked the docs at HelpOnConfiguration, HelpOnInstalling/ApacheWithModPython, and HelpOnInstalling for an answer to this. Of all those pages, the only one that begins to address this question is HelpOnInstalling, which simply states:
Create a directory for your farm, and under it, make two data trees per the /WikiInstanceCreation instructions. In the config directory (by default /usr/share/moin/config) you will find an example farmconfig.py file. Copy this into the farm directory, and edit moin's launcher script (moin.py if you are standalone, moin.cgi if you are cgi, etc.) to point directly at it.
This is not explicit enough for me. What particular MoinMoin file do I need to edit for Apache with mod_python, and what specifically do I need to place or alter within that file to point to my farmconfig.py file? Many thanks in advance. -- ChrisLasher 2006-11-09 01:31:23
- You have to modify sys.path to contain the directory that has your configuration files, so Python can import the config file(s) from there.
How about a concrete example? Let's say I have two wikis, WikiA and WikiB. Their files are stored in /home/moin/wikia/ and /home/moin/wikib/, respectively. Each one has its own wikiconfig.py under its directory. There is a farmconfig.py script in /home/moin/. What would one need to place in the <Location> directives of the Apache config file such that http://mysite.org/wikia/ goes to WikiA and http://mysite.org/wikia/ WikiB, via mod_python using farmconfig.py?
How to get spaces in the page_front_page
My site is set to convert spaces to spaces in page names. This works fine, except for the page set to the variable page_front_page in the moinconfig.py config file. So when starting to visit the site without a page name in the URL, the front page is displayed with underscores in the title, where I would expect spaces. Example: http://www.wijgoudenleeuw.nl/ Is there a solution?
- You run an old moin version, can you try if this also happens with the latest one?
I am running debian packages moinmoin-common and python-moinmoin Version: 1.5.3-1.1, the newest version on debian etch = testing.
I fixed this problem without upgrading moin with this line in my apache config (root-wiki style):
RewriteRule ^/$ /Name_with_underscores
just above the rule for ^(.*)$ . I also wrote a note in the moinconfig.py file about this fix, otherwise I might get crazy later, trying in vain to set another front page.
Disable ErrorLogs in webbrowser, enable only in flat files
How to disable displaying of any error logs for ordinary user (or for everybody) in browser? I'd like only to have error logs written to the file (for example to /etc/moin/errors , or /var/log/moin-error.log) ?
Something similiar is planned for 1.6 -- ReimarBauer 2007-04-10 15:59:29
- OK. but is it possible to disable displaying of error informations in webbrowser now? (moinmoin ver. 1.5.x) -- Yanaek
-- Yanaek 2007-04-19
- See CHANGES of moin 1.5.8.
Even when I edit wikiconfig.py, surge protection won't turn off
I added this line
surge_action_limits = None this only works for 1.5.5+
to the wikiconfig.py file but the surge protection still locks me out. (Desktop Windows version)
What an annoying feature! It's unacceptable to have my software lock me out for working at a fairly normal speed.
Help, anyone?
For 1.5.4 you just have to configure high limits, see the help page.
What limits should I set? I've played with the high limites and I still get locked out. This is very frustrating! Any specific suggestions?
wikiconfig.py doesn't seem to be loading
I changed the value of some of the variables in wikiconfig.py (following the installation help files). I noticed no changes in the wiki itself, in particular the title did not change. So, I made sure that the path to wikiconfig.py was in the server script. However, it wasn't clear to me what script I should actually be editing, since in the server directory there are moin.cgi and moin.py and both have lines asking for the path to wikiconfig.py. Which script should I be editing, and am I missing anything else? Otherwise my wiki seems to be working quite nicely. I'm running Mac OS X 10.4. Thanks! -- Brian Taylor
Maybe you yourself are the only one who can answer this. moin.cgi is the cgi adaptor, usually used with apache or some other web server executing moin as a standard cgi script. moin.py is the standalone server, so if you don't want to install apache or some other web server, you can use this "python builtin" web server. -- ThomasWaldmann 2006-09-14 08:29:45
- I figured out the problem. I was editing a copy of the wikiconfig.py file and not the wikiconfig.py file that was in the actual wiki. I'm new to the unix directory structure and it took me a while to figure out my mistake. Thanks for your feedback, though.
- I found that with mod_wsgi, the wikiconfig.py changes did not take effect until I restarted apache2.
- Maybe read the mod_wsgi documentation, it contains useful hints like that when touching moin.wsgi, it will restart the moin daemons.
CGI-Fehler
Die angegebene CGI-Anwendung hat keinen vollständigen Satz von HTTP-Headern zurückgegeben I'm running Windows 2003, IIS 6. The Configuration seems to be correct, but I always get the cgi-Error. Anyone an idea?
Supress URLs
Hi, can I prevent URLs entered in an article to be transformed into klickable links? I found a variable to add further protocols, but how to remove e.g. http? Thank You, -- mrdslave.
You can use preformatted text {{{http://example.com/}}} http://example.com/ or the Verbatim macro [[Verbatim(http://example.com/)]] http://example.com/. But most readers expect to be able to click on a URL - making URL useless seems like a bad idea.
Trying to enable discussion pages
Hi there. I've read HelpOnConfiguration/SupplementationPage and I've edited my wikiconfig.py, adding an extra line at the end which says
- supplementation_page = True
I've restarted apache2, but I don't see any Discussion pages in my wiki (single instance). I don't understand what's going wrong. I haven't changed the wikiconfig since I first set up the wiki a year or so ago. It's worked fine ever since (apache2 has been upgraded several times - I'm running Debian Etch). Sorry if I'm being really dim. (Yes, I have logged out and then logged back in - still no discussion pages.)
This is a new 1.6 feature (this wiki and the MoinMaster wiki are running 1.6 now, release 1.6.0 is expected in december).
Thank you - nice to know I'm not stupid. I look forward to the 1.6.0 release.
Preventing the script name from appearing when using mod_python
Hi, using 1.5.8.
I usually use mod_rewrite in cgi mode so that moin.cgi does not appear in the URLs. As I don't want the name to appear in the URLs generated by MoinMoin, I edit moin.cgi and leave it like this:
from MoinMoin.request import RequestCGI #request = RequestCGI() request = RequestCGI(properties={'script_name':'/'}) request.run()
and everything works fine.
Now, I got my own server and I'm trying to set it up to use mod_python... I got everything working (including mod_rewrite), but the stock moinmodpy.py will generate the URLs with it's own name in it...
I guess that there should be something I could do in this part of the code:
from MoinMoin.request import RequestModPy def handler(request): moinreq = RequestModPy(request) return moinreq.run(request)
but I don't know what.
I bearly read Python, so studying request.py is not helping me. Can someone hand me a recipe to do this?
TIA
-- MarianoAbsatz 2007-12-13 20:02:50
BUMP
Anyone can tell me if the above is indeed possible with mod_python???
I just upgraded to 1.6.3 and I'm not able to do this. What I want is to see http://wiki.example.com/RecentChanges instead of http://wiki.example.com/moinmodpy.py/RecentChanges (and that the links get generated that way internally).
I've done this many times with moin.cgi, but I can't see how to do this with moinmodpy.py.
I'm using moinmoin 1.6.3 with apache 2.2.4 under ubuntu 7.10 (gutsy).
The virtual host config file looks something like this:
<VirtualHost *:80> ServerName wiki.example.com ServerAdmin webmaster@example.com DocumentRoot /var/vhost-www/wiki.example.com/ <Directory /var/vhost-www/wiki.example.com/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all #DirectoryIndex moin.cgi index.html # start the rewrite engine RewriteEngine On RewriteBase / RewriteRule ^moin_static.../ - [last] RewriteRule ^(/.*/)?moinmodpy.py - [last] RewriteRule ^(.*)$ /var/vhost-www/wiki.example.com/moinmodpy.py$1 [type=application/x-httpd-cgi] </Directory> ErrorLog /var/log/apache2/vhost/wiki.example.com/error.log RewriteLog /var/log/apache2/vhost/wiki.example.com/rewrite.log RewriteLogLevel 2 # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/vhost/wiki.example.com/access.log combined ServerSignature On ## WIKI #ScriptAlias /moin.cgi /var/vhost-www/wiki.example.com/moin.cgi <Location /> SetHandler python-program # Add the path of your wiki directory PythonPath "['/var/vhost-www/wiki.example.com', '/usr/local/etc/moin'] + sys.path" PythonHandler moinmodpy PythonDebug On </Location> <LocationMatch "/moin_static..."> SetHandler None </LocationMatch> </VirtualHost>
in /var/vhost-www/wiki.example.com I have a copy of /usr/local/share/moin/htdocs named moin_static163 and a modified copy of moinmodpy.py as follows:
# -*- coding: iso-8859-1 -*- """ MoinMoin - mod_python wrapper for broken mod_python versions add a .htaccess to the path below which you want to have your wiki instance: <Files wiki> SetHandler python-program PythonPath "['/path/to/moin/share/moin/cgi-bin'] + sys.path" PythonHandler moinmodpy </Files> Note: this is a wrapper needed because of a bug in mod_python < 3.1.3 mod_python.apache.resolve_object fails to parse a object with dots. If you have a newer version, take a look at moinmodpy.htaccess to see how to use MoinMoin without this wrapper. You can also look into INSTALL.html to see how you can fix the bug on your own (a simple one line change). TODO: this should be refactored so it uses MoinMoin.server package (see how server_twisted, server_wsgi and server_standalone use it) @copyright: 2004-2005 by Oliver Graf <ograf@bitart.de> @license: GNU GPL, see COPYING for details. """ # System path configuration import sys # Path of the directory where wikiconfig.py is located. # YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP. #sys.path.insert(0, '/path/to/wikiconfig') sys.path.insert(0, '/usr/local/lib/python2.5/site-packages/') # Path to MoinMoin package, needed if you installed with --prefix=PREFIX # or if you did not use setup.py. ## sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages') # Path of the directory where farmconfig is located (if different). ## sys.path.insert(0, '/path/to/farmconfig') sys.path.insert(0, '/usr/local/etc/moin') # Debug mode - show detailed error reports ## import os ## os.environ['MOIN_DEBUG'] = '1' # Simple way #from MoinMoin.server.server_modpython import modpythonHandler as handler # Complex way from MoinMoin.server.server_modpython import ModpythonConfig, modpythonHandler class MyConfig(ModpythonConfig): """ Set up local server-specific stuff here """ # Make sure moin will have permission to write to this file! # Otherwise it will cause a server error. logPath = "/var/log/moin/moinlog" # Properties # Allow overriding any request property by the value defined in # this dict e.g properties = {'script_name': '/mywiki'}. ## properties = {} #properties = {'script_name': '/'} def handler(request): return modpythonHandler(request, MyConfig)
/usr/local/etc/moin holds my farmconfig.py.
-- MarianoAbsatz 2008-05-03 15:35:09
SOLVED
Well... it turned out that the mod_rewrite loop was originated by having a <Directory> section within the <VirtualHost> and having the RewriteRule's there... I'll try to elaborate a bit by updating HelpOnInstalling/ApacheWithModPython with some info... but now I'm going to sleep... -- MarianoAbsatz 2008-05-04 11:10:38
navi_bar and spaces in page names
I have migrated to 1.6 and stumbled upon following: some of the pages have spaces in their names (all well so far, they were renamed from underscores when migrating), but I cannot find out how to write their names into navi_bar. The previous navi_bar = [u'[Hlavná_stránka Hlavná stránka]'] does not work, since Hlavná_stránka is not the same as Hlavná stránka. Replacing the underscore with a space does not work, obviously. Neither does using &x20; or the (semi-expected) pipe [Hlavná_stránka|Hlavná stránka]. Is there any way of escaping the space? I have resorted to renaming the page to Hlavná_stránka (with an underscore), but clearly that is not an universal solution. -- 147.213.138.3 2008-04-30 11:21:49
For navibar, 1.6 still uses ["Free Link"] syntax. Sorry about this inconsistency, but the respective changeset was forgotten when backporting from 1.7. Starting with 1.7.0, it will consistently use the new link markup. -- ThomasWaldmann 2008-04-30 12:37:04
Question: How do I remove the Quick links form from the preferences page?
How do I remove the Quick links form from the page xxx?action=userprefs&sub=prefs completely? I have tried: user_form_remove = ['quick_links'] in wikiconfig.py but that does not work for me.
Thanks. -- JohanZiprus 2024-11-14 09:32:43
How can I redirect the wiki pages from http to https?
I have installed a wiki (1.7.1) under linux (Apache with modpython). This wiki is configured as root wiki and working fine. I would like redirect all wiki pages from http to https. Who does know the recipe for it?
Thanks for your help!
Cyrillic pages names
I have several pages named in cyrillic. The problem is that folders in wich the pages are stored on disk are named in unreadable way: for example page 'поезд' (poezd - train in Russian) is stored in "(d0bfd0bed0b5d0b7d0b4)" folder - it seems like a raw unicode output. This is very inconvenient - for example it's hard to access that folder from my macro. Can I make pages with cyrillic names be stored in folders named as the pages themselves? (поезд - поезд, not поезд - (d0bfd0bed0b5d0b7d0b4))
Currently (as of moin 1.7/1.8/1.9 there is no easy way to do this). We did choose this encoding because it works everywhere (no matter what your FS encoding is, no matter whether linux or windows). We are working on improved backend storage for moin >= 2.0. -- ThomasWaldmann 2008-10-17 02:40:26
Macro names appearing in rendered pages
If accessing a wiki page that doesn't exist, on the new page template we see "Action(edit,Create new empty page)" instead of a link to create a new page. On the RecentChanges page, we see RandomQuote() and Icon(diffrc) rather than a quote and an icon. I believe this behavior started around the time that I updated MoinMoin to 1.7.2. Any ideas how to troubleshoot this problem?
You likely forgot to update your underlay directory with the new one we provide in the distribution archive as wiki/underlay/.
wiki.py missing
I try to follow this guide to enable MathMLSupport (MoinMoin 1.8, DesktopEdition): http://moinmo.in/MathMlSupport/MathML%20HOWTO.
I'm told to "edit the file parser/wiki.py under MoinMoin directory"
- This file does not exist at all. What to do?
Those instructions are obviously for an old moin version. In recent moins, the wiki parser is in MoinMoin/parser/text_moin_wiki.py.
Configure MoinMoin to use a different server for static stuff
I see that when I load a page from moinmo.in, the CSS, Javascript, and images actually come from static.moinmo.in. How do you do that?
Configure MoinMoin standalone to run as www-data on port 80
I'm trying to setup monimoin on an ubuntu box using the built-in server, but running on port 80 as user www-data. I haven't been able to find any examples of these, if you have any please point me in the right direction.
Here's what I've done so far:
- Using the 1.9.3 tarball, I've installed it in /home/wiki like this:
- /home/wiki/
data/
underlay/
config/
- /home/wiki/
- In the config directory I've placed wikiconfig.py, wikiserverconfig.py and wikiserverlogging.conf. I modified the sys.path in wikiserver.py like:
sys.path.insert(0, '/home/wiki/config')
sys.path.insert(0, '/home/wiki/lib/python2.7/site-packages')
..
log.load_config('config/wikiserverlogging.conf')
I've installed all the code from the LanguageSetup page and the wiki appears to be running fine when run as me.
- I then added more command-line configuration to wikiserver.py:
sys.argv = ["moin.py", "server", "standalone", "--user=www-data", "--group=www-data", "--pidfile=/home/wiki/moinmoin.pid", "--start" ]
The server works correctly on port 8080 when run as www-data.
- Next I edited wikiserverconfig.py, setting port=80, user='www-data', group='www-data', interface='192.168.1.2' (my ip address)
- Then I added "--port=80" to sys.argv in wikiserver.py and ran the server as "sudo ./wikiserver.py" and (removing "--start") I get:
mecklen@pippin:/home/wiki$ sudo ./wikiserver.py Traceback (most recent call last): File "./wikiserver.py", line 47, in <module> MoinScript().run() File "/home/wiki/lib/python2.7/site-packages/MoinMoin/script/__init__.py", line 138, in run self.mainloop() File "/home/wiki/lib/python2.7/site-packages/MoinMoin/script/__init__.py", line 261, in mainloop plugin_class(args[2:], self.options).run() # all starts again there File "/home/wiki/lib/python2.7/site-packages/MoinMoin/script/__init__.py", line 138, in run self.mainloop() File "/home/wiki/lib/python2.7/site-packages/MoinMoin/script/server/standalone.py", line 143, in mainloop run_server(**kwargs) File "/home/wiki/lib/python2.7/site-packages/MoinMoin/web/serving.py", line 159, in run_server **kw) File "/home/wiki/lib/python2.7/site-packages/MoinMoin/support/werkzeug/serving.py", line 392, in run_simple inner() File "/home/wiki/lib/python2.7/site-packages/MoinMoin/support/werkzeug/serving.py", line 378, in inner passthrough_errors).serve_forever() File "/home/wiki/lib/python2.7/site-packages/MoinMoin/support/werkzeug/serving.py", line 251, in make_server passthrough_errors) File "/home/wiki/lib/python2.7/site-packages/MoinMoin/support/werkzeug/serving.py", line 207, in __init__ HTTPServer.__init__(self, (host, int(port)), handler) File "/usr/lib/python2.7/SocketServer.py", line 408, in __init__ self.server_bind() File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind SocketServer.TCPServer.server_bind(self) File "/usr/lib/python2.7/SocketServer.py", line 419, in server_bind self.socket.bind(self.server_address) File "/usr/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 13] Permission denied
It appears that moinmoin is attempting to open port 80 as www-data instead of root. I would have expected it to open port 80 before settting its effective uid/gid.
How do I run the built-in http server on port 80?
Solution
Here is an evil hack that seems to have worked (although it cannot be "checked in" with the source).
- In site-packages/MoinMoin/web/serving.py comment out the switch_user call:
def run_server(hostname='localhost', port=8080, docs=True, debug='off', user=None, group=None, threaded=True, **kw): """ Run a standalone server on specified host/port. """ application = make_application(shared=docs) if port < 1024: if os.name == 'posix' and os.getuid() != 0: raise RuntimeError('Must run as root to serve port number under 1024. ' 'Run as root or change port setting.') # if user: # switch_user(user, group)
- In site-packages/MoinMoin/support/werkzeug/serving.py add the os.setgid and os.setuid function calls:
class BaseWSGIServer(HTTPServer): multithread = False multiprocess = False def __init__(self, host, port, app, handler=None, passthrough_errors=False): if handler is None: handler = BaseRequestHandler HTTPServer.__init__(self, (host, int(port)), handler) self.app = app self.passthrough_errors = passthrough_errors os.setgid(33) os.setuid(33)
The effect of this is to delay the switching the user to www-data until after the HTTPServer code has started listening on port 80. The reason it is unsuitable for checking in is that there is no good way to pass the desired user/group down from run_server through run_simple -> inner -> make_server -> BaseWSGIServer. Also, of course, this may simply be the Wrong Way To Do It.
Comments?
Please read wikiserverconfig.py -- ReimarBauer 2011-09-29 12:34:08
Thank you for responding. Your answer is a little vague. Of course, I have read those files. In fact, there are two in the 1.9.3 release and they have different contents. The moin-1.9.3/wiki/server/wikiserverconfig.py file describes a variable "interface = 'localhost'", which (as far as I can tell) does nothing, while the moin-1.9.3/wikiserverconfig.py file uses the correct value "hostname = 'localhost'".
As to reading them to solve my problem, I was not able to find any information in these very short files which directly relates. There is, of course, the comment "if you use port < 1024, you need to start as root", which I tried as I described above. There is also the comment, "if you start the server as root, the standalone server can change to this user and group, e.g. 'www-data'". When running moinmoin as root I got the backtrace I described and debugged. The bug is that moinmoin invokes switch_user too soon and the socket open fails. Did you read my post?
Or perhaps you meant the comment beginning "DEVELOPERS! Do not add...", which doesn't relate at all, unless I could use the custom Config class to change how switch_user works. I think so.
So, perhaps you could be more specific in your advice. Can you answer two questions:
- Should running standalone as www-data on port 80 work when wikiserver.py is run as root, i.e., "sudo python wikiserver.py"?
- Does this work for you or anyone you know?
Thanks,
Robert Mecklenburg 2011-10-02 02:24:00
This could be a regression from 1.8 to 1.9 - there have been a few in the general HTTP-related code - because the 1.8 code looks like this (in MoinMoin.server.server_standalone):
httpd = makeServer(config)
# Run as a safe user (posix only)
if os.name == 'posix' and os.getuid() == 0:
switchUID(config.uid, config.gid)
httpd.serve_forever()
It's quite possible that the underlying SocketServer code in 1.8 binds to a port when the server is instantiated, whereas the WSGI stuff defers that to a later point in time, when MoinMoin.support.werkzeug.serving.run_simple is called. That means that the above pattern ("initialise server, switch user, start server") doesn't work because the code is more like "initialise application, switch user, initialise and start server". So yes, the last part has to be punctuated with a "switch user" somehow. -- PaulBoddie 2011-10-02 15:07:40
URL prefix with CGI on IIS
Is it possible to hide the url prefix like "/mywiki/moin.cgi/MyPage" when MoinMoin is installed as a IIS CGI ? I have to mention that I had to define something like
url_mappings = {'/mywiki/moin.cgi/mywiki':'/mywiki'}
Is it the right thing to do (the Howto may be uncomplete ?) ?