How to Install MoinMoin on CentOS 7

Published on: Tue, Nov 7, 2017 at 10:21 am EST
CentOS Linux Guides Server Apps Web Servers

MoinMoin is an open source, filesystem-based wiki engine written in Python. Nowadays, MoinMoin is widely used in open source community. Many vendors, including, but not limited to Apache, Ubuntu, Debian, and Python, have setup their own wikis with the MoinMoin wiki engine.

In this tutorial, you will learn how to setup a single MoinMoin wiki site on a CentOS 7 server instance. In order to serve MoinMoin, Nginx and uWSGI will be installed as well.

Prerequisites

Step 1: Install and configure Nginx

Before you can get MoinMoin up and running, you need to setup a web server for it, and Nginx is a great choice for that purpose.

1) As a matter of convenience, you can install Nginx using the EPEL YUM repo:

sudo yum install nginx -y

2) Configure Nginx as follows so that it can work with uWSGI and MoinMoin.

Use the vi text editor to open the main Nginx config file /etc/nginx/nginx.conf:

sudo vi /etc/nginx/nginx.conf

Within the http { } segment, find the server { } segment which is excerpted below:

http {

...

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

...

2.1) Use the server's IP address to define a server name for Nginx:

Find the line:

server_name _;

Replace it with:

server_name  203.0.113.1;

2.2) Configure Nginx as using the uWSGI protocol for communications:

Find the location / { } segment:

location / {
}

Insert two lines as below:

location / {
    uwsgi_pass unix:///run/moin/moin.sock;
    include uwsgi_params;
}

Save and quit:

:wq!

3) Optionally, you can test the modified configuration with the following command:

sudo nginx -t

If nothing goes wrong, you should see the output as below:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

4) Finally, start the Nginx service and make it start automatically on system boot:

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Step 2: Install and configure MoinMoin

1) Use the following commands to install MoinMoin 1.9.9, the latest stable release of MoinMoin at the time I wrote this article:

cd
wget http://static.moinmo.in/files/moin-1.9.9.tar.gz
tar -zxvf moin-1.9.9.tar.gz
cd moin-1.9.9
sudo python setup.py install --force --record=install.log --prefix='/opt/moin' --install-data=/srv

After running commands above, the MoinMoin executable and all library files will be installed in the /opt/moin directory, and data used for building your own single MoinMoin wiki will be installed in the /srv/share/moin directory.

2) Create a config file named moin.wsgi in the MoinMoin data directory using a template file of the same name:

cd /srv/share/moin/
sudo cp server/moin.wsgi moin.wsgi

Open the newly created config file using the vi text editor:

sudo vi /srv/share/moin/moin.wsgi

Find the following line:

import sys, os

Append the following two lines beneath:

sys.path.insert(0, '/opt/moin/lib/python2.7/site-packages/')
sys.path.insert(0, '/srv/share/moin/')

Save and quit:

:wq!

3) Create another MoinMoin wiki config file which will be used to customize your own wiki:

cd /srv/share/moin
sudo cp config/wikiconfig.py wikiconfig.py

You can configure many features for your MoinMoin wiki in this file, but for now, you just need to setup several features as below.

Define the site name (Say it is My First Wiki):

sudo sed -i 's/Untitled Wiki/My First Wiki/' /srv/share/moin/wikiconfig.py

Define a superuser (Say it is admin):

sudo sed -i '/#superuser/a\    superuser = [u\"admin\", ]' /srv/share/moin/wikiconfig.py

Note: You still need to register this user from the MoinMoin web interface later.

Disable reverse DNS lookups for acceleration:

sudo sed -i '$a\    log_reverse_dns_lookups = False' /srv/share/moin/wikiconfig.py

4) Change the ownership of installed MoinMoin files:

sudo chown -R nginx:nginx /srv/share/moin
sudo chown -R nginx:nginx /opt/moin

Step 3: Install and configure uWSGI

Acting as a hub between the Nginx web server and a Python application, uWSGI is designed to produce best performance using the high-performance uWSGI protocol. Next, let's take a look at how to install and configure uWSGI for running MoinMoin.

1) Use pip to install uWSGI as follows:

sudo yum install -y python-devel python-setuptools python-pip gcc
sudo pip install --upgrade pip
sudo pip install uwsgi

If everything goes well, you should see the output similar to:

...
Successfully installed uwsgi-2.0.15

2) Having uWSGI installed, you need to create a directory to store uWSGI log files:

sudo mkdir /var/log/uwsgi
sudo chown nginx:nginx /var/log/uwsgi

3) In addition, you need to create a directory to store the MoinMoin socket file:

sudo mkdir /run/moin
sudo chown nginx:nginx /run/moin

4) Create a uWSGI config file uwsgi.ini in the MoinMoin wiki data directory and populate it as follows:

cat <<EOF | sudo tee -a /srv/share/moin/uwsgi.ini
[uwsgi]
uid = nginx
gid = nginx
socket = /run/moin/moin.sock
chmod-socket = 660
logto = /var/log/uwsgi/uwsgi.log

chdir = /srv/share/moin
wsgi-file = /srv/share/moin/moin.wsgi

master = true
processes = 3
max-requests = 200
harakiri = 30
vacuum = true
enable-threads = true
EOF

5) In order to use systemd to manage uWSGI, you need to setup a systemd unit file for uWSGI:

cat <<EOF | sudo tee -a /etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI instance to serve MoinMoin
After=syslog.target

[Service]
ExecStart=/usr/bin/uwsgi --ini /srv/share/moin/uwsgi.ini
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target
EOF

6) Start the uWSGI service and make it automatically start on system boot:

sudo systemctl start uwsgi.service
sudo systemctl enable uwsgi.service

Step 4: Allow web access

Configure firewall rules as follows so that users can visit your MoinMoin wiki site using a web browser:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Step 5: Access MoinMoin from a web browser

Now, a single MoinMoin wiki site has been up and running on your CentOS 7 server instance.

Point your favorite web browser to http://203.0.113.1, and then you will get into the MoinMoin web interface. Sign up and log in as the superuser admin we mentioned earlier, and then you are able to manage your wiki site as you wish.

If necessary, you can make more customization by editing the /srv/share/moin/wikiconfig.py file.

This concludes the tutorial. Thanks for reading.

Want to contribute ?

You could earn up to $300 by adding new articles