Forums

Installing MoinMoin on PythonAnywhere

One of our users asked about MoinMoin recently. I got it working, thought I'd share the instructions...

Unfortunately our default MoinMoin install that's in the batteries included won't let you configure a new wiki from scratch, due to a bug in our sandboxing (but we're going to fix it soon!)

You can still get it working if you "roll your own" config. I did it by reinstalling moinmoin from the source tarfile, using the --user flag:

Start by installing moinmoin to ~/.local using the tarfile:

wget http://static.moinmo.in/files/moin-1.9.7.tar.gz
cd /tmp
tar -xvf moin-1.9.7.tar.gz 
cd moin-1.9.7/
python setup.py install --user

Then we start a wiki in a directory called mywiki

cd -
mkdir mywiki
cp ~/.local/share/moin/config/wikiconfig.py mywiki
cp -r ~/.local/share/moin/data mywiki
cp -r ~/.local/share/moin/underlay mywiki

Finally we set up the wsgi config - you will need to have created a web app on pythonanywhere, using eg "manual configuration"

# we start by overwriting the default wsgi file:
cp  ~/.local/share/moin/server/moin.wsgi /var/www/wiki_pythonanywhere_com_wsgi.py
# now we edit the wsgi file
# all I changed was the value at section a2)
# sys.path.insert(0, '/home/wiki/mywiki')
vi /var/www/wiki_pythonanywhere_com_wsgi.py

And here it is in all its glory:

http://wiki.pythonanywhere.com/

(coming soon, an official PythonAnywhere wiki for support requests etc)

Feel free to post questions, tips & tricks, corrections here....

I just noticed you added "PythonAnywhere staff" to the snake accounts. When did you roll it out? I'm just curious to see how long I missed it staring me in the face...☺

Well, at least a little while. A quick git blame on that template shows that the line of code including PythonAnywhere staff was last modified 2012-03-29 12:37:39 :-)

Well, it was probably cached in the... Uh... That is to say that the... Um.. Hadn't updated... Nope, sorry a2j, I got nothin'. (^_^)

I want a Charter Member tag...☺

Yeah, 2012-03-29 12:37:39 makes it sound like I haven't been paying attention, but in my defense, if that was the edit, it still had to go through integration prior to me seeing it...☺

Heh, our integration loop is pretty slow at the moment but I'm pretty sure it's taking less than a year ;-)

Meh! There goes that excuse.

