How to deploy MoinMoin on Nginx and uwsgi using Python scripts
This article mainly introduces how to use Python scripts to deploy MoinMoin on Nginx and uwsgi. The example is based on the CentOS operating system. For more information, see
MoinMoin is deployed using apache + mod_wsgi in CentOS, but the editing and saving pages are slow. Therefore, you are ready to redeploy the MoinMoin using nginx + uwsgi.
This document assumes that Quick MoinMoin on CentOS has completed basic installation beyond apache and mod_wsgi following official instructions.
Install Nginx
By default, CentOS without nginx source, you need to manually add, access the http://nginx.org/en/linux_packages.html#stable to download CentOS 6 rpm package, and install
?
1 2 |
Wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm Rpm-ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm |
Run the following command to install nginx:
Yum install nginx
Install uwsgi
Install python package management tool pip
?
1 2 |
Yum install python-devel python-setuptools Wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py-O-| python |
Install uwsgi using pip (using the image of Douban)
?
1 |
Pip install-v uwsgi-I http://pypi.douban.com/simple |
Start moin with uwsgi
Create uwsgi configuration/etc/uwsgi. xml as follows
?
1 2 3 4 5 6 7 8 9 |
<Uwsgi> <Socket>/var/run/moin. sock </socket> <Chmod-socket> 666 </chmod-socket> <Limit-as> 256 </limit-as> <Processes> 6 </processes> <Memory-report/> <Vhost/> <No-site/> </Uwsgi> |
Where 666 This statement prevents nginx from having no permission to access moin. sock.
Rename the moin wsgi STARTUP script to be recognized by uwsgi.
?
1 2 |
Cd/usr/local/share/moin Mv moin. wsgi moin_wsgi.py |
To start uwsgi, run the following command:
?
Configure nginx to access uwsgi
Create/etc/nginx/conf. d/moin. conf as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Moinmoin VM Configuration Server { Listen YOUR_SERVER_IP: 80; Server_name localhost; Access_log/var/log/nginx/moin. access_log main; Error_log/var/log/nginx/moin. error_log info; Location ^ ~ /{ Include uwsgi_params; Uwsgi_pass unix: // var/run/moin. sock; # Uwsgi_param UWSGI_PYHOME/usr/local/lib/python2.6/; # site-packages /; Uwsgi_param UWSGI_CHDIR/usr/local/share/moin /; Uwsgi_param UWSGI_SCRIPT moin_wsgi; Uwsgi_param SCRIPT_NAME /; Uwsgi_modifier1 30; } Location ^ ~ /Moin_static193 /{ Alias/usr/local/lib/python2.6/site-packages/MoinMoin/web/static/htdocs /; Add_header Cache-Control public; Expires 1 M; } } |
Run nginx
?
Operation and troubleshooting
Next, you can access the Wiki through a browser. However, you find that editing and saving pages are still slow. Then, after a little Google, you will find an article to solve this problem and quickly solve the problem.
Edit wikiconfig. py and add the following Configuration:
Log_reverse_dns_lookups = False
Restart uwsgi and access Wiki again. The slow problem is solved. (why didn't I find this article before !)