このサイトのはてなブックマーク数の合計

www を検索 sarabande.info を検索
トップページに戻る

MoinMoin

FedoraUbuntuで採用されている。

MoinMoinをWindowsとmod_pythonで動作させる。MoinMoinはUbuntuの公式サイトに採用されている。

Ubuntu(最新版)

ダウンロードとインストール

Apacheとmod_pythonで動かすことを前提とします。mod_pythonは次のコマンドでインストールします。

sudo apt-get install libapache2-mod-python

MoinMoinの最新パッケージを公式サイトからダウンロードします。

wget http://static.moinmo.in/files/moin-1.6.0.tar.gz
tar xvfz moin-1.6.0.tar.gz
cd moin-1.6.0
sudo python setup.py install

wikiインスタンスの作成

公開するためにwikiインスタンスとしてmywikiディレクトリを作成し、/use/share/moin内にあるdataとunderlayディレクトリ、config、server内にあるスクリプトをコピーします。

cd /usr/share/moin
sudo mkdir mywiki
sudo cp -R data mywiki
sudo cp -R underlay mywiki
sudo cp config/*.py mywiki
sudo cp server/*.py mywiki
sudo cp server/moin.cgi mywiki
sudo chown -R www-data.www-data mywiki

さらにユーザーに閲覧されないようにするには次の設定を追加する。

sudo chmod -R ug+rwX mywiki
sudo chmod -R o-rwx mywiki

Apache

mod_pythonでの設定。

sudo nano /etc/apache2/sites-available/default

で下記のコードを追記。

Alias       /moin_static160/ "/usr/share/moin/htdocs/"
<Directory "/usr/share/moin/htdocs">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /mywiki "/usr/share/moin/mywiki/moin.cgi"
<Location "/usr/share/moin/mywiki/">
   Order deny,allow
   Allow from all
   Options ExecCGI
    SetHandler python-program
    # Add the path of your wiki directory
    PythonPath "['/usr/share/moin/mywiki/'] + sys.path"
    PythonHandler MoinMoin.request::RequestModPy.run
        PythonDebug ON
</Location>

アクセス

Ubuntu(パッケージ版)

TaskselでApacheが導入されている場合を前提とする。

インストール

sudo apt-get install python-moinmoin
sudo apt-get install libapache2-mod-python

ディレクトリとファイルの編集

ディレクトリと権限の設定

cd /usr/share/moin
sudo mkdir mywiki
sudo cp -R data mywiki
sudo cp -R underlay mywiki
sudo cp server/moin.cgi mywiki
sudo chown -R www-data.www-data mywiki

さらにユーザーから閲覧されないように制限する場合は以下の設定を追加する。

sudo chmod -R ug+rwX mywiki
sudo chmod -R o-rwx mywiki

wikiconfig.pyの編集(data_dirの指定)

sudo nano /etc/moin/mywiki.py

data_dir = '/org/moin/mywiki/data'

data_dir = '/usr/share/moin/mywiki/data'

に変更する。

Apache

sudo nano /etc/apache2/sites-available/default

<VirtualHost>内にmod_pythonもしくはCGIのどちらかの設定を追記する。編集が終わったらApacheを再起動する。

sudo /etc/init.d/apache2 restart

mod_python

ScriptAlias /mywiki "/usr/share/moin/mywiki/moin.cgi"
<Location "/usr/share/moin/mywiki/">
   Order deny,allow
   Allow from all
   Options ExecCGI
    SetHandler python-program
    # Add the path of your wiki directory
    PythonPath "['/usr/share/moin/mywiki/'] + sys.path"
    PythonHandler MoinMoin.request::RequestModPy.run
        PythonDebug ON
</Location>

CGI

ScriptAlias /mywiki "/usr/share/moin/mywiki/moin.cgi"
alias /wiki "/usr/share/moin/htdocs"
<Directory /usr/share/moin/htdocs>
Order allow,deny
allow from all
</Directory>

アクセス

http://localhost/mywiki

参考

Windows

インストール

http://moinmo.in/MoinMoinDownload からmoin-1.5.8.tar.gzをダウンロードして解凍。

cd moin-1.5.8
python setup.py install

XREAにインストールする場合。easy_installの導入を前提とする

wget http://static.moinmo.in/files/moin-1.6.0.tar.gz
tar xzvf moin-1.6.0.tar.gz
cd moin-1.6.0
python setup.py install

セットアップ

cd C:\
md moin\mywiki moin\mywiki\data moin\mywiki\underlay
cd C:\Python\share\moin
xcopy data C:\moin\mywiki\data /E
xcopy underlay C:\moin\mywiki\underlay /E
copy  config*.* C:\moin\mywiki*.*
copy  server*.* C:\moin\mywiki*.*

mod_python

http.conf

LoadModule python_module modules/mod_python.so
Alias       /moin_static160/ "C:/Python/share/moin/htdocs/"
#ScriptAlias /mywiki          "C:/Moin/mywiki/moin.cgi"

<Directory "C:/Moin/mywiki">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /mywiki "C:\moin\mywiki\moin.cgi"
<Location "C:\moin\mywiki\">
   Order deny,allow
   Allow from all
   Options ExecCGI
    SetHandler python-program
    # Add the path of your wiki directory
    PythonPath "['C:\moin\mywiki\'] + sys.path"
    PythonHandler MoinMoin.request::RequestModPy.run
        PythonDebug ON
</Location>

アクセス

http://localhost/mywiki/

mod_wsgi

http.conf

Alias       /moin_static160/ "C:/Python/share/moin/htdocs/"
<Directory "C:/Python/share/moin/htdocs/">
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias /mywiki "C:/moin/mywiki/moin.wsgi"

<Directory "C:/moin/mywiki">
Order deny,allow
Allow from all
</Directory>
</pre>

moin.wsgi(C:/moin/mywiki/ コメント部分は省略)

 
import sys
sys.path.insert(0, 'C:/Python/Lib/site-packages')
sys.path.insert(0, 'C:/moin/mywiki')
 
import logging
 
from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
 
class Config(WsgiConfig):
    logPath = 'moin.log' # adapt this to your needs!
    #loglevel_file = logging.INFO # adapt if you don't like the default
 
config = Config() # MUST create an instance to init logging!
 
application = moinmoinApp
 

参考

CGI

1.6.0で動作確認。

moin.cgi

 
#!C:/Python/python.exe
# -*- coding: utf-8 -*-
 

wikiconfig.py(C:\moin\mywiki)

 
# -*- coding: utf-8 -*-
sitename = u'Untitled Wiki'
logo_string = u'<img src="/moin_static160/common/moinmoin.png"    alt="MoinMoin Logo">'
page_front_page = u"FrontPage"
data_dir = 'C:\moin\mywiki\data'
data_underlay_dir = 'C:\moin\mywiki\underlay'
language_default = 'ja'
 

http.conf

Alias       /moin_static160/ "C:/Python/share/moin/htdocs/"
ScriptAlias /mywiki          "C:/Moin/mywiki/moin.cgi"

<Directory "C:/Moin/mywiki">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

<Directory "C:/Python/share/moin/htdocs">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

サイトの設定

ユーザの作成

http://localhost/mywiki/UserPreferences

スーパーユーザを追加するには

 
superuser = [u"スーパーユーザ名", ]
 
acl_rights_before = u"ユーザ名:read,write,delete,revert,admin"
 

匿名ユーザーはreadのみにするには

 
acl_rights_default = u"All:read"
 

参考

docbook対応

http://pyxml.sourceforge.net/

cd PyXML-0.8.4
python setup.py build -f -c mingw32 install -f

拡張

Pygments

Pygmentsによるコードのハイライト。

easy_install pygments

でインストールできるが、プラグインが同伴されていないので別にsouceforgeよりパッケージを入手する。まずmoin-parser.py(Pygments-x.x.x\external)をcode.pyにリネームしてC:\moin\mywiki\data\plugin\parserにコピーする。インラインのCSSを使えるようにするために次の行をTrueにする。

 
# Set to True if you want inline CSS styles instead of classes
INLINESTYLES = True
 

そして

wikiconfig.py(C:\moin\mywiki)でCSSを指定する。

 
stylesheets = [('screen', '/moin_static160/modern/css/highlight.css')]
 

この場合。highlight.cssはC:\Python\share\moin\htdocs\modern\cssに設置する。highlight.cssは例えば次のコードスニペットをスクリプトに保存して コマンドラインから実行することで生成される。

 
from pygments.formatters import HtmlFormatter
 
f = open('highlight.css', 'w')
f.write(HtmlFormatter().get_style_defs('.highlight'))
f.close()
 

コードの表示を試すには例えば次のコードスニペットを貼ってみる。PHPの場合は <?phpが無いとハイライトされないことに注意する。

 
{{{
#!code python
from pygments.formatters import HtmlFormatter
 
f = open('highlight.css', 'w')
f.write(HtmlFormatter().get_style_defs('.highlight'))
f.close()
}}}
 
トップページに戻る