本文假设nginx,uwsgi都已经安装完毕!
1. 首先安装flup,不多说,easy_install flup
2. 下载moinmoin,我用的是1.9.5,解压到/data下,并做符号链接ln moin-1.9.5 moin -s
3. cd /data/moin/wiki;
4. cp server/moin.wsgi .
5. cp config/wikiconfig.py .
6. 修改moin.wsgi, 找到a2,加入:
sys.path.insert(0, '/data/moin/wiki')
7. 启动uwsgi:
uwsgi -s 127.0.0.1:9003 -M -t 30 -A 4 -p 2 -d /var/log/moin-uwsgi.log --pythonpath /data/moin --wsgi-file /data/moin/wiki/moin.wsgi
8. 修改nginx配置,加入一下虚拟主机设置:
server {
listen 8080;
# Replace this with your domain name
server_name wiki.xxxx.com;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9003;
}
}
9. 重新启动nginx,加载新的配置;
10. DONE !如果没有任何问题提示,现在可以访问ip:8080来打开wiki页面了!
Update: MoinMoin官方wiki上说明的External Cookie(http://moinmo.in/HelpOnAuthentication/ExternalCookie)验证方式verifySessionPlus有一个潜在的BUG:
def verifySessionPlus(sidHash,timeout=3600*4): # +++ to use this, uncomment a procedure call below in ExternalCookie
"""Return True if sidHash value exists (meaning user is currently logged on), false otherwise.
This version of verifySession deletes entries inactive for more than 4 hours and
updates the tStamp field with each moin transaction. If performance is
important, find another way to delete inactive sessions.
"""
db = MySQLdb.connect(db='mydb',user='myuserid',passwd='mypw') # +++ user ID needs write access
c = db.cursor()
q = 'delete from ActiveSession where tStamp<"%s"' % int(time.time() - timeout) # delete inactive entries
result = c.execute(q)
q = 'update ActiveSession set tStamp=%s where sidHash="%s"' % (int(time.time()),sidHash)
result = c.execute(q)
c.close()
if result == 1:
return True
return False
其中,为了判断某用户是否具有一个合法的session的时候,使用的是一个update语句的返回值,在实际使用中发现,如果快速刷新页面,会在用户拥有合法session的前提下也会判断为无效用户。具体的修正方法是,在判断之前做一次select操作,用select的操作替代update操作:
def verifySessionPlus(sidHash,timeout=3600*4): # +++ to use this, uncomment a procedure call below in ExternalCookie
"""Return True if sidHash value exists (meaning user is currently logged on), false otherwise.
This version of verifySession deletes entries inactive for more than 4 hours and
updates the tStamp field with each moin transaction. If performance is
important, find another way to delete inactive sessions.
"""
db = MySQLdb.connect(db=DATABASE['NAME'],user=DATABASE['USER'],passwd=DATABASE['PASSWORD']) # +++ user ID needs write access
c = db.cursor()
q = 'delete from ActiveSession where tStamp<"%s"' % int(time.time() - timeout) # delete inactive entries
result = c.execute(q)
q = 'update ActiveSession set tStamp=%s where sidHash="%s"' % (int(time.time()),sidHash)
result = c.execute(q)
q = 'select * from ActiveSession where sidHash="%s"' % sidHash
result = c.execute(q)
c.close()
if result >= 1:
return True
return False