Date Tags wiki

环境

  • Ubuntu: 10.04.04
  • Python: 2.7.3
  • Ngnix: 1.2.6
  • virtualenv: 1.8.4

首先我们安装的用户必须在admin组

moinmoin运行在virtualenv 环境下面,所以先创建virtualenv

sudo mkdir /opt/moinmoin
chown root:admin /opt/moinmoin
cd /opt/moinmoin
virtualenv env
pip install uwsgi

然后在moin会在/opt/moin/env/share/moin中会创建以下文件夹

|-  config
|-  data
|-  server
|-  underlay

运行一下命令

cd /opt/moin/env/share/moin
cp config/wikiconfig.py ./
cp server/moin.wsgi ./

编辑/opt/moin/env/share/moin

application = make_application(shared=False)

编辑/opt/moin/env/share/moin/wikiconfig.py

sitename = u'Knowledge Base'
page_front_page = u'home'
superuser = [u'admin', ]
acl_rights_before = u'admin:read,write,delete,revert,admin'
acl_rights_default = u'TrustedGroup:read,write,delete,revert All:none'
navi_bar = [
        # If you want to show your page_front_page here:
        #u'%(page_front_page)s',
        u'home',
        u'RecentChanges',
        u'FindPage',
        u'HelpContents',
    ]
#theme_default = 'modern'
theme_default = 'fixedleft'
theme_force = True
show_timings = True

安装themes

cd /tmp
wget "http://moinmo.in/ThemeMarket/FixedLeft?action=AttachFile&do=get&target=FixedLeft193.zip" -O FixedLeft.zip
unzip FixedLeft.zip
cd /tmp/FixedLeft193
cp fixedleft.py /opt/moin/env/share/moin/data/plugin/theme/
cp -r js /opt/moin/env/lib/python2.7/site-packages/MoinMoin/web/static/htdocs/fixedleft/
cp -r css /opt/moin/env/lib/python2.7/site-packages/MoinMoin/web/static/htdocs/fixedleft/
cp -r img /opt/moin/env/lib/python2.7/site-packages/MoinMoin/web/static/htdocs/fixedleft/

编辑/opt/moin/moin_nginx.conf

server {
    listen          80;
    server_name     wiki.folowing.com;
    access_log      /var/log/nginx/moin/access.log;

    location /moin_static195 {
        alias /opt/moin/env/lib/python2.7/site-packages/MoinMoin/web/static/htdocs;
        add_header Cache-Control public;
        expires 1M;
    }

    location / {
        include     uwsgi_params;
        uwsgi_pass  unix:/tmp/moin.sock;
        uwsgi_modifier1 30;
    }
}

编辑/opt/moin/uwsgi.ini

[uwsgi]
socket = /tmp/moin.sock
virtualenv = /opt/moin/env
daemonize = /var/log/nginx/moin/uwsgi.log
chdir = /opt/moin/env/share/moin

master = true
processes = 2

enable-threads=true

wsgi-file=/opt/moin/env/share/moin/moin.wsgi

编辑/etc/init/moin.conf

escription "moin uwsgi instance"
start on runlevel [2345]
stop on runlevel [!2345]

respawn
expect daemon

instance moin
exec /opt/moin/env/bin/uwsgi --die-on-term --ini /opt/moin/uwsgi.ini --pidfile /var/run/moin.pid

post-stop script
    rm -f /var/run/moin.pid
end script

最后start service

start moin

参考:

  • http://moinmo.in/HowTo/UbuntuQuick
  • http://projects.unbit.it/uwsgi/wiki/Upstart
  • http://uwsgi-docs.readthedocs.org/en/latest/ThingsToKnow.html
  • http://manpages.ubuntu.com/manpages/natty/en/man5/init.5.html
  • http://stackoverflow.com/questions/9972023/ubuntu-upstart-and-creating-a-pid-for-monitoring