[arch-general] problems configuring moinmoin wikifarm
shadrock uhuru
niyalevi at gmail.com
Fri Apr 12 00:31:50 UTC 2019
hi everyone
i am trying to install moinmoin as a wiki farm using nginx as the webserver,
the nginx is configured and i can acces the welcome page with https,
i mainly followed the arch wiki page for moinmoin'
as arch wiki only gives configuration for a single wiki instance i have
also use information from other sources
i would like to access the wiki farm at http://cleopatra.mydomain/moin/,
e.g.
http://cleopatra.mydomain/moin/wiki1
http://cleopatra.mydomain/moin/wiki2
when i go to the page it returns
Not Found
<p>No wiki configuration matching the URL found!</p>
as the error logs show the server is trying to access file from
/srv/nginx/html instead of from /srv/nginx/moin
could someone look over everything i've done and point out where my
errors are,
i've included the config files i've changed and the bash script i used
to configure the wiki,
i would also welcome suggestions if the script could do with improving.
thanks
shadrock
===========
/var/log/nginx/error.log
2019/04/11 11:16:39 [error] 3020#3020: *1 open()
"/srv/nginx/html/favicon.ico" failed (2: No such file or directory),
client: 10.2.1.228, server: cleopatra.mydomain, request: "GET
/favicon.ico HTTP/2.0", host: "cleopatra.mydomain"
2019/04/11 12:04:29 [error] 3020#3020: *3 open()
"/srv/nginx/html/favicon.ico" failed (2: No such file or directory),
client: 10.2.1.228, server: cleopatra.mydomain, request: "GET
/favicon.ico HTTP/2.0", host: "cleopatra"
===========
===========
/etc/nginx/nginx.conf
http {
# Logging Settings
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html index.htm;
# include sites-enabled/*; # See Server blocks
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Redirect to HTTPS
server {
listen 80;
server_name cleopatra.mydomain;
return 301 https://$host$request_uri;
}
# HTTPS server
server {
#listen 80; # Uncomment to also listen for HTTP requests
listen 443 ssl http2; # HTTP/2 is only possible when using SSL
listen [::]:443 ssl http2;
server_name cleopatra.mydomain;
# root /srv/nginx/html;
ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/nginx/html;
}
location / {
root /srv/nginx/html;
}
location /moin/ {
uwsgi_pass unix:/run/uwsgi/moin.sock;
include /etc/nginx/uwsgi_params;
}
location ~ /moin/moin_static[0-9]+/(.*) {
alias /srv/nginx/moin/static/htdocs/$1;
}
location /moin/favicon.ico {
alias /srv/nginx/moin/static/htdocs/favicon.ico;
}
}
}
===========
===========
moin.wsgi ## included only changed parameters
# -*- coding: iso-8859-1 -*-
import sys, os
sys.path.insert(0, '/srv/nginx/moin')
from MoinMoin.web.serving import make_application
application = make_application(shared='/srv/nginx/moin/static/htdocs')
===========
===========
moinmoin_install.sh
#!/bin/bash
## ./moinmoin.sh 2>&1 | tee moinmoin.debug
. ../../conf/functions.sh
INSTALLBASE=`pwd`
SERVERBASE=/srv/nginx
## if restarting scripts disable active services
for MYSERVICE in nginx moinmoin
do
if systemctl status $MYSERVICE | grep --quiet 'active (running)'; then
echo
echo stopping $MYSERVICE service
systemctl stop $MYSERVICE && systemctl disable $MYSERVICE
fi
done
pacman -S --needed nginx-mainline python2
## alarm is a non privileged user
/bin/su -c "aurman -S --needed moinmoin uwsgi-plugin-python2
perl-html-wikiconverter-moinmoin" - alarm
# nginx
## from function.sh -- backup if no backup file found or restore backup
file if found
backup_restore_file "/etc/nginx/nginx.conf"
systemctl enable nginx
systemctl start nginx
systemctl status nginx
echo
echo creating ssl keys
echo
mkdir -p /etc/nginx/ssl
cd /etc/nginx/ssl
openssl req -new -x509 -nodes -newkey rsa:4096 -keyout server.key -out
server.crt
chmod 400 server.key
chmod 444 server.crt
cd $INSTALLBASE
## use /srv/nginx as the server base
cp -r /usr/share/nginx /srv/
chown -R http:http $SERVERBASE
## my nginx.conf
cp ../nginx.conf /etc/nginx/nginx.conf
echo
echo checking nginx config file
echo
nginx -t
WIKIFARM=$SERVERBASE/moin
mkdir -p $WIKIFARM
# Wikifarm creation
mkdir -p $WIKIFARM/master # master wiki instance folder, to be cloned later
mkdir -p $WIKIFARM/users # where all the users data will be
mkdir -p $WIKIFARM/cache # where all the cache and sessions data will be
cp /usr/share/moin/config/wikifarm/farmconfig.py $WIKIFARM/
cp /usr/share/moin/config/wikifarm/mywiki.py $WIKIFARM/master.py
cp -R /usr/share/moin/data $WIKIFARM/master
cp -R /usr/share/moin/underlay $WIKIFARM/master
# static stuff like logos and themes will be placed here
cp -Rp /usr/lib/python2.7/site-packages/MoinMoin/web/static $WIKIFARM
# create wiki instance folder and configuration from the master one
## include following section in farmconfig.py
cat << EOF > /tmp/pat
##lab_public##
("public", r"^http://cleopatra\.mydomain/moin/public/.*$"),
##lab_public!!
##lab_reserved##
("reserved", r"^https?://cleopatra\.mydomain/moin/reserved/.*$"),
##lab_reserved!!
EOF
awk '/^wikis = /{print;f=1;next;}/^\]/{print;f=0;next;}f!=1{print}'
$WIKIFARM/farmconfig.py | sed '/wikis = \[/r /tmp/pat' > /tmp/newfile
mv /tmp/newfile $WIKIFARM/farmconfig.py
rm /tmp/pat
sed -i "s;#url_prefix_static = .*$;url_prefix_static =
'$WIKIFARM/static/htdocs';" $WIKIFARM/farmconfig.py
echo 'tz_offset = 1.0' >> $WIKIFARM/farmconfig.py
cp -Rp $WIKIFARM/master/* $WIKIFARM/public
# cp $WIKIFARM/master.py $WIKIFARM/public.py
cp -Rp $WIKIFARM/master/* $WIKIFARM/reserved
# cp $WIKIFARM/master.py $WIKIFARM/reserved.py
for WIK in public reserved
do
cat << EOF > $WIKIFARM/${WIK}.py
# -*- coding: iso-8859-1 -*-
from farmconfig import FarmConfig
class Config(FarmConfig):
sitename = u'${WIK}' # [Unicode]
interwikiname = u'${WIK}' # [Unicode]
page_front_page = u"${WIK}_Start_Page"
data_dir = '$WIKIFARM/${WIK}/data/'
data_underlay_dir = '$WIKIFARM/${WIK}/underlay'
EOF
done
#Uwsgi
cp /usr/share/moin/server/moin.wsgi $WIKIFARM
#sed -i 's/\(^.*SGIScriptAlias\).*$/#\1/' $WIKIFARM/moin.wsgi
#sed -i "/^#.*WSGIScriptAlias/ a\WSGIScriptAlias /reserved
$WIKIFARM/moin.wsgi" $WIKIFARM/moin.wsgi
#sed -i "/^#.*WSGIScriptAlias/ a\WSGIScriptAlias /public
$WIKIFARM/moin.wsgi" $WIKIFARM/moin.wsgi
#sed -i 's/daemonname/moin/' $WIKIFARM/moin.wsgi
#sed -i 's/user=someuser/user=http/' $WIKIFARM/moin.wsgi
#sed -i 's/group=somegroup/group=http/' $WIKIFARM/moin.wsgi
sed -i '/\/path\/to\/farmconfigdir/s/^#//' $WIKIFARM/moin.wsgi
sed -i "s-/path/to/farmconfigdir-$WIKIFARM-" $WIKIFARM/moin.wsgi
sed -i 's/application = make_application/s/shared=True/shared=False/'
$WIKIFARM/moin.wsgi
cat << EOF > $WIKIFARM/uwsgi.ini
[uwsgi]
socket = /run/uwsgi/moin.sock
chmod-socket = 660
plugin = python2
chdir = $WIKIFARM/
wsgi-file = $WIKIFARM/moin.wsgi
master
workers = 3
max-requests = 200
harakiri = 60
die-on-term
EOF
# fix security on folders
chown -R http:http $WIKIFARM
chmod -R ug+rwX $WIKIFARM
chmod -R o-rwx $WIKIFARM
# service file for MoinMoin with uwsgi
cat << EOF > /etc/systemd/system/moinmoin.service
[Unit]
Description=Start uwsgi for moinmoin wiki
After=network.target
[Service]
Type=simple
User=http
ExecStart=/usr/bin/uwsgi --ini $WIKIFARM/uwsgi.ini
[Install]
WantedBy=multi-user.target
EOF
echo
echo restarting services
echo
systemctl enable moinmoin
systemctl start moinmoin
systemctl restart nginx
systemctl status nginx moinmoin
echo
echo creating wiki create/delete scripts
echo
cat << EOF > /usr/local/bin/create_wiki
#!/bin/bash
WIKIFARM=/srv/nginx/moin
CONFIGFILE=/srv/nginx/moin/farmconfig.py
CREATE=''
echo
echo the following wikis will be created
echo "\$@"
echo
for NEWWIKI in "\$@"
do
if grep -q \$NEWWIKI \$CONFIGFILE; then
echo \$NEWWIKI exists in \$CONFIGFILE!! skipping creation
else
cp -Rp \$WIKIFARM/master/* \$WIKIFARM/\$NEWWIKI
# cp \$WIKIFARM/master.py \$WIKIFARM/\${NEWWIKI}.py
cat << INNEREOF > \$WIKIFARM/\${NEWWIKI}.py
# -*- coding: iso-8859-1 -*-
from farmconfig import FarmConfig
class Config(FarmConfig):
sitename = u'\${NEWWIKI}' # [Unicode]
interwikiname = u'\${NEWWIKI}' # [Unicode]
page_front_page = u"\${NEWWIKI}_Start_Page"
data_dir = '\$WIKIFARM/\${NEWWIKI}/data/'
data_underlay_dir = '\$WIKIFARM/\${NEWWIKI}/underlay'
INNEREOF
INTRO_BLOCK="
##lab_\${NEWWIKI}##
("\$NEWWIKI", r"^http://cleopatra\.mydomain/\$NEWWIKI/.*\$"),
##lab_\${NEWWIKI}!!
"
# gawk -i inplace -v x="\$INTRO_BLOCK" '{print} /wikis =
\[/{print x}' \$CONFIGFILE
cat \$CONFIGFILE | awk -v x="\$INTRO_BLOCK" '{print} /wikis =
\[/{print x}' > nefil && mv newfil \$CONFIGFILE
CREATE='y'
fi
done
if "[\$CREATE" == 'y']; then
chown -R http:http \$WIKIFARM
chmod -R ug+rwX \$WIKIFARM
chmod -R o-rwx \$WIKIFARM
systemctl restart nginx moinmoin
fi
EOF
chmod 744 /usr/local/bin/create_wiki
cat << EOF > /usr/local/bin/delete_wiki
#!/bin/bash
WIKIFARM=/srv/nginx/moin
CONFIGFILE=/srv/nginx/moin/farmconfig.py
DELETE=''
echo
echo the following wikis will be deleted
echo "\$@"
echo
read -r -p "Are you sure? [y/N] " ANS
if [[ "\$ANS" =~ ^(yes|y)\$ ]]
then
for WIKINAME in "\$@"
do
echo checking if \$WIKINAME wiki exist
if [ -d \$WIKIFARM/\$WIKINAME ]; then
DELETE=Y
echo deleting $WIKINAME
rm -r \$WIKIFARM/$WIKINAME
else
echo \$WIKIFARM/\$WIKINAME does not exist!! skipping
fi
if [ -e \$WIKIFARM/\${WIKINAME}.py ]; then
DELETE=Y
rm \$WIKIFARM/\${WIKINAME}.py
else
echo \$WIKIFARM/\${WIKINAME}.py does not exist!! skipping
fi
if grep -q \$WIKINAME \$CONFIGFILE; then
sed -i
'/^##lab_'"\$WIKINAME"'##/,/^##lab_'"\$WIKINAME"'!!/d' \$CONFIGFILE
DELETE='Y'
else
echo \$WIKINAME not found in \$CONFIGFILE!! skipping
fi
done
fi
if ["\$DELETE" == 'Y']; then
systemctl restart nginx moinmoin
fi
EOF
chmod 744 /usr/local/bin/delete_wiki
echo
echo moinmoin wiki installed
echo
===========
More information about the arch-general
mailing list