moinmoin Installation/Setup
Version 1.9.x (Ubuntu, Apache2, WSGI, standalone)
In order to make an installation/setup easier, I like to document it by step by step command lines. This has the advantage to use copy and paste with the terminal.
Update 2018-04-03, wiki Version 1.9.9.
In case of editing add new lines below the originals and comment out the old once.
Download package from http://www.moinmo.in/MoinMoinDownload
- Copy and expand to the home directory
$ cp /home/pi/Downloads/moin-1.9.9.tar.gz /home/pi $ cd /home/pi $ tar xzf moin-1.9.9.tar.gz $ sudo chown -R www-data:www-data moin-1.9.9 $ sudo chmod -R g+w moin-1.9.9 $ cd moin-1.9.9 $ touch moin-1.9.9.txt # show version number in folder # check for user in group www-data $ groups # if www-data is not included in the list, add user to it $ sudo adduser pi www-data
Moin WSGI setup for Apache2 web server
Setup moin.wsgi for Apache2 web server connection, see also MoinApache2WSGI .
$ cp wiki/server/moin.wsgi . $ gedit moin.wsgi - add: sys.path.insert(0, '/home/pi/moin-1.9.9') - add: from MoinMoin import log - add: log.load_config('/home/pi/moin-1.9.9/wikiserverlogging.conf') save file
Do first the newaccount.py modification, before activating the new wiki. Otherwise, latest after 5 minutes you will have some spam accounts set.
If after an apache2 restart the wiki page does not show CSS formatting,
look in file /etc/apache2/httpd.conf if Alias /moin_static197 is set wrong.
If after an apache2 restart the wiki pages does look OK, but after editing and saving a traceback is thrown, have a look for the permissions. Im my case the folder moin-1.9.9 should have user:group of www-data:www-data, the user folder must have the user:group permission of the user.
Setup wikiconfig.py
- Setup wikiconfig.py for server operation, sending email, and interwiki backup operation:
$ mv wikiconfig.py wikiconfig.py.org $ cp wiki/config/wikiconfig.py . $ sudo chown -R www-data:www-data * $ gedit wikiconfig.py - add: sitename = u'rudiswiki9' - add: instance_dir = os.path.join(wikiconfig_dir, 'wiki') just for customising - add: logo_string = u'<img src="%s/common/Asus900A_RudisWiki_baby_re.png" alt="RudisWiki Logo">' % url_prefix_static - add: page_front_page = u"Frontpage" - add: interwikiname = u'rudiswiki9' - add: show_interwiki = 1 - add: superuser = [u'RudolfReuter', ] - add: acl_rights_before = u'RudolfReuter:read,write,delete,revert,admin All:read' - add: mail_smarthost = "mail.arcor.de" - add: mail_from = u"RudolfReuter <reuxxxxx@arcor.de>" - add: mail_login = "reuterxx xxxxxxxx" # user password - add: language_default = 'de' save file
Cloning moin for backup
In order to clone moin for backup purpose you have to make several changes after copying to a new folder.
# First copy folder $ cp -r moin-1.9.6 moin-1.9.9 # Edit moin-1.9.9/moin.wsgi 2x sys.path.insert(0, '/home/pi/moin-1.9.9') log.load_config('/home/pi/moin-1.9.9/wikiserverlogging.conf') # Edit wikiserverlogging.conf 1x logfile=/home/pi/moin-1.9.9/moin_rot.log # Edit /etc/apache2/httpd.conf 7x, with sudo #Alias /moin_static196 /home/pi/moin-1.9.9/MoinMoin/web/static/htdocs/ <Directory /home/pi/moin-1.9.9/MoinMoin/web/static/htdocs> WSGIScriptAlias /wiki /home/pi/moin-1.9.9/moin.wsgi WSGIDaemonProcess moin_196b user=www-data group=www-data processes=1 threads=4 maximum-requests=100 umask=0007 WSGIProcessGroup moin_196b <Directory /home/pi/moin-1.9.9> # clear cache $ moin-1.9.9/moin.py maint cleancache # correct user:group $ sudo chown -R www-data:www-data moin-1.9.9 # get into use $ sudo service apache2 restart # adopt index page /var/www/index.html
Setup logging for rotating log file
In case of the "Desktop Edition" it is the easiest method to do the logging on the error output, in a console window.
If you want to setup "moin" in the server mode (run as background daemon) the logging must be done to a file. Especially in an embedded environment you do not have the full support of Linux. So, a rotating log file handler (python standard) is welcome.
- Setup wikiserverlogging.conf for rotating log:
# This is the standalone wikiserver logging configuration. # It can be easily modified to help when debugging, see the comments. # Available loglevels, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL # 2014-04-08 RudolfReuter, adopted to RotatingFileHandler [DEFAULT] #logfile=moin.log logfile=moin_rot.log [loggers] keys=root,moin_debug [logger_root] level=INFO #level=DEBUG handlers=stderr [logger_moin_debug] # adapt the next lines to your debugging needs: level=INFO #level=DEBUG handlers=stderr qualname=MoinMoin.auth propagate=0 [handlers] keys=logfile,stderr #keys=stderr [handler_logfile] class=FileHandler formatter=default level=DEBUG args=('%(logfile)s', 'at') [handler_stderr] #class=StreamHandler class=handlers.RotatingFileHandler formatter=default # after test, switch from DEBUG to INFO level=DEBUG #level=INFO #args=(sys.stderr, ) # rotate if the size of 64000 bytes are reached, 3 files total. # args filename, mode, maxBytes, backupCount args=('%(logfile)s', 'a', 64000, 2) [formatters] keys=default [formatter_default] format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s datefmt= class=logging.Formatter
Setup wikiserver.py stand alone version, moin.py (from MoinMoin/script/)
# Server run daemon: $ cp MoinMoin/sript/moin.py . # copy run daemon to main folder $ chmod 755 moin # set execute bits #from MoinMoin import log from MoinMoin import log #log.load_config('/path/to/logging_configuration_file') log.load_config('wikiserverlogging.conf')
Apache2 setup
- Edit /etc/apache2/httpd.conf` as described in MoinApache2WSGI and restart Apache2 web server:
$ sudo /etc/init.d/apache2 restart
Setup moin as web Standalone Server
In order to run moin as a web standalone server for testing, you have to do the following setup on file wikiserverconfig.py.
hostname = '' port = 8080 user = 'www-data' group = 'www-data' Start web server for test: $ ./wikiserver.py Point web browser to main web page: http://server-name-or-IP:8080
- If it works, the first step is to setup the superuser and login (Anmelden).
Find the page HelpOnLanguages and click on "install help and system page packages"
- First click on "English" and then on "all_pages install"
- Second click on "German" and then on "all_pages installieren"
- Now you have all system and help pages installed, in English and German
Last action is to read a lot of the help pages
In order to boot the moin standalone web server automatic create the file /etc/init.d/moin_sas.sh
File: /etc/init.d/moin_sas.sh #!/bin/sh ### BEGIN INIT INFO # Provides: moin_sas # Required-Start: $all # Required-Stop: # Default-Start: 2 # Default-Stop: # Short-Description: Start moin wiki as StandAlone Server (_sas). # Description: adopt PYTHONPATH, PREFIX ### END INIT INFO # Structur Reference: http://wiki.debian.org/LSBInitScripts/ # Debug with: sh -x moin_sas.sh (linewise output with '+' Prefix) # Port check with: nmap localhost # for DockStar, NSLU2, SlugOS/BE, RAM-disk # Start with "root", runs under "user" (setup in wikiserverconfig.py) for better security # file moin_sas.sh must be stored in /etc/init.d # Install file with: cd /etc/init.d; update-rc.d moin_sas.sh default # 2010-12-11 RudolfReuter # 2013-04-11 RudolfReuter, start with moin command if [ -d "/var/volatile" ]; then # create new RAM-disk directory RAMDISK="/var/volatile/www" # if not exist, create directory for user # no permission for user, if no execute bit! if [ ! -d "$RAMDISK" ]; then mkdir -m 755 "$RAMDISK" 2>&1 | logger chown pi:pi "$RAMDISK" fi fi PYTHONPATH="/usr/bin/python" # check for existing python if [ ! -e "$PYTHONPATH" ]; then echo "moin_sas.sh: Error - NO $PYTHONPATH" | logger exit fi PREFIX="/home/pi/moin-1.9.9" # moin home folder PARAMS=" server standalone --user=www-data --group=www-data" DAEMON="moin.py" MOINPATH=${PREFIX}/${DAEMON} if [ ! -x "$MOINPATH" ]; then echo "moin_sas.sh: Error - No file moin, or no exec attr. 775" | logger exit fi # check for first letter of LINK in /etc/rc2.d and set START/STOP if [ -z "$1" ] ; then case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in S??*) rc="start" ;; K??*) rc="stop" ;; *) rc="usage" ;; esac else rc="$1" fi case "$rc" in start|"") echo "Starting web server: $DAEMON" 2>&1 | logger cd $PREFIX $MOINPATH $PARAMS --start 2>&1 | logger # change owner, otherwise it cannot be deleted at Stop if [ -e "moin.pid" ] ; then chown www-data:www-data moin.pid fi ;; stop) echo "Stopping web server: $NAME" 2>&1 | logger cd $PREFIX $MOINPATH $PARAMS --stop 2>&1 | logger ;; restart) "$0" stop sleep 1 "$0" start ;; *) echo "Usage: $0 (start|stop|restart)" exit 3 ;; esac exit 0 # end of file
and install it with:
$ sudo update-rc.d moin_sas.sh defaults the startup link "/etc/rc2.d/S03moin_sas.sh" will be created. For more information to the init system type: man update-rc.d, or man init
Additional server help file moin must be copied to the home directory and extended:
$ cd /home/pi/moin $ cp wiki/server/moin moin Add the following lines before "run()" to change the logging config: from MoinMoin import log log.load_config('wikiserverlogging.conf')
Now the moin daemon can be started manually for testing:
$ sudo /etc/init.d/moin_sas.sh start Check with process dir: $ ps -Af www-data 8861 1 0 13:46 ? 00:00:06 python /home/pi/moin-1.9.9/moin server standalone --user=www-data --group=www-data --start # in the logging file moin_rot.log the last 4 lines should be: date INFO MoinMoin.log:135 using logging configuration read from "/home/pi/moin-1.9.9/wikiserverlogging.conf" date INFO MoinMoin.log:157 Running MoinMoin 1.9.9 release code from /home/pi/moin-1.9.9/MoinMoin date INFO MoinMoin.web.serving:129 Running as uid/gid 33/33 date INFO werkzeug:116 * Running on http://localhost:8080/ # If it does not work, you can trace the startup file: $ sudo bash -x /etc/init.d/moin_sas.sh start
After a reboot the moin standalone server should now start automatically.
moin security fixes
Better use version 1.9.9 which includes all security fixes.
On this web page you can find the security fixes for moin.
The installation is also described. What was missing was a detailed patch procedure. So, I will try to explain it more detailed, in order to make it more easy to apply the patches. Therefore I will use a security fix of moin 1.9.5 as an example.
Rename the downloaded file c98ec456e493 to a more readable name m195_security_fix1.diff
Copy the diff file to the moin folder, which contains the folder MoinMoin
cd to this folder
- Use the following command to try the diff:
$ patch --verbose --dry-run -b -p1 < m195_security_fix1.diff # explanation of the options --verbose # tell me more --dry-run # just test the patch -b # make a backup of the original file -p1 # reduce one level of the path in the diff file (a/)
- If that does not show any errors, do the patch with:
$ patch --verbose -b -p1 < m195_security_fix1.diff
Setup for interwiki Sync
Because I had a lot of problems with interwiki sync, I switched to utility rsync, and call rsync to sync the whole path wiki/data/pages.
Delete all synctags at once
In case of manual copying pages between servers, or synching with multiple servers, it is necessary to delete before synching the synctags in the page folder. This can be done for all pages from the command line:
$ cd wiki $ find . -name synctags -exec rm {} \;
Moin Update / Setup
When you update the moin wiki software, you basically install a new version, and set it up to your specific needs.
In the next step you copy all your old data pages to the new wiki, and restart it (touch moin.wsgi).
When all was setup correct, you navigate to the new wiki address. What do you see: Not very much, a logo and a menu bar. The next steps are:
Setup the configured superuser as a user
- Login with your user as superuser
Search for the page LanguageSetup
- Read the page carefully up to the end
Click on install help and system page packages
Click on the first Language, in my case German
Click on all_pages install, if you do not know better
Click on the second Language, in my case English
Click on the Logo in the upper left corner, a message appears, that no FrontPage is setup up to now.
The only pages are now BadContent, FrontPage, and MissingPage
If it is not your fist wiki, instead an update, copy the old pages (version 1.9.x) from wiki/data/pages/ to the new installation.
In order to not limiting the TableOfContent width to 50% line length, I increased this value to 90% in MoinMoin/web/static/htdocs/modern/css/common.css about line 139. This will reduce the number of line breaks in the table of contents.
max-width: 90%; /* 2012-03-07 RudolfReuter, 50% -> 90%, reduce line breaks */
Highlight Lexer
In order to displaying a table with the list of available Pygments lexers, you need HighlighterList macro. To install:
Copy the file HighlighterList.py to path wiki/data/plugin/macro/
GraphViz Support
In order to install the moin support for Graphviz you have to install from the archiv [[https://moinmo.in/GraphVizForMoin?action=AttachFile&do=view&target=MoinGraphViz-1.0rc4-brn-1.9.x.comp.zip|MoinGraphViz-1.0rc4-brn-1.9.x.comp.zip]:
$ unzip MoinGraphViz-1.0rc4-brn-1.9.x.comp.zip # to wiki/data/plugin/action/ # to wiki/data/plugin/parser/ $ cp -r MoinGraphViz-1.0rc4-brn-1.9.x.comp/wiki ~/moin-1.9.9/wiki/ $ cp -r MoinGraphViz-1.0rc4-brn-1.9.x.comp/umoin ~/moin-1.9.9/MoinMoin/support/
newaccount, superuser only
To block spammers, it is neccessary to not allow everybody to create a new user:
http://www.moinmo.in/FeatureRequests/DisableUserCreation In order to avoid SPAM creating new accounts, patch MoinMoin/action/newaccount.py $ diff -c newaccount.py.org newaccount.py.mod *** newaccount.py.org 2012-02-07 22:36:47.000000000 +0100 --- newaccount.py.mod 2012-03-13 06:53:02.000000000 +0100 *************** *** 167,172 **** --- 167,176 ---- page = Page(request, pagename) _ = request.getText + # 2011-08-20 RR + if not request.user.isSuperUser(): + request.theme.add_msg(_('You are not allowed to use this action.'), "error") + return page.send_page() form = request.form submitted = form.has_key('create') Now only the superuser can create a new account with URL: http://www.rudiswiki.de/wiki/StartSeite?action=newaccount
Contact Email page
For the Contact Email function you need the MoinComments Macro. To install it:
Copy file comments.css to path MoinMoin/web/static/htdocs/modern/css/
Edit file MoinMoin/web/static/htdocs/modern/css/screen.css, add after the title lines:
/* For MoinComments macro, 2012-03-07 RudolfReuter */ @import "comments.css";
from the archive moin-comments-0.2.tar.gz copy the files AddComment.py and comment_utils.py to path wiki/data/plugin/macro/
Then you title your macro AddComment with Contact Email and subscribe the page. Text to insert into the page:
=== Contact Email === <<AddComment>>
When the user clicks on Send comment, the subscriber of the page will get the comment message as an Email.
Beware, when you test that function, you have to log out before you send, otherwise no Email will be send, because a notification Email is not send to the owner of the page.
Contact Email reCAPTCHA
2017-11-04, Google wanted to change reCaptcha from version 1 to version 2. Fortunately Helder made the change on AddComments.py. Fortunately the old keys could still be used. But I needed to remove the "logged-in users only" limitation.
Line 300: if self.can_create: # changed by: try:
Unfortunately a spammer misused my Contact Email function. Fortunately the author of package moin-comments-0.2 has provided access to the reCAPTCHA function (version 1) of Google. On that page you click on the intro link. In order to use that function, you must have an Google Email account. Next step is to sign up for an API key pair for your site. The key pair consists of a site key (public key) and secret (private key).
MoinMoin Configuration
In the configuration file wikiconfig.py you must set the parameters:
# append to file wikiconfig.py .... # 2015-12-29 use reCAPTCHA from google, because of spammer comment_recaptcha = True comment_recaptcha_public_key = "6LfDBxQTAAAAAJfBLwv......................." comment_recaptcha_private_key = "6LfDBxQTAAAAACn5q........................" comment_recaptcha_use_ssl = True ....
Next you must download the reCAPTCHA client library (for python) and copy it in the main folder of MoinMoin (usually moin-1.9.9/) under the name captcha.py. There exists also an install package for download, but I could not get it to work. It installs a module named recaptcha.py, but the software moin-comments-0.2 did not work with that module.
With all that setup, the next step is to restart the wiki. If you have a wsgi connection to the web server apache2, you can do it with:
$ cd moin-1.9.9 $ touch moin.wsgi
When you navigate to a wiki page with the macro AddComment,
When you access your web server via the inhouse IP address then reCaptcha will not work (an internal error occurred: xxx), because the domain has changed.
Screen Width Limit
In order to have a more consistent layout on different screen width, I limited the screen width in the CSS to 1000 pixel. This can be edit on line. After a reload of the web page the effect is visible.
Path MoinMoin/web/static/htdocs/modern/css/screen.css Edit to: body { padding: 0; border: 0; width: 1000px; }
Moin Logo Graphic
The moin logo should show, on which computer it is installed.
- In all cases the operating is Linux, so the penguin must be there.
- On top is the name of the computer.
- In the center the CPU clock rate is shown (color red).
In the bottom line either the wiki name, or the version of the Linux distribution is shown.
- File location (v.1.9.4): MoinMoin/web/static/htdocs/common/
The file must be defined in: wikiconfig.py
logo_string = u'<img src="%s/common/RudisWiki_Dockstar_baby.png" alt="RudisWiki Logo">' % url_prefix_static
The logo is drawn with Gimp. For example the logo for the Dockstar heating temperature measurement:
File name, Gimp version: RudisWiki_Dockstar_baby.xcf
File name, wiki use: RudisWiki_Dockstar_baby.png
- Font: Arial Rounded MT Bold
- The shadow for the 3D effect is build with the parameters:
- x-offset: 3 pixel
- y-offset: 3 pixel
- Fade: 4 pixel
- Transparency: 40%
- The transparent round edges of the rectangle are: Radius 15 pixel, edge smoothing ON
- select rectangle with rounded edges, invert selection, delete selection (=transparent)
- Setup information is in menu: Picture/Picture properties/Comment
Count wiki pages
If you want to know how many personal pages your wiki has (including the deleted ones), use the command line:
$ ls -l moin-1.9.6/wiki/data/pages | wc -l 208
If you use the macro <<PageCount(exists)>> you will also get in addition the underlay pages as well.
Number of all existing pages: 644
Compare directories
You can compare directories with the standard diff command, see:
$ diff moin-1.9.8/wiki/data/pages moin-1.9.9/wiki/data/pages
Links
Very good setup description for version 1.9.3: http://moinmo.in/HowTo/CentOSQuick
Good explanation of services, init (DE: Dienste) in Ubuntu: http://wiki.ubuntuusers.de/dienste
Good explanation of init in Debian: http://wiki.debian.org/LSBInitScripts/
Gimp help: http://gimp-handbuch.de
Gimp, transparent rounded edges: http://www.gimpforum.de/archive/index.php/t-11704.html
List of pages in this Category:
-- RudolfReuter 2010-12-29 20:30:21
Go back to CategoryMoinMaintenance or FrontPage ; KontaktEmail (ContactEmail)