Unfortunately our default MoinMoin install that's in the batteries included won't let you configure a new wiki from scratch, due to a bug in our sandboxing (but we're going to fix it soon!)

Did this get fixed? Or is installing from source the way to go?

It is simpler now. You don't need to install MoinMoin from source, you can just start with the usual wiki configuration, from the installed package.

We start a wiki in a directory called mywiki

cd -
mkdir mywiki
cp /usr/local/share/moin/config/wikiconfig.py mywiki
cp -r /usr/local/share/moin/data mywiki
cp -r /usr/local/share/moin/underlay mywiki

Finally we set up the wsgi config - you will need to have created a web app on pythonanywhere, using eg "manual configuration"

# we start by overwriting the default wsgi file:
cp  /usr/local/share/moin/server/moin.wsgi /var/www/wiki_pythonanywhere_com_wsgi.py

Then edit the wsgi file so there's a line like this in it with the path modified to point to the directory that we've been copying things into:

sys.path.insert(0, '/home/wiki/mywiki')

Under "Web app setup" and under "Code", the detail for "Source code", "Working directory" is what?

Source code is the directory where the code for your web app is. If you're in the editor and inside the source directory for a web app, it shows a reload button at the top, so you can reload your web app from the editor.

The working directory is the current directory for the environment that the web app runs in.

I think I' done the steps above, but it does not work :-( Can someone help me?

thank you

Renato

In what way does it not work?

going to that addr: http://rp4.pythonanywhere.com yhe wiki does not run

I see that you still have the default page on that site. Have you put the appropriate code in your WSGI file? And have you reloaded the site after doing that?

maybe not. Do I have to paste a WSGI content file? And, where I take it?

Renato

It sounds like you need to do the part that starts "# we start by overwriting the default wsgi file:"

I redo all steps and all seems to be right. I don't need to run the moinmoin installation right?

Renato

hmm- you may want to give a bit more information for others to help you. eg: what in particular is working now?

I've create another vm , followed the step described above, but still have the same "HELLO WORD" page. I have also changed the source code directory /home/rp5/moin-1.9.10/MoinMoin but I still have the same "Hello word.."page, so it seem that the change I've done, is not correct... my working dir is: Working directory:/home/rp5/

what do I have to check?

TIA Renato

What are the contents of your WSGI file? There's a link to it on the "Web" page.

the name of my WSGI config file is: /var/www/rp4_pythonanywhere_com_wsgi.py

and it's content is:

# This file contains the WSGI configuration required to serve up your
# web application at http://rp4.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#

# +++++++++++ GENERAL DEBUGGING TIPS +++++++++++
# getting imports and sys.path right can be fiddly!
# We've tried to collect some general tips here:
# https://help.pythonanywhere.com/pages/DebuggingImportError


# +++++++++++ HELLO WORLD +++++++++++
# A little pure-wsgi hello world we've cooked up, just
# to prove everything works.  You should delete this
# code to get your own working.


HELLO_WORLD = """<html>
<head>
    <title>PythonAnywhere hosted web application</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>
    This is the default welcome page for a
    <a href="https://www.pythonanywhere.com/">PythonAnywhere</a>
    hosted web application.
</p>
<p>
    Find out more about how to configure your own web application
    by visiting the <a href="https://www.pythonanywhere.com/web_app_setup/">web app setup</a>

page </p> </body> </html>"""

def application(environ, start_response):
    if environ.get('PATH_INFO') == '/':
        status = '200 OK'
        content = HELLO_WORLD
    else:
        status = '404 NOT FOUND'
        content = 'Page not found.'
    response_headers = [('Content-Type', 'text/html'), ('Content-Length', str(len(content)))]
    start_response(status, response_headers)
    yield content.encode('utf8')


# Below are templates for Django and Flask.  You should update the file
# appropriately for the web framework you're using, and then
# click the 'Reload /yourdomain.com/' button on the 'Web' tab to make your site
# live.

# +++++++++++ VIRTUALENV +++++++++++
# If you want to use a virtualenv, set its path on the web app setup tab.
# Then come back here and import your application object as per the
# instructions below


# +++++++++++ CUSTOM WSGI +++++++++++
# If you have a WSGI file that you want to serve using PythonAnywhere, perhaps
# in your home directory under version control, then use something like this:
#
#import sys
#
#path = '/home/rp4/path/to/my/app
#if path not in sys.path:
#    sys.path.append(path)
#
#from my_wsgi_file import application  # noqa


# +++++++++++ DJANGO +++++++++++
# To use your own django app use code like this:
#import os
#import sys
#
## assuming your django settings file is at '/home/rp4/mysite/mysite/settings.py'
## and your manage.py is is at '/home/rp4/mysite/manage.py'
#path = '/home/rp4/mysite'
#if path not in sys.path:
#    sys.path.append(path)
#
#os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
#
## then:
#from django.core.wsgi import get_wsgi_application
#application = get_wsgi_application()



# +++++++++++ FLASK +++++++++++
# Flask works like any other WSGI-compatible framework, we just need
# to import the application.  Often Flask apps are called "app" so we
# may need to rename it during the import:
#
#
#import sys
#
## The "/home/rp4" below specifies your home
## directory -- the rest should be the directory you uploaded your Flask
## code to underneath the home directory.  So if you just ran
## "git clone git@github.com/myusername/myproject.git"
## ...or uploaded files to the directory "myproject", then you should
## specify "/home/rp4/myproject"
#path = '/home/rp4/path/to/flask_app_directory'
#if path not in sys.path:
#    sys.path.append(path)
#
#from main_flask_app_file import app as application  # noqa
#
# NB -- many Flask guides suggest you use a file called run.py; that's
# not necessary on PythonAnywhere.  And you should make sure your code
# does *not* invoke the flask development server with app.run(), as it
# will prevent your wsgi file from working.

this is the content but I do not find any a2) section. I'm wondering if this is the right file

