洛阳铲的日志

2010年03月29日

moin wiki农场

Filed under: Python — HackGou @ 10:59

two parts:

  1. step 0-2. all are required
  2. step 3,4,5. web server configration, you only need one of them.

all these installation are done in $HOME , so don’t need any root prerogative

step 0. install/upgrade Moin to 1.9.2 (when upgrade,
recommend to delete the old release, I didn’t do this before , that cause a big problem )

install new moin ignore.

this is the upgrade:

1.8.3->1.9.2

python setup.py install

gavin_kou@shadow:~/downloads/python/moin-1.9.2$ ll /home/gavin_kou/local/lib/python2.5/site-packages/moin-* -d
drwxrwxr-x 6 gavin_kou pg2184500 4096 2009-06-03 02:32 /home/gavin_kou/local/lib/python2.5/site-packages/moin-1.8.3-py2.5.egg
-rw-rw-r– 1 gavin_kou pg2184500 3183 2010-03-10 02:26 /home/gavin_kou/local/lib/python2.5/site-packages/moin-1.9.2-py2.5.egg-info

>>> import MoinMoin.version

>>> MoinMoin.version.release
‘1.9.2’

there are a special directory: ~/local/share/moin/ ,it contains all of wiki initialization data, especially the data and underlay directory and
some files in the server and config directory: server(eg: moin.fcgi is the server of fcgi ENV, and moin.cgi is the cgi script , etc ) and
config( eg: config/wikifarm/farmconfig.py is the wiki farm configuration sample )
gavin_kou@shadow:~/sites/wiki/bin$ ll ~/local/share/moin/
total 16
drwxrwxr-x 5 gavin_kou pg2184500 4096 2010-03-10 02:26 config
drwxrwxr-x 7 gavin_kou pg2184500 4096 2010-03-10 02:26 data
drwxrwxr-x 2 gavin_kou pg2184500 4096 2010-03-10 02:26 server
drwxrwxr-x 3 gavin_kou pg2184500 4096 2010-03-10 02:26 underlay

step 1. design the directory structure, all the setting are based on this stucture. if change the structure ,
DO NOT forget to change the corresponding setting files.

wiki/
├─bin/
│ ├─mointwisted
│ ├─mointwisted.py
│ ├─moin.fcgi
│ ├─moin.cgi
│ └─moin
├─config/
│ ├─farmconfig.py
│ ├─hackgou.py
│ └─hiking.py
├─data/
│ ├─hackgou
│ │ ├─data/
│ │ └─underlay/
│ ├─hiking/
│ │ ├─data/
│ │ └─underlay/
│ └─user/
└─static/
└─htdocs/
and create it by:

mkdir -p wiki/{bin,config,data/hackgou,data/hiking,static}

step1. copy data ( the data and underlay dir)
cp -rp ~/local/share/moin/data ~/local/share/moin/underlay wiki/data/hackgou
cp -rp ~/local/share/moin/data ~/local/share/moin/underlay wiki/data/hiking

step2. copy the ~/local/share/moin/config/wikifarm/farmconfig.py and ~/local/share/moin/config/wikifarm/mywiki.py to your config dir
mywiki.py

cp ~/local/share/moin/config/wikifarm/farmconfig.py wiki/config/
cp ~/local/share/moin/config/wikifarm/mywiki.py wiki/config/hackgou.py
cp ~/local/share/moin/config/wikifarm/mywiki.py wiki/config/hiking.py

and change the farmconfig.py:

wikis = [
(“hiking”, r’^http://hackgou.itbbq.com/wiki/hiking.*$’),
(“hackgou”, r’^http://hackgou.itbbq.com/.*$’),
]

add the following code into the hackgou.py and hiking.py(Both of them):

import os
app_root=os.path.realpath( os.path.join( os.path.dirname( os.path.realpath(__file__) ) ,’..’) )
data_root=os.path.join(app_root, ‘data’)
data_dir = os.path.join(data_root, __name__, ‘data’ )
data_underlay_dir = os.path.join(data_root, __name__, ‘underlay’ )

step3. config the mointwisted ,

add the following lines into mointwisted.py

import sys, os
app_root=os.path.realpath( os.path.join( os.path.dirname( os.path.realpath(__file__) ) ,’..’) )
sys.path.insert(0, os.path.join(app_root, ‘config’) )

step4. config the WSGI

cp ~/local/share/moin/server/moin.wsgi bin/

change the following codes:

app_root=os.path.realpath( os.path.join( os.path.dirname( os.path.realpath(__file__) ) ,’..’) )
sys.path.insert(0, os.path.join(app_root, ‘config’) )

application = make_application(shared=os.path.join(app_root,’static’,’htdocs’))

setp5. config the FCGI, two files: moin.fcgi and .htaccess
cp ~/local/share/moin/server/moin.fcgi and change it.

change the following line

import sys, os

sys.path.insert(0, ‘/home/gavin_kou/local/lib/python2.5/site-packages’)

app_root=os.path.realpath( os.path.join( os.path.dirname( os.path.realpath(__file__) ) ,’..’,’wiki’) ) # based the above directory structure
sys.path.insert(0, os.path.join(app_root, ‘config’) )

from MoinMoin import log
#enable the log, for trouble shooting. the log.conf is the logger config file,
# if enable it , please make sure it’s right
log.load_config( os.path.join( app_root,’config’,’log.conf’) )
logging = log.getLogger(__name__)

from MoinMoin.web.serving import make_application
app = make_application( shared = os.path.join(app_root,’static’,’htdocs’) ) # <– adapt here as above directory structure

fix_script_name = ‘/wiki’

.htaccess add the following lines:

AddHandler fastcgi-script .fcgi
RewriteRule wiki(/?.*) /moin.fcgi/$1 [L]

other advanced setting:

user_dir=os.path.join(app_root, ‘data’, ‘user’)
#session data stored in cache_dir/__session_. so
# if shared the cache_dir, shared the login information(SSO)
cache_dir=os.path.join(app_root,’var’,’cache’)

没有评论 »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress