How to setup a Moinwiki using uswgi on a WebHost
Example is for German Webhoster "Uberspace"
Setup commands
1 mkdir moinwiki
2 cd moinwiki
3 python3.11 -m venv moin-py311-venv
4 cd moin-py311-venv/
5
6 . bin/activate
7 pip install --pre moin
8 cd ..
9 mkdir moin-wiki-uber
10 cd moin-wiki-uber/
11 moin --help
12 moin create-instance --full
13 moin run # test only
14 cp -p wikiconfig.py wikiconfig.py_default
15 vi wikiconfig.py
16 pip install uwsgi
17 flask run --port 1024 # test only
18
19 cd moinwiki/moin-wiki-uber/
20 vi uwsgi.ini # see content below
21 vi moin2.wsgi # see content below
22 uwsgi uwsgi.ini # test only
23
24 uberspace web backend set / --http --port 1024
25 uberspace web backend list
26
27 vi ~/etc/services.d/moinwiki.ini
28 supervisorctl reread
29 supervisorctl update
30 supervisorctl status
Browser URL https://<username>.uber.space/
Config files
- uwsgi.ini
[uwsgi] venv = /home/<username>/moinwiki/moin-py311-venv chdir = /home/<username>/moinwiki/moin-wiki-uber wsgi-file = moin2.wsgi die-on-term # from uber # module = start:app http-socket = :1024 chmod-socket = 660 processes = 1 strict = true master = true enable-threads = true vacuum = true
- moin2.wsgi
1 # copyright: 2010 by MoinMoin:ThomasWaldmann
2 # copyright: 2016 by MoinMoin:RogerHaase
3 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
4
5 """
6 MoinMoin - mod_wsgi driver script
7
8 To use this, copy this file to your wiki root (wikiconfig.py resides there),
9 then add these statements to your Apache's VirtualHost definition
10 (omit WSGIDaemonProcess and WSGIProcessGroup on Windows):
11
12 # invoke your moin wiki at the root url, like http://servername/ItemName:
13 WSGIScriptAlias / /<path-to>/moin2.wsgi
14 # create some wsgi daemons - use someuser.somegroup same as your data_dir:
15 moin-wsgi user=someuser group=somegroup processes=5 threads=10 maximum-requests=1000 umask=0007
16 # use the daemons we defined above to process requests
17 WSGIProcessGroup moin-wsgi
18 """
19
20 import sys
21 import os
22 import site
23
24
25 moin_dir = os.path.dirname(os.path.abspath(__file__))
26
27 site.addsitedir("/home/<username>/moinwiki/moin-py311-venv/lib/python3.11/site-packages/moin")
28
29 # make sure this directory is in sys.path (.lower() avoids duplicate entries on Windows)
30 if not (moin_dir in sys.path or moin_dir.lower() in sys.path):
31 sys.path.insert(0, moin_dir)
32
33 # for debugging sys.path issues, comment out after things are working
34 '''
35 print('== moin2.wsgi sys.path ==')
36 for p in sys.path:
37 print(p)
38 print('== end moin2.wsgi sys.path ==')
39 '''
40
41 wiki_config = moin_dir + '/wikiconfig_local.py'
42 if not os.path.exists(wiki_config):
43 wiki_config = moin_dir + '/wikiconfig.py'
44 print('== wiki_config path =', wiki_config, '==')
45
46 # create the Moin (Flask) WSGI application
47 from moin.app import create_app
48 application = create_app(wiki_config)
49
50 # please note: if you want to do some wsgi app wrapping, do it like shown below:
51 # application.wsgi_app = somewrapper(application.wsgi_app)