TIA Renato

You have not done the first part of that instruction. The part that starts with # we start by overwriting the default wsgi file:

ok, I've done now But on my

WSGI configuration file: /var/www/rp4_pythonanywhere_com_wsgi.py

I don't have

wiki_pythonanywhere_com_wsgi.py but rp4_pythonanywhere_com_wsgi.py that donot have the a2) section

Do I have to put the wiki_pythonanywhere_com_wsgi.py instead of rp4_pythonanywhere_com_wsgi.py ?

Thank you Renato

YYYYYEEEESSSS!!!!! IT RUN!!!!!!

I've simply overwrite the rp4_pythonanywhere_com_wsgi.py with the brand new wiki_pythonanywhere_com_wsgi.py

and now it works!!!!

Thank you for your patient help

Renato

wiki_pythonanywhere_com_wsgi.py is the wsgi file for the example that harry created. rp4_pythonanywhere_com_wsgi.py is the wsgi file for your web app. That is the one that you need to copy the moin.wsgi file to. Once you've done that, /var/www/rp4_pythonanywhere_com_wsgi.py will have the a2 section for you to edit.

Hi, I still would try to install moinmoin 1.9.10 from scrath, using the instruction you wrote. My first prob is this:

Start by installing moinmoin to ~/.local using the tarfile:

Do I have to go this directory? (cd /home/<my_user_name>/.local)?

wget http://static.moinmo.in/files/moin-1.9.7.tar.gz I've to dowload the file to my home?

cd /tmp the /tmp directory is empy

tar -xvf moin-1.9.7.tar.gz
cd moin-1.9.7

python setup.py install--user

no- the python setup.py install --user command installs to ~/.local, so you don't need to go to that directory when you extract the tar file.

Hi, I think I've done a "big step ahead". I mean, I've understand the problem I had past time to install and made it work moinmoin 1.9.x The prob is (I think) that: - after created the web app, documentation say:

we start by overwriting the default wsgi file: cp ~/.local/share/moin/server/moin.wsgi /var/www/wiki_pythonanywhere_com_wsgi.py now we edit the wsgi file all I changed was the value at section a2) sys.path.insert(0, '/home/wiki/mywiki') vi /var/www/wiki_pythonanywhere_com_wsgi.py

but on the page still point to file: /var/www/ wiki_... not to /var/www/<user_name_python... So, I have renamed the file I've changed the a2) section then renamed from my broser I point to_ <user_name>.pythonanywhere.com but still obtain an error. error.log is empty what I have to check?

Thank you Renato Pontefice

p.s. please uèpdate documentation

[edit by admin: formatting]

what documentation are you referring to? also can you try to format your post better?

sorry, not "documentation (as book ...) but the instructio I have pasted on the thread. I mean those that you can see on top of the page

Renato

Hi Renato -- this is more of a forum thread than documentation, and it shows something that worked seven years ago, but not necessarily now.

There is stuff in your error log -- it looks like there is some junk at the start of your WSGI file...?

yeess!!!! finaly (for te second time) it works: 1 - I've seen in the error log that on the first line of WSGI file there was rubbish character. I've clean it and...it still doesn't work :-( 2 - I've seen that on the working directory in the path indicated las a folder name (the las folder of the path)

And now it run! And I've undertand how. Thank you again Renato

Excellent, glad you worked it out!

hi! i also try moin wiki on pythonanywhere. are there tutorial guides or alternative wiki engine for python?

Right now, moin only supports Python 2, and moin2, which supports Python 3, is experimental, so we don't have any tutorials given that they would either have to be out-of-date, or for something that is changing all of the time. I'm not sure if there's a good alternative, though :-(

When moin2 stabilises we may write a tutorial for it.

@giles thx for rep. i found flask-based wiki engine "openNAMU"(https://github.com/2du/openNAMU). it may be good tool due to support working on pythonanywhere(https://github.com/2du/openNAMU/issues/947).

That certainly sounds worth a try!