Contents
About this HowTo
- MoinMoin versions
- 1.9.8
- Platforms
- Debian 8
Detailed guide for setting up MoinMoin on Debian 8. This was tested on the Jessie release but should also work on testing/unstable. It used a python virtual environment, uwsgi, and nginx. I have simply created this as a basic setup so performance changes will need made to suit the particular server and environment this is being run on.
Preparing the server
First we need to get the current MoinMoin release from https://moinmo.in/MoinMoinDownload which at the time of writing is 1.9.8 as well as install the supporting applications.
Note: You can use the uwsgi package from apt if preferred but it will not be as updated as the pip install
wget http://static.moinmo.in/files/moin-1.9.8.tar.gz tar xzvf moin-1.9.8.tar.gz apt-get update && apt-get install -y nginx python-pip python-dev build-essential pip install uwsgi virtualenv useradd -r -s /sbin/nologin -d /srv/moin moin
Next we setup a specific account for moin and start to setup permissions on the needed directories. During this phase we also install the MoinMoin software from the tarball downloaded previously. This is done with a virtual environment to isolate the required version of Python to avoid conflicts.
mkdir -p /srv/moin /var/log/moin chown -R moin /var/log/moin virtualenv /srv/moin/pythonenv source /srv/moin/pythonenv/bin/activate cd moin-1.9.8 python setup.py install --record=install.log deactivate
Now that we have MoinMoin installed we should make a copy of the config rather than modifying the defaults. This provides easy rollback and will consolidate them into one location for the uwsgi configuration. We also want to ensure that the directory is owned by our moin user and group for security.
cp -r wiki/ /srv/moin cd /srv/moin/wiki cp config/wikiconfig.py ./ && cp server/moin.wsgi ./ chown -R moin:moin /srv/moin
Finally we need to tell MoinMoin where our new application and configuration files are in order for it to properly run. Simply open moin.wsgi in your favorite text editor and add the indented lines below under the commented out lines that are similar.
vim moin.wsgi sys.path.insert(0, '/srv/moin/pythonenv/lib/python2.7/site-packages/') sys.path.insert(0, '/srv/moin/wiki/')
Configuring uwsgi
Navigate to your wiki directory and simply copy and paste the below into uwsgi.ini. Ensure the path to moin.uwsgi and the uid matches the user created previously if it does not match 'moin' per this article. The group should be set to match nginx in order for nginx to read and write to the socket to communicate with uwsgi.
vim /srv/moin/wiki/uwsgi.ini [uwsgi] plugins = python master = true uid = moin gid = www-data processes = 1 logto = /var/log/moin/moin.log socket = /var/run/moin/moin.sock chmod-socket = 660 wsgi-file = /srv/moin/wiki/moin.wsgi
MoinMoin systemd service file
Create the following file using your favorite text editor to allow the MoinMoin wiki application to run as a service during boot. The group must be www-data for nginx to be able to read and write to the socket necessary for communication with uwsgi. If you do not specify this then nginx will not have access to the socket in /run/moin
vim /etc/systemd/system/moin.service [Unit] Description=MoinMoin wiki application After=syslog.target network.target [Service] Type=simple ExecStart=/usr/local/bin/uwsgi --ini /srv/moin/wiki/uwsgi.ini ExecReload=/usr/local/bin/uwsgi --ini /srv/moin/wiki/uwsgi.ini --reload ExecReload=/usr/local/bin/uwsgi --ini /srv/moin/wiki/uwsgi.ini --stop Restart=no RuntimeDirectory=moin User=moin Group=www-data KillSignal=SIGQUIT [Install] WantedBy=multi-user.target
nginx configuration
Create a new virtualhost in nginx and copy and paste the below configuration for a basic setup. This is very simple and adds no security and uses a generic domain name.
vim /etc/nginx/conf.d/wiki.example.com.conf server { server_name wiki.example.com; access_log /var/log/nginx/wiki.example.com_access.log; error_log /var/log/nginx/wiki.example.com_error.log; location / { include uwsgi_params; uwsgi_pass unix:///var/run/moin/moin.sock; uwsgi_modifier1 30; } }
Final steps
Simply enable the moin and nginx services and boot and start the applications.
systemctl enable moin nginx && systemctl start moin nginx
Now just navigate to the IP of your server in a browser and you should see the setup page for MoinMoin.
Use BasicAuth for MoinMoin users
Add the following lines to wikiconfig.wsgi.
from MoinMoin.auth import GivenAuth # add to security section auth = [GivenAuth(autocreate=True)]
Then add the following to the nginx virtual host file in the location block after the include statement. Substitude the auth_basic string and user file as appropriate to your environment.
auth_basic "Authorized users only"; auth_basic_user_file .htpasswd; uwsgi_param REMOTE_USER $remote_user;
Restart both services and users listed in a .htpasswd file will be used for user authentication.