这个HTML页面包含基本的安装文档,其英文文档保留在 http://moinmaster.wikiwikiweb.de/MoinMoin/InstallDocs. 它包含有WIKI的安装、运行的所有必要的信息,甚至不必在线就可看到。假如你永久的连接到Internet,那么你可以在安装页面的帮助目录看到这些最新的文档。

遵照这个页面的安装步骤执行之后,你的WIKI就能正常运行并且能浏览在线文档的其他部分。

如何安装 MoinMoin Wiki

这个页面描述了MoinMoin的安装步骤。在下一节,将有具体环境中的安装简介,那会帮助你理解怎样把这些指令应用到各个不同的环境中去。假如你已经有了一个正在运行的Wiki想升级,请看 HelpOnUpdating。

一个MoinMoin的安装过程可以分为以下几个基本的步骤:

不同网络服务器和操作系统下的安装步骤

以下链接向你演示了具体的安装过程,包括使用的命令及其作用。在进行实际安装之前,你必须阅读上面关于安装的一般信息

Linux:

Long-Running-Process Setup:

Mac OS X:

Windows:

如何在你的系统上实现MoinMoin的基本安装

目录

在你把MoinMoin整合到网络环境之前,必须使用Python标准的distutils机制(setup.py')安装MoinMoin源代码和数据文件。本页面向你解释其一般实现步骤。对于distutils安装的详细过程,请参考你的Python文档 Installing Python Modules

在Windows下和Linux下的安装过程是类似的,简单起见,我们在此文档中以"Linux"为例。

(!) 我们使用类似> command arguments这样的文字来表示你应该在命令行(或者shell, 终端等)下输入的命令。 在我们的例子中,是提示符,你不需要输入它,需要输入的是跟在它后面的文字。不是以开头的那些行表示输入命令后得到的结果。请仔细阅读。

检查Python是否正常工作

MoinMoin需要Python才能运行,所以第一步就是要检查是否安装了可以使用的Python版本以及安装是否正确。如果有问题,你必须先修复它。

在MoinMoin归档中的"CHANGES"文件中给出了需要的Python版本。Python2.3是MoinMoin 1.5所需要的最低版本,但是我们建议你使用最新的Python版本。

你可以在 http://www.python.org/download/下载Python。

如果你非常肯定已经安装了可接受的Python版本,但是下面的命令却不能正常工作,那么可能是因为你的Python文件不在搜索路径中。关于正确设置所索路径,已经超出了本文档的范围了;请在你喜欢的Python,Linux,或者Window讨论区提问。

如果你可以使用shell,检查Python的状态就非常简单了。只要输入下面的命令,然后看看结果就可以:

> python -V
Python 2.3.4

如果你不能使用shell,可以使者使用下面这个pythontest.cgi脚本(假设你使用的是Linux类型的网络服务器)。将此脚本上载到你的cgi-bin目录,使用chmod a+rx pythontest.cgi(或者在你的FTP程序中类似的命令)将此脚本变为可执行文件,然后使用网络浏览器调用它。

echo Content-Type: text/plain
echo
echo "Your web server is running as:"
id
echo "CGI scripts work"
echo "Now we try to invoke Python interpreters and get their versions:"
python -V 2>&1
python2.3 -V 2>&1
python2.4 -V 2>&1
echo "Finished."

如果没有显示"CGI scripts work",那么CGI脚本没有正常工作。如果没有显示一个或者多个Python版本号,那么Python没有正确安装。这两种情况下,你必须与服务器的系统管理员联系以便修正这些问题。

在你已经完成了这里说明的../BasicInstallation,请一定要读一读 ../ApacheOnLinuxFtp

下载MoinMoin

要下载发行包,请到 下载区 获得最近的归档。

下一步是解压发行包(如果你现在读的这些文字在硬盘上,说明你已经上完成了此项工作)。如果你在网络上读到这些文字,发行包是一个 带有版本号的.tar.gz压缩包,你可以按照下面的方法来解压。

  • 在Window下
    • 你可以使用最近版本的解压程序,比如WinZip,WinRar,and WinAce,他们可以处理.tar.gz类型的压缩包。

    • 在命令行下,可以使用GNU gzip and GNU tar 的Window版本。

  • 在Linux下
    • 你可以使用喜欢的文件管理器 -- 它应该可以解压它们。
    • 在任意shell提示符下,你可以使用tar命令。

发行包通常会解压到一个名字为moin-<verion>的目录下,比如moin-1.5

这个例子演示你如何(使用GNU tar)解压发行包,并进入MoinMoin文件所在的目录:

> tar xzf moin-1.5.0.tar.gz
> cd moin-1.5.0

安装 MoinMoin

你可以将MoinMoin安装到以下任意一个目录:

  • 系统目录(如果你有权限这样做 -- 在Linux上你必须是根用户)
  • 某一指定位置,比如你的home目录(Linux)或者C:\moin (Windows)。

安装到系统目录比较容易,所以尽量选择这种方式。

/!\ 如果你安装了多个版本的Python,请使用相同版本的Python来安装和运行wiki。通常,最新版的Python会有最好的结果。

如果你在安装中使用setup.py有问题,请试一下这个命令:

> python -v setup.py --quiet install --record=install.log

附加的-v标志会给你提供安装过程中每一步的详细信息。

/!\ 在Linux上,如果得到类似Invalid Python installation: cannot find /usr/lib/Python2.x/config/Makefile的错误,可能是因为没有安装Python模块distutils,它通常是Python开发库 (python-dev)的一部分。一些Linux发行版可能缺省状态下没有安装它。例如,在Mandrake上,你要安装python-devel 包, 在Debian上它的名字是python-dev.

安装到系统默认位置

> python setup.py --quiet install --record=install.log

这个命令把MoinMoin安装系统默认位置(一般是Python目录,例如在Linux下,在/usr/lib/usr/share里)。在install.log文件里可以看到安装的你容以及安装位置。

  • Mac OS X 注意:使用下面的命令:
    python setup.py install --install-data='/usr/local'

它把共享文件安装到'/usr/local/share/moin',取代不方便的系统目录。

安装到home目录或者其他指定位置

Linux例子,安装到home目录:

> python setup.py --quiet install --prefix=$HOME --record=install.log

Windows例子,安装到C:\moin目录:

> python setup.py --quiet install --prefix="C:\moin" --record=install.log

所有的MoinMoin文件将被安装到这些目录中,install.log记录着那些文件被安装以及它们的安装位置。

注意: 你可能会看到下面的警告:

  • warning: install: modules installed to 'C:\moin\', which
    is not in Python's module search path (sys.path) -- you'll
    have to change the search path yourself

警告中给出了信息,你需要把你的安装目录增加到Python的搜索路径中,否则它没法找到MoinMoin代码。

比如,如果你使用网络服务器和标准CGI,那么编辑moin.cgi,把你的安装目录增加到Python路径中,就像这样:

import sys
sys.path.insert(0, 'C:/moin')

安装测试

最后一步,如果你能使用shell或者命令行,可以检查安装是否正确可以运行。运行Python并输入import MoinMoin。对此命令应该没有任何东西显示。例如:

> python
Python 2.3.4 (#1, May 29 2004, 17:05:23)
[GCC 3.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MoinMoin
>>>

如果你得到这样的结果:

>>> import MoinMoin
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named MoinMoin
>>>

那么你不得不调整你的安装了。试着像上面所说的那样修改sys.path

安装了什么

现在,你有一个随时可以运行的MoinMoin了。祝贺你!在继续配置它之前,看一看已经被安装的文件以及它们所在的目录。

/!\ 这一步很重要,你应该了解MoinMoin安装中使用的不同目录,所以请仔细阅读。

在下面的描述中,PREFIX是随setup.py一起使用的选项,或者如果你没有使用--prefix选项时的默认位置。(一般Linux上的默认位置 是/usr and /usr/localX.Y是Python的版本。一般是2.3或者2.4

看一看install.log,找到下面这些重要的位置:

  • MoinMoin 目录,通常是PREFIX/lib/pythonX.Y/site-packages/MoinMoin - 这是 MoinMoin 源代码的位置。

  • share 目录,通常是PREFIX/share/moin - 这是 模板的位置。

    • data 目录 (wiki pages, users, etc.) - 只有MoinMoin能够访问它。

    • underlay 目录 (wiki pages) - 只有MoinMoin能够访问它。

    • htdocs 目录以及html支持文件 (不同主题相应的图片等) - 网络服务器需要访问它。

    • server - MoinMoin 启动文件范例 (例如用于CGI的moin.cgi , 以及其他启动方法对应的启动文件)

    • config - MoinMoin 配置文件范例 (例如wikiconfig.py)

  • bin - 此目录下有一些脚本,可以帮你使用 MoinMoin shell命令。

share目录我们谈到模板, 因为你通常不会使用那些目录下的文件,而是当需要时把它们拷贝到其他地方。这样,你可以建立多个wiki,而且容易升级到新MoinMoin版本。

此页的英文版本:HelpOnInstalling/BasicInstallation


After you have downloaded and installed MoinMoin, you will want to "have a wiki". As explained at the bottom of ../BasicInstallation, you have to copy several directories and files. This way, you can have as many wikis as you want, and you can easily upgrade MoinMoin: only the original files will be overwritten, not your copies.

Every time you copy those files (and modify the configuration of your server accordingly), you create what is called a wiki instance. Each wiki instance is independent from the others, with a different configuration, different pages, different users, etc.

Some of the steps you need to take depend on which web server and which operating system you use. They are described on dedicated pages, which you should read (at least the beginning) before reading this one. Some other steps are common to every webserver and operating system (copying files around, setting permissions), and this is what is described here.

Linux users can download and use createinstance.sh (a bash script that creates the instance) instead of doing all steps manually:

  1. If anything is unclear, just read the sections below for more hints.
  2. Have a look into the script before running it, if all settings are correct for your setup:
    • If your system does not have /bin/bash. try /bin/sh (or whatever your shell is called) - see the first line in the script.

    • USER and GROUP should be the user and group used by your web-server for running moin.
    • SHARE is where the shared files were copied to, see install.log from the setup.py install step

  3. Make the script executable (e.g. chmod +x createinstance.sh).

  4. The script takes a single parameter: the location of your wiki instance (see "Choose a location" section below):
    # ./createinstance.sh /path/to/mywiki
  5. Now continue in section "Tune configuration"

Read this first

Security warnings

/!\ Warning: make sure that your data directory and your configuration files are not accessible through your web server. Do not put your wiki directory in public_html, Sites or any other directory your web server can access. The web server only needs to access the file in the htdocs directory and the moin.cgi script! (Or whatever script your server uses to start MoinMoin.)

/!\ Warning: make sure that the data directory and its subdirectories are not readable and not writeable by users other than the web server user. If you need to give worldwide read-write permissions to get it working, be aware that you are doing a very unsecure setup, that can be compromised by any other user or program on your computer.

Note to Windows users

All the commands below are Linux commands. The text descriptions that introduce them should be enough to help you understand what you need to do. Use the Windows Explorer, or the appropriate text-mode commands.

Choose a wiki name

Choose a unique name for the new wiki instance you want to create. It should be a short word, something that reflects what you intend to use the wiki for, like the name of your organization, of your team, of the project you are working on, etc.

The name "mywiki" is used as an example in the various commands below.

Choose a location

Choose a directory on your disk, it will contain all the files needed for your wiki instance. At the beginning, your wiki instance will use approximately 10 MB of disk space. Then of course, it will grow depending on the way your wiki is used. A personal wiki, even with many pages, might only use 30 MB or 40 MB of disk space. A popular wiki, or a wiki with many files attached to the pages, might use much more, of course.

If you are the administrator (or root) of the server, you can use anything you like or that makes sense to you, for example /usr/local/var/moin, /mnt/wikis, etc.

If you are a simple user, you will probably only be allowed to write in your personal, "home" directory. Choose a subdirectory that makes sense to you, for example the share/moin subdirectory.

Collect some important information

This is where the instructions differ according to the web server and operating system you use, and whether you are the administrator or a simple user. See the appropriate pages for your web server and operating system combination.

On Linux, the export command will be used to remember the collected information. Windows users should write it down carefully (maybe cutting-and-pasting in a Notepad window), or store it in environment variables if they use the command prompt.

  • PREFIX is the prefix you used during the ../BasicInstallation

  • SHARE is the name of the share directory, as discussed at the bottom of ../BasicInstallation

  • WIKILOCATION is the name of the directory that will contain your wiki instance

  • INSTANCE is the directory containing the wiki instance. It cannot be an existing directory readable through Apache, otherwise it will fail.

If you are an administrator, you also need to collect the following:

  • USER is the user name of the web server

  • GROUP is the name of the group to which the web server belongs

Now, Linux folks, let's store these settings in memory:

> export PREFIX=/usr                # this might be something else
> export SHARE=$PREFIX/share/moin   # this should be correct for most people
> export WIKILOCATION=$SHARE        # this is just an example
> export INSTANCE=mywiki            # this is just an example

Administrators also need the following two lines:

> export USER=www-data              # this is just an example
> export GROUP=www-data             # this is just an example

Copy the files

To create your new instance, you first need to create a directory named like your instance, inside the WIKILOCATION. Then you need to copy the data and underlay directories from your SHARE directory into your instance directory. Finally, you need to copy the wikiconfig.py file from the config directory into the instance directory.

Linux folks need to just type these commands:

> cd $WIKILOCATION
> mkdir $INSTANCE                   # make a directory for this instance
> cp -R $SHARE/data $INSTANCE       # copy template data directory
> cp -R $SHARE/underlay $INSTANCE   # copy underlay data directory
> cp $SHARE/config/wikiconfig.py $INSTANCE   # copy wiki configuration sample file
  • /!\ Note that you just need to keep one underlay directory on your system if you are running multiple wikis (e.g. in a farm.)

Set permissions

Administrators

Administrators need to restrict the permissions of the files, so that only the web server (and the administrator of course) can read and write them. For maximum security, no other user on the machine should be able to read or write anything in the wiki instance directory. Don't forget that this directory contains sensitive information, notably the (encrypted) passwords of the wiki users.

On Linux, the following commands should be enough:

> chown -R $USER.$GROUP $INSTANCE   # check that USER and GROUP are correct
> chmod -R ug+rwX $INSTANCE         # USER.GROUP may read and write
> chmod -R o-rwx $INSTANCE          # everybody else is rejected

Normal users

Normal users, on the contrary, need to broaden the permissions of the files, so that the web server can read and write them. On recent Windows versions, and on some versions of Linux and other systems, access control lists can be used to that effect. They are, however, powerful and complicated, much beyond the scope of this document. Ask a knowledgeable person about them.

Without them, normal users have to allow everybody to access the instance directory. This is the only way the web server can enter it and do its work. This is, of course, VERY INSECURE, since any other user and program on the server can read the directory. You should not use such a setup for a wiki open to the public.

On Linux, the following commands will open the instance directory to the whole world:

> chmod -R a+rwX $INSTANCE

Note:

  • it is also possible to put the web server and the normal user in the same group, and then only open the instance directory to the members of that group. This is a bit more secure (depending on who else is in the group), but you need the cooperation of the server administrator; he is the one setting up groups.

  • the best other possibility is that the server administrator sets up suexec to execute CGI scripts in user directories under the user id of that user. You don't need to give world permissions that way, so it is a quite secure setup, but you also need cooperation of the administrator.

Tune configuration

Now, you need to tune the configuration of your web server and of your wiki instance. Look at the appropriate help page for your web server, then come back here to tune the settings of your wiki instance.

Edit wikiconfig.py. The default settings should work fine in most cases, but there are some things that you will probably want to change, like the name and logo of your wiki! :) Read the comments inside wikiconfig.py, they will guide you through this process.

/!\ Warning: don't forget to restart your web server in order to apply changes in wikiconfig.py

HelpOnConfiguration contains all the details about all the options, in case the comments in wikiconfig.py are not enough.


使用 Apache 和 Linux

本页面记述在 Linux 上使用 Apache 服务器安装 MoinMoin 维基例程的步骤。 在此之前,你应该完成../基本安装。在其他类Unix操作系统上,比如FreeBSD,安装步骤是类似的。

有两种可能情况。你可能是服务器的管理员(root),可以安装和修改计算机上的每一个文件,特别是可以修改 Apache 的配置文件。你也可能只是普通用户,只能对自己 home 目录下的文件进行写操作,不能修改Apache的配置文件。下面讨论这两种情况。

目录

管理员 (root)

大多数 GNU/Linux 发行版事先安装好了 Apache。但是,Apache文件的具体位置可能有所不同。你应该查阅发行版手册,或者在适当的讨论区上寻求答案。在接下来的章节中,我们假设一个文件系统的(几乎标准的)布局如下:

  • /etc/httpd/httpd.conf - Apache 主配置文件

  • /var/log/httpd/error_log - 包含 Apache 错误信息的日志文件

有些发行版使用 apache 代替 httpd 作为目录名,其他的发行版也可能使用奇怪的设置。

创建维基例程

创建维基例程的操作包括拷贝文件和设置适当权限。在继续操作之前,你应该明确Apache服务器以什么用户和组运行。最简单的方法是运行下面的命令:

> egrep "^User|^Group" /etc/httpd/httpd.conf
User wwwrun
Group nogroup

上面显示了一个典型的结果: "wwwrun.nogroup"。其他常见结果包括 "nobody.nogroup", "apache.apache" 和 "www-data.www-data"。你当然可以使用自己的方式来设置。重要的你应该知道到底是哪一个结果,因为你还需要利用它们来设置文件权限。

这个信息清楚之后,请阅读../创建维基例程,然后按照下面的步骤来做。

安装 moin.cgi

需要拷贝 moin.cgi。它用于连接 MoinMoin 和 Apache。你可以把这个脚本放在任何位置 (MoinMoin文件的路径可以任意配置,以适合文件系统的布局)。但是为了简单和安全起见,我们建议你按照下面的例子进行操作,除非你认为自己可以做的更好。

我们将在例程目录下创建一个 cgi-bin 子目录。使用../创建维基例程中定义的环境变量,运行下面的命令:

> cd $WIKILOCATION/$INSTANCE
> mkdir cgi-bin
> cp $SHARE/server/moin.cgi cgi-bin
> chown -R $USER.$GROUP cgi-bin
> chmod -R ug+rx cgi-bin
> chmod -R o-rwx cgi-bin

配置 moin.cgi

moin.cgi 运行时,它导入 MoinMoin 模块,而 MoinMoin 模块接着导入其他模块和配置文件. 虽然 MoinMoin 模块在正确配置 (如../基本安装所述) 的系统中总可以被找到,但是配置文件不一定会存在。编辑 moin.cgi 脚本来纠正它。 在文件顶端添加这些文字:

import sys
sys.path.insert(0, '..')

你也可以使用包含wikiconfig.py文件的目录的绝对路径来代替 '..'.

配置 Apache

现在所有文件都到位了,并且正确的设定了权限,我们需要配置 Apache。但是,由于不同的发行版中其默认的 Apache 配置各不相同,而且管理员经常会对配置文件作出不同的添加和更改,我们无法给出涵盖所有情况的精确建议。相反,我们首先大致的描述有哪些要做的操作,然后给出一些特定的配置,你可以把它们添加到Apache配置文件的适当位置。

你的Apache安装后应该是这样的:

  • 访问例程目录是被拒绝的 (安全的 Apache 配置应该拒绝对对整个服务器的的访问,而仅仅开放一些特定的目录)。
  • 设置了一个 alias,将把对 /wiki/的访问 (in the URL) 重定向到 htdocs 目录(如../基本安装所述,在 share 目录下)。

  • 设置了一个 script alias,将把任何你希望的访问 (我们建议你使用例程的名字,比如/mywiki) 重定向到你刚刚拷贝的CGI脚本。

下面的命令会在你的 Apache 配置文件底部增加两行。它们只涵盖上述的最后两条。你应该自己检查第一条 (Linux发行版中的变化实在是多种多样)。注意你可能需要将这两行拷贝到配置文件中适当的位置 -- 也许在其他类似的某些行配置的附近。

> echo "" >>/etc/httpd/httpd.conf
> echo "Alias /wiki/ \"$SHARE/htdocs/\"" >>/etc/httpd/httpd.conf
> echo "ScriptAlias /mywiki \"$WIKILOCATION/$INSTANCE/cgi-bin/moin.cgi\"" >>/etc/httpd/httpd.conf

你只需要定义 htdocs 的 alias 一次。你需要对不同维基例程定义不同的 script alias。

配置 MoinMoin

最后,检查例程目录下的wikiconfig.py文件是否包含 htdocs url_prefix,例程的 data 目录,underlay 目录的正确路径。 你可以使用相对路径,但是注意它们应该是相对于GCI脚本而不是相对于配置文件的!你也可以使用绝对路径,这样不会出错。

如果你一直听从我们之前的建议,那么这个配置文件中的设置应该如下所示:

    data_dir = '../data/'
    data_underlay_dir = '../underlay/'
    url_prefix = '/wiki'

还有一些其他设置可以更改,详细内容请看../创建维基例程

测试维基

现在一切都应该工作正常了。现在应该 重新启动 Apache 服务器 (通常使用 "/etc/init.d/apache restart", 有时候是 "apachectl restart") ,然后操作如下:

  • 运行 MoinMoin CGI Diagnosis: 连接 "http://127.0.0.1/mywiki?action=test" (或者是你在 Apache 配置文件中设置的名字和端口)。确认显示了正确的信息。检查 Checking directories... 下面列出的目录状态都是 OK.

  • 使用 "http://127.0.0.1/mywiki/" 访问你的新维基(或者是你在 Apache 配置文件中设置的名字和端口)。应该可以看到 FrontPage.

  • 如果上面操作正常,试着编辑并保存。
  • 如果上面操作正常,查看你的更改是否在最新改动页面上体现出来了。

  • 如果上面操作正常,祝贺你,你的维基可以正常运行了!

如果有错误发生,请看页面底部的问题解答

Apache 技巧

高级配置和其他技巧,请看 帮助-其他

普通用户 (安装在 home 目录)

在多人共享的计算机上,普通用户没有管理员权限,不能修改 httpd.conf 文件,不能将文件拷贝到系统所属的 cgi-binhtdocs 目录。在这种情况下,无法在 Apache 中设置 UserDir 使得每个用户都可以在 home 目录下建立网站。如果管理员却是如此设置服务器,那么所有以 "/~username" 开始的 URLs 都会被重定向到用户的 home 目录下的子目录,用户对这些目录有写权限,可以安装MoinMoin.

下面,我们以用户 "mm" 为例。当然,下面所有的 "mm" 都可以替换成你自己的用户名。

确认 /~username 工作正常

只有管理员 (root) 允许的情况下,home 目录安装方式才可以正常工作。所以,第一步是检查其是否可以正常工作。一般来说,Apache 会被配置成使用 home 目录中的 public_html 子目录作为网站的根目录。所以,第一步是检查这个目录是否存在。

> ls -ld ~/public_html
drwxr-xr-x   2 mm       users        4096 Nov 30 00:29 public_html

如果目录不存在,就新建一个,确保它可以被网络服务器读取和访问。

> mkdir public_html
> chmod a+rx public_html
> ls -ld ~/public_html
drwxr-xr-x   2 mm       users        4096 Nov 30 00:35 public_html

现在检查 "/~mm" URL 是否工作正常:

> lynx -error_file=/dev/stderr -dump http://localhost/~mm/ >/dev/null
URL=http://localhost/~mm/ (GET)
STATUS=HTTP/1.1 200 OK

如果是 "200 OK" 的结果,那表明它工作正常,你可以进行下一步检查了。如果是 "403 Forbidden" 或者是 "404 Not Found",那么可能是目录有些问题,或者可能是管理员禁止了这些功能。

  • 检查home (~) 和 public_html目录的权限,它们的权限应该分别是 "--x" 和 "r-x"。

  • 也有可能是管理员设置了其他的个人网站的目录名字。默认值是 "public_html",但也可能使用其它值。你必须向管理员(root)询问详细信息。

  • 如果个人网站功能被禁用了,也许你可以让管理员打开这个功能?

如果可以读取该目录下的文件,你还需要检查在这个目录下是否能够执行CGI脚本。使用下面的命令在适当的位置新建一个简单的CGI脚本:

> mkdir -p ~/public_html/cgi-bin
> cat > ~/public_html/cgi-bin/test.cgi
#!/bin/sh
echo Content-Type: text/plain
echo
echo "CGI scripts work"
<CTRL-D>
> chmod a+rx ~/public_html/cgi-bin/test.cgi
> lynx -dump http://localhost/~jh/cgi-bin/test.cgi
CGI scripts work

如果结果不是"CGI scripts work", 那说明又有问题了。检查目录的权限,试试其他的名字。最糟糕的情况是你没有权限运行CGI脚本。你必须让管理员(root)给你设置权限。

如果有了权限,你就可以在 public_html 目录下创建维基例程了。 :)

创建维基例程

创建维基例程的操作包括拷贝文件和设置适当权限。请阅读 ../创建维基例程,按照其所描述的步骤进行操作。

安装 htdocs 文件

网络服务器需要访问这些文件,所以我们要把它们拷贝到"public_html"目录。

> cd ~/public_html
> cp -R ~/share/moin/htdocs wiki
> chmod -R a+rX wiki

安装 moin.cgi

需要拷贝 moin.cgi。它用于连接 MoinMoin 和 Apache。你要把它放在可以运行CGI脚本的目录。下面是默认的情况:

> cd ~/public_html
> mkdir cgi-bin
> cp $SHARE/server/moin.cgi cgi-bin
> chmod -R a+rx cgi-bin

配置 moin.cgi

moin.cgi 运行时,它导入 MoinMoin 模块,而 MoinMoin 模块接着导入其他模块和配置文件. 由于所有文件都安装到了home目录,所以它们可能都无法找到。编辑 moin.cgi 脚本来纠正它。 在文件顶端添加这些文字:

When moin.cgi is launched, it imports a MoinMoin module (that in turn imports other modules and the configuration file). Since everything has been installed in your home directory, it is likely none of these will be found. Edit the moin.cgi script to correct that. Add these lines near the top of the file:

import sys
sys.path.insert(0, '/home/mm/lib/python2.3')
sys.path.insert(0, '/home/mm/lib/python2.3/site-packages')
sys.path.insert(0, '/home/mm/share/moin/mywiki')

当然,你应该根据实际情况修改这些路径。前两行用于定位 MoinMoin 模块,最后一行用于定位 wikiconfig.py 文件。

注意: 可能需要编辑这个文件的第一行,将它指向 Python 的正确版本,默认值应该可以运行,如果不行的话可以使用 "#! /usr/bin/python2.3"。

注意 2: 在这个文件中有一行 request = RequestCGI(). 如果你使用复杂的 mod_rewrite,可以在括号中添加 properties = {'script_name': '/mywiki'} 。这样 MoinMoin 可以生成以 /mywiki 开头的URLs:

def handle_request(req, env, form):
    request = RequestCGI(req, env, form, properties = {'script_name': '/mywiki'})
    request.run()

配置 MoinMoin

最后,检查例程目录下的 wikiconfig.py 文件中是否包含正确的htdocs目录,例程data目录,underlay目录的路径。可以使用相对路径,但注意它们是相对于CGI脚本的,而不是相对于配置文件的!你也可以使用绝对路径,这样不会出错

    data_dir = '/home/mm/share/moin/mywiki/data/'
    data_underlay_dir = '/home/mm/share/moin/mywiki/underlay/'
    url_prefix = '/~mm/wiki'

测试维基

现在一切都应该工作正常了。现在按照下面的步骤来操作:

  • 运行 MoinMoin CGI Diagnosis: > lynx -dump http://localhost/~mm/cgi-bin/moin.cgi?action=test

  • 使用 "http://127.0.0.1/~mm/cgi-bin/moin.cgi" 访问你的新维基(或者是你在 Apache 配置文件中设置的名字和端口)。应该可以看到 FrontPage。

  • 如果上面操作正常,试着编辑并保存。
  • 如果上面操作正常,查看你的更改是否在最新改动页面上体现出来了。

  • 如果上面操作正常,祝贺你,你的维基可以正常运行了!

如果有错误发生,请看下面的问题解答

问题解答

你可以在 ../问题解答中看到更多信息。

当维基工作不正常的时候,首先应该使用命令 "tail /var/log/httpd/error_log" 来显示最近的错误。通常,你可以看到发生了什么错误,比如说缺少权限之类的。

Adding permission to serve the htdocs directory

In some (sane) Linux distributions (like SuSE 9.0) serving directories other than the document-root "/srv/www/htdocs" with Apache is switched off by default for security reasons in "/etc/httpd/httpd.conf" (or for Apache2 "/etc/apache2/httpd.conf"):

# forbid access to the entire filesystem by default
<Directory />
  Options None
  AllowOverride None
  Order deny,allow
  Deny from all
</Directory>

To allow Apache to serve directories outside of the document root you have to add these lines to "/etc/httpd/httpd.conf" (in SuSE it is recommended to create a new "http.conf.local" and include this file in "/etc/sysconfig/apache2"):

Alias /wiki/ "/usr/share/moin/htdocs/"
<Directory "/usr/share/moin/htdocs/">
   Order deny,allow
   Allow from all
</Directory>

ScriptAlias /mywiki "/usr/share/moin/mywiki/cgi-bin/moin.cgi"
<Directory "/usr/share/moin/mywiki/cgi-bin">
   Order deny,allow
   Allow from all
</Directory>

Of course, you need to adapt the paths to your particular situation.

此页的英文版本: HelpOnInstalling/ApacheOnLinux


Invalid include arguments "帮助-安装/FastCgi, 使用 Apache/Lighttpd 和 FastCGI", 1"!



使用 Twisted

Using MoinMoin with Twisted

Twisted is an event-driven networking framework for many kinds of applications. For MoinMoin Twisted is used as a web server that just imports MoinMoin persistently. This has the advantage that the Python interpreter and all Python scripts (including Twisted itself and also MoinMoin) is only loaded and initialized one time, and that data can be cached in memory from request to request, enhancing the performance of MoinMoin.

Besides the general installation you need 3 files:

  1. the script /path/to/cgi-dir/mointwisted (see "Starting the server" below)

  2. the webserver script file like mointwisted.py (which needs to be in the same directory where your working directory is).

  3. the configuration file like /path/to/wikiconfig-dir/wikiconfig.py

Install Twisted

First, install Twisted (see URL above). Many Linux distributions have Twisted packages. Please refer to the documentation of Twisted for installation information.

Configuring the Twisted server

Copy the file wiki/server/mointwisted.py to your wiki directory. Edit and adapt the settings to your needs.

System path configuration

If you did a standard install, and you are not a developer, you probably want to skip this section. Otherwise, you might want to add the path to moin and config file, like that:

sys.path.insert(0, '/path/to/moin')
sys.path.insert(0, '/path/to/wikiconfig')

Config class options

If you did a standard install, the default options might be just what you need. Check and change what you like:

Option

Default

Comment

docs

'/usr/share/moin/wiki/htdocs'

Path to moin shared files

user

'www-data'

If you run as root, the server will run as this user

group

'www-data'

If you run as root, the server will run as this group

port

8080

Port to serve. To serve a privileged port below 1024 you will have to run as root

interfaces

['']

A list of interfaces the server will listen to. If the list contains the entry '' (like for the default configuration), all other entries are ignored and the server will listen to all interfaces.

logPath

'mointwisted.log'

Log file.

profiler

commented python code

Useful only if you are a moin developer.

Configuring wikiconfig.py

The sample config file should be just fine.

Don't change url_prefix_static as the default value is hardcoded in the Twisted server.

Starting the server

on Unix

On GNU/Linux, Mac OS X or another POSIX-like OS, copy wiki/server/mointwisted to your wiki directory. You might want to adapt PYTHONPATH and the path to twistd.

Start the server with ./mointwisted start and test your wiki at http://localhost:8080/. Stop the server with ./mointwisted stop.

For more options run ./mointwisted without arguments.

If you want to start the server via initscript make sure mointwisted finds montwisted.py on startup!

on Windows

Copy wiki/server/mointwisted.cmd to your wiki directory. You might have to change the path pointing to the python-scripts directory.

Double click mointwisted.cmd to start the server. It will create a new terminal window. To stop the server, close the terminal window.

A windows service runner written in Python

I have written a service runner to help configuring a windows service to run, because I prefer to run moin using Twisted.

Usage:

  1. install pywin32
  2. download servicerunner.py
  3. modify the "mointwisted" and "mointwisted_dir" according to your system
  4. run "servicerunner.py install" on the command line

servicerunner.py


使用独立服务和 Linux

安装和配置独立服务

同时参考:HelpOnConfiguration/IntegratingWithApache

独立服务专门用于本地维基,因为它不需要安装网络服务器,需要的仅仅是Python和Moin。

要安装并运行独立服务:

  1. 如果MoinMoin还没有安装,请先进行 ../基本安装

  2. 按照[../创建维基例程]里面所叙述的,创建一个维基实例。
  3. moin.py 拷贝到你的维基目录, 即wikiconfig.py所在的地方。

  4. 如果你使用--prefix选项进行安装,必须编辑moin.py并正确设置docs的路径。

  5. 运行moin.py

  6. 通过 http://localhost:8000/ 访问你的维基。

大多数情况下,默认的设置就可以正常工作。你可以按照后面一节描述的内容来编辑moin.py,改动其中一些选项。

配置 moin.py

系统路径配置

如果你进行了标准安装,而且你不是开发者,那么你可以跳过这一节。如果不是那样,你可以把路径加入moin和配置文件,就像这样:

import sys
sys.path.insert(0, '/path/to/moin')
sys.path.insert(0, '/path/to/wikiconfig')

配置类选项

选项

默认值

注释

name

'moin'

服务器名称,默认用于日志和pid文件。 (!) New in 1.5

docs

'/usr/share/moin/wiki/htdocs'

moin共享文件路径。如果你使用 --prefix 安装,那么默认路径不能正常工作,你必须把路径设置成'PREFIX/share/moin/wiki/htdocs'

user

'www-data'

如果你以根用户运行,则服务会按照该用户的设置来运行。

group

'www-data'

如果你以根用户运行,则服去会按照该用户组的设置来运行。

port

8000

服务端口。如要想在1024端口之内运行,你必须是根用户才可以 。

interface

'localhost'

服务监听接口。默认情况下只监听localhost。设置为 '' 就可以监听所有的。

logPath

name + '.log'

日志文件。推荐使用默认设置。

serverClass

'ThreadPoolServer', 'ThreadingServer', 'ForkingServer', 'SimpleServer'

使用的服务类型,请参考moin.py中的注释。 默认类型是 'ThreadPoolServer',它创建线程池,并且在有新连接时重复使用它们。 (!) New in 1.3.5

threadLimit

10

创建多少线程。 (!) New in 1.3.5

requestQueueSize

50

被操作系统缓冲的socket连接请求数目。 (!) New in 1.3.5

properties

 {} 

在该字典中设置键值,允许不顾其任意请求性质,比如properties = {'script_name': '/mywiki'}. (!) New in 1.5

  • (!) 对于moin开发者来说,还有其他有用的选项,请看moin.py中的注释

配置 wikiconfig.py

给定的配置文件范例应该可以正常工作。

选项

默认值

注释

url_prefix

'/wiki'

你不应该改变这一项,否则image和css文件都不能使用了!

启动服务

从命令行运行 moin.py

$ ./moin.py
Serving on localhost:8000

通过 http://localhost:8000/ 测试维基

在Windows上,你可以双击moin.py来启动服务。新的终端窗口会打开。关闭该窗口或者按下Control+Pause来停止服务。

在Unix上,使用Control+C来关闭服务。

在Unix上使用80端口

在GNU/Linxu, Mac OS X 或者其他Posix类操作系统,你可以使用标准的80端口服务,但是你必须作为根用户运行才可以。

port设置为80,并确认usergroup在你的系统上存在。如果不是的话,把它们设置为已存在的用户(对于网络服务来说)。如果有必要,把你的维基目录chown到该用户和用户组。

使用根用户运行moin.py

$ sudo moin.py
Password:
Serving on localhost:8000
Running as uid/gid 70/70

通过 http://localhost:8000/ 测试维基

在后台运行

如果运行在Unix上,你可以把moin.py运行在后台:

  1. 有用一个正常工作的 moin.py (像上面所描述的那样)。

  2. prefix/share/moin/server/moin拷贝到维基目录。

  3. 运行moin服务:

./moin start

要停止服务:

./moin stop

直接运行moin不加任何参数,可以得到更多信息。

如果想从系统启动脚本中启动moin,你需要把路径添加到moin.py的顶端:

# Add the path to moin.py directory 
import sys
sys.path.insert(0, '/path/to/moin')
  • (!) New in release 1.5

此页的英文版本:HelpOnInstalling/StandaloneServer


使用 Apache 和 Mac OS X

These instructions will walk you through, step by step, setting up Moin on Mac OS X

  • Apple's latest operating system, 10.5 Leopard, packs enough under-hood changes that, rather than a bunch of if/then instructions, going forward this page will be updated only for Leopard. If you have an older system (Tiger or Panther) you can click 'info' and view revision 45 for hints for those operating systems.

System Requirements & Preparation

MacOS 10.5 Leopard includes the latest version of Python, version 2.5.1. (Older versions 10.4-Tiger and 10.3-Panther include the minimum required versions of Python to run Moin without updating, 2.3.5 and 2.3 respectively).

MoinMoin installation requires the use of the Terminal and assumes you have a basic familiarity with commands and syntax. When you read commandline mentioned below, assume that you will enter these commands using the Terminal.app (located in /Applications/Utilities/Terminal.app).

Make sure Apache is started ('Apple' menu > 'System Preferences...' > 'Sharing' panel > and check "Personal Web Sharing")


Installation

Installing MoinMoin

  1. Download MoinMoin

  2. Expand the archive

    • Double-click to expand the moin-X.X.tar.gz archive.

    • You should then have a folder such as moin-x.x where "x.x" is the current release number. This folder will contain a setup.py file in addition to several other files and subfolders. Optionally, you may want to move the expanded moin-X.X folder to a location more convenient to work from, like into a temp folder the root of your hard drive.

  3. Run Setup.py from the commandline

    • Open Terminal.app and enter the commands:

      sudo -s
      password:
    • Now you have root privileges in this shell (note: the prompt will change from a $ to a #). To install, type:

      cd /temp/moin-1.6
    • (!) Important: Now you have to decide where you want to install your Moin wiki installation; this will be your wiki root folder. Unix traditionalists will install this into /usr/local because of long standing unix conventions. However, on Mac, this and other unix folders are typically hidden from the Finder. So, you may want to install outside this folder where you can more easily manage the files (such as drag-copy backups, editing config files using TextEdit.app, etc). In the examples below, Moin is installed in a folder on the root of your hard drive named /moinwiki. If you want to follow unix conventions, simply substitute /usr/local for /moinwiki in all the examples below.

      python setup.py install --install-data='/moinwiki'
    • The --install-data='/moinwiki' argument tells the setup script where to put the data. In this case, it will create a folder on the root of your hard drive called 'moinwiki'.

    • (!) Note: 'moinwiki' may seem like an odd name, but there are a number 'moin' folders created, so I use 'moinwiki' to distinguish this folder from the others. You can of course name it anything you like.

    • <!> Security warning: Your wiki should not be in the "Sites" folder of your home folder, or in the /Library/!WebServer/Documents (Apache root) folder. Do not put your wiki folder where the web server can access it!

  4. Add yourself access privileges for moinwiki

  5. Apple tightened security in 10.5 Leopard. We want to add our username to the moinwiki folder so that it's easier to work with.

    1. right-click (control-click) on the moinwiki folder, and select "Get Info...".
    2. click the lock icon in the lower-right corner, enter your password to unlock.
    3. click the + icon to add a new user, from the dialog select your username.
    4. change your privileges to "Read & Write"

    5. click the gear icon and select "Apply to enclosed items".

The installation portion is now finished.


Configuration

You are now ready to create a wiki instance! The following instructions will create a wiki called "mywiki". You may replace the name mywiki with almost any name you wish, but do not use wiki because that is used by MoinMoin for loading standard images and style sheets. Although this can be changed later, the name you choose for mywiki will become part of the url used to access your site, e.g. http://server.myorganization.org/mywiki/FrontPage.

Creating a Wiki Instance

We now want to create our own wiki instance and copy in a default set of templates and files. Do these commands:

cd /moinwiki/share/moin
mkdir mywiki
cp -r data mywiki
cp -r underlay mywiki
cp server/moin.cgi mywiki
cp config/wikiconfig.py mywiki

You can repeat these steps for creating multiple instances, run these same commands again, substituting mywiki2 for mywiki.

Configuring Apache httpd.conf

Apple upgraded Apache to 2.2 in Leopard, which (among other things) brings tighter security controls than previous versions.

  1. Add yourself access privileges for apache2 (alternatively, if you're comfortable with commandline (Terminal.app), you can bypass these steps and use sudo and pico instead)

    1. From the Finder, under the 'Go' menu, select "Go to folder..." and type /etc.

    2. right-click (control-click) on the apache2 folder, and select "Get Info...".
    3. click the lock icon in the lower-right corner, enter your password to unlock.
    4. click the + icon to add a new user, from the dialog select your username.
    5. change your privileges to "Read & Write"

    6. click the gear icon and select "Apply to enclosed items".
  2. Edit Apache's configuration file, httpd.conf

    1. From the Finder, under the 'Go' menu, select "Go to folder..." and type /etc/Apache2. Drag the httpd.conf file onto TextEdit.app.

    2. Go to the end of the Aliases section and edit like the example below:

          Alias /moin_static160/   "/moinwiki/share/moin/htdocs/"
          ScriptAlias /mywiki      "/moinwiki/share/moin/mywiki/moin.cgi"

      Add the following to allow Apache to access your moinwiki directory (see http://httpd.apache.org/docs/2.2/mod/core.html#options for more help):

      <Directory "/moinwiki">
          Options Indexes FollowSymLinks MultiViews
          AllowOverride None
          Order allow,deny
          Allow from all
      </Directory>
    3. Save changes
    4. Restart Apache -
      • open System Preferences, go to the Sharing page, select "Personal Web Sharing" and click "Stop" then "Start".
      • Alternatively, from Terminal.app, type apachectl graceful.

Configuring moin.cgi

The moin.cgi file essentially tells Apache to run all the moin wiki pages through the python interpreter.

  1. Edit the moin.cgi file at the following path /moinwiki/share/moin/mywiki/moin.cgi (click-drag the file onto TextEdit.app). Change the line that points to your wikiconfig.py file, like in the example below.

    sys.path.insert(0, '/moinwiki/share/moin/mywiki/wikiconfig.py')
  2. What to do if you get an "Internal Server Error"
    This most likely means that the pathname above is not correct.

    You can test your pathname by opening Terminal.app and pasting in the above line without the shebang #! statement (using the above example, /Library/Frameworks/Python.framework/Versions/2.5/bin/Python. If the path is correct, you should see output indicating your Python version as well as sample commands such as "help", "copyright", "credits", etc. If you get the error "Bad executable (or shared library)" or "No such file or directory" then the path is likely wrong, and you will need to correct. I've also noticed that it helps to point directly at the "python" executable, rather than the alias or symlinks found in the upper directories.

Configuring wikiconfig.py

Open wikiconfig.py (click-drag the file onto TextEdit.app) and read the comments. The wiki you created is a new "Untitled Wiki", using the default configuration. You want to give a better name and setup some configuration values.

  • (!) Note that the file belongs to user and group www:www. You can edit the file as root, or change the group of the file to yourself with chown www:username wikiconfig.py.

Edit /moinwiki/share/moin/mywiki/wikiconfig.py and change the sitename to the name of your wiki:

    sitename = 'My Mac Wiki'

Additionally, set data_dir and data_underlay_dir to the absolute paths of the particular directories. You can use relative paths for the directories, but note that they are relative to the CGI script, not the configuration file! Better to use absolute paths, and save yourself some headaches:

    data_dir = r'/moinwiki/share/moin/mywiki/data'
    data_underlay_dir = r'/moinwiki/share/moin/mywiki/underlay'

Uncomment the url_prefix_static line:

    url_prefix_static = '/moin_static160'

For a public installation, you'll normally want to forbid some of the more dangerous actions. Add a line like this to wikiconfig.py:

    actions_excluded = ['AttachFile', 'DeletePage', 'RenamePage', ]

Additional configuration details can be found in HelpOnConfiguration.

Setting Permissions

You have to make the web server the owner of the files in your wiki. Navigate to /moinwiki/share/moin/ and run the following commands:

chown -R www:www mywiki
chmod -R 744 mywiki


Testing Your New Wiki

In a web-browser surf to the site: http://localhost/mywiki You should see the FrontPage of your new wiki.

Now run the unit tests, to make sure everything is fine. Go to this address: http://localhost/mywiki?action=test



使用 IIS 和 Windows

Index

Requirements & Preparation

Before you install MoinMoin, make sure you have the necessary infrastructure in place, namely the Internet Information Services webserver (any version should be OK), and a Python installation (at least version 2.3 is required, the latest python release is recommended).

These instructions make the basic assumption that you will have these components installed in their default locations. In reality, you'll probably have them installed elsewhere (on the D: drive, for example). Be careful to substitute your drive and paths based on the following assumed default locations:

  • IIS to its default location
  • C:\Python - the Python interpreter

  • C:\Moin - MoinMoin itself

Installation

Installing IIS

From Microsoft: (http://www.microsoft.com/windows2000/en/server/iis/)

  1. To install IIS, add components, or remove components:
    1. Click Start => Settings => Control Panel => Add/Remove Programs.

    2. Click 'Add/Remove Windows Components', Check 'Internet Information Services' and follow the on-screen instructions to install. ( /!\ it is also recommended to click the 'details' button and un-selecting components you will not need. This will depend on your server role; but for example, you probably will not need FTP, or "Frontpage 2000 Server Extensions").

Make sure that your webserver runs without problems before you start to install MoinMoin; problems with your webserver installation are not in the scope of this document.

Installing Python

There are currently two different distributions of Python available for Windows. Either version will work fine.

  1. http://www.python.org - The standard open-source Python distribution.

    • The installer is a windows executable (.exe) file.
  2. http://www.activestate.com - An alternative, commercially-supported, distribution (distributed for free (email address required)).

    • The installer is a Windows .MSI file.
    • If you are or plan to develop in the Python language, ActivePython has some tools specific to the Windows operating system and includes a popular Windows IDE called Pythonwin.

MoinMoin works with either distribution, but requires Python release 2.3 or later. Download and install the distribution of your choice. Be sure your Python installation is correct before proceeding. Installation is straightforward; however, any questions or issues regarding the Python installation process should be resolved through the use of resources provided by Python.org or ActiveState.

Installing MoinMoin

  1. Download MoinMoin

  2. Expand the archive

    • Note: users of older versions of WinZip report problem expanding .tar.gz files. Either upgrade or use the free 7-Zip utility.

    • Expand the archive into C:\TEMP or an alternative location.

    • You should then have a folder such as C:\TEMP\moin-x.x where "x.x" is the current release number. This folder will contain a setup.py file in addition to several other files and subfolders.

  3. Run Setup.py from the commandline

    • Open an DOS window (start > Run... > type cmd) and enter the commands:

      C:
      cd \temp
      unzip moin-1.6.zip
      cd moin-1.6
      python setup.py install --prefix=C:\Moin --record=install.log

This will install all necessary files to the "C:\Moin" directory, and create a "install.log" file listing all the files that are created there.

You are now ready to create a wiki instance.

Configuration

Creating a Wiki Instance

Enter these commands in a console window from C:\Moin>:

cd c:\Moin
md mywiki
md mywiki\data
md mywiki\underlay
xcopy share\moin\data mywiki\data /E
xcopy share\moin\underlay mywiki\underlay /E
copy share\moin\server\moin.cgi mywiki\
copy share\moin\config\wikiconfig.py mywiki\
copy share\moin\htdocs\index.html mywiki\default.htm

"mywiki" is the name of your wiki instance, you might want to chose a different name best fitting the intended use of this instance; just don't name it simply "wiki", because that would result in confusion and problems later on.

We have to make sure that moin.cgi can find the MoinMoin directory, so that "import MoinMoin" will work. The easiest way to make sure MoinMoin can be imported is to append to sys.path within moin.cgi.

You can change the first two lines of code in moin.cgi to something like this:

   1 #!python
   2 import sys
   3 sys.path.append('C:/Moin/Lib/site-packages')

Notice that we're pointing to the directory which contains the MoinMoin directory, not the directory itself.

Configuring IIS

Next, you'll need to create two virtual directories in IIS. One for the shared data, and one for this specific wiki instance.

Configuring IIS 5.0 and above

  1. Open Internet Services Manager (Start > Settings > Control Panels > Administrative Tools > ...). Open up the tree to Default Web Site.

  2. Right click on Default Web Site and choose New > Virtual directory.

    1. This will bring up a wizard with the mandatory useless first screen, hit next.
    2. Enter "wiki" for the alias name, hit next.

    3. Browse to "C:\Moin\share\moin\htdocs", hit next.

    4. Leave the Access permissions at their defaults, hit next.

    5. And now you're done, hit finish!
  3. Now follow the same steps, but set the alias to "mywiki" and the path to "C:\Moin\mywiki".

  4. Use IIS Admin to remove permissions to read the data directory:
    1. expand the "mywiki" node

    2. right click on data

    3. select Properties

    4. and uncheck Read.

    5. Repeat these steps with the underlay directory.

  5. Now you need to setup the 'mywiki' alias so that it will run Python to interpret .cgi files.

    1. On Windows Server 2003, click the Create button under Application Settings to create an application space.

    2. Right-click on your new 'mywiki' alias and choose Properties. On the first tab (Virtual Directory), click the Configuration button.

    3. The first tab is the App Mappings tab, which defines which programs to use for each file extension.

    4. Click Add. Browse to your python.exe (probably something like c:\pythonXX\python.exe).

    5. Then add -u "%s" "%s" after the Python executable path. The Executable line will look something like this: "C:\Python22\python.exe" -u "%s" "%s". In the Extension box enter .cgi with the beginning period.

    6. Make sure that the Check that file exists option is not checked (if it is, MoinMoin won't be able to display sub pages).

    7. Ok, you're done with the alias configuration, click OK several times to get back out of all the dialog boxes.

  6. If you add another wiki instance, you'll only need to setup the reference to its folder, they can safely share the "wiki" alias which points to static files only.

IIS 6.0 (Windows Server 2003)

The instructions below also apply to IIS 6.0 but the more aggressive security settings in newer version of IIS disallow the usage of unknown CGI extensions. That means you will always get a 404 error unless you do this:

  1. Open IIS Manager (Start > Programs > Administrative Tools > IIS Manager).

  2. Go to the Web Service Extensions folder.

  3. Under the Action menu, select Add a new Web service extension....

  4. For Extension name, give it a name such as .cgi or Python cgi or similar.

  5. Under Required files click the Add... button and type in the exact command-line string you used above. Eg: c:\python24\python.exe -u "%s" "%s", then click the Ok button.

  6. Make sure the Set extension status to Allowed checkbox is checked and click the Ok button.

Another change that may be necessary if you are receiving HTTP Error 403 19 1314 while using IIS 6.0 is to adjust the Identity settings for the Application Pool that is being used by your site. The following steps assume you are adjusting the Default Web Site.

  1. Open IIS Manager (Start > Programs > Administrative Tools > IIS Manager).

  2. Go to the Application Pool folder.

  3. Select the Application Pool you wish to adjust. (likely DefaultAppPool ) When you do this on the right you will see the Application pools for each site on the server. This will include a Description (likely Default Application ) and a Path (<Default Web Site>). In this way you can be certain you are adjusting the appropriate Application Pool.

  4. With DefaultAppPool still selected right click and select Properties.

  5. Select the Identity tab and with Predefined clicked use the drop down box to change the Identity to Local System instead of Network Service. Please be aware that this is a workaround since you SHOULD set your group settings to allow Network Service to access the cgi scripts.

Under Windows Server 2003, you will also need to give your IUSR_MACHINENAME account Modify access to the mywiki\data and mywiki\underlay sub-directories, as file system permissions are more restricted by default than previous Windows versions.

That is all, try to access your new-born wiki with the URL http://127.0.0.1/mywiki/. You should see the FrontPage, try to edit and save it, and if that works, see if your edit is reflected on the RecentChanges page.

Configuring wikiconfig.py

Finally, edit "wikiconfig.py" and at least change "sitename" and "logo_string" to some personal values:

sitename = u'My Wiki'
logo_string = u'<img src="/mywiki/images/mywiki-logo.gif" alt="MyWiki Logo">My Wiki'

Where "images" is a directory under your "mywiki" instance.

NOTE: The configuration variable "url_prefix" in "wikiconfig.py" should match the alias for "C:\Moin\share\moin\htdocs" or themes will not work ("/wiki" for the instructions above). This way, any reference in "wikiconfig.py" to "/wiki/something" will look in the shared data directory and a reference to "/mywiki/something" will look in the wiki instance directory. These are considered absolute paths because relative paths will not work correctly.

It seems you need to change the Custom Errors setting for 404 before you can create new pages. You can accomplish this by performing the following steps:

  1. Go into the IIS Manager, right-click on 'mywiki' (or whatever your wiki instance directory is called), and select properties.
  2. Next, go to the Custom Errors tab and find the 404 entry, and click the Set to Default button.

Troubleshooting

  • If you see an error like "ImportError: No module named MoinMoin", it means that python cannot find MoinMoin. See above for how to add to sys.path.

  • If you see an error like Error 13: Permission Denied, it means that your web user permissions for the files do not have write/modify enabled.
  • If the page never loads after hitting Save Changes, you should check the permissions of the data directory. Make sure the IUSR_COMPUTERNAME user has modify permissions.

  • If some images like InterWiki and WorldWideWeb don't show up, it could have been because of incorrect permissions or a bad "url_prefix" in "wikiconfig.py" or the cached pages need to be updated by an Edit or deleting them in the data folder. Or you are using MS IE which has broken CSS :before support - try another browser.

  • If you see an error message like:

    Check your URL regular expressions in the "wikis" list in "farmconfig.py". Content-type: text/html;charset=utf-8
    MoinMoin Configuration Error
    Could not find a match for url: "servername/wikiname/moin.cgi?
    Check your URL regular expressions in the "wikis" list in "farmconfig.py".
    • and you don't intend on using a serverfarm, remove the farmconfig.py and farmconfig.pyc files and try again. The error message shouldn't appear when you refresh the page.

IIS URLScan problem

If you see an error like "The system cannot find the file specified." when trying to run Moin on IIS the problem may be URLScan. By default URLScan blocks any URLs that use PATH_INFO. To solve the problem, edit the URLScan.ini file in the %SystemRoot%\system32\inetsrv\urlscan\urlscan.ini directory. I changed the line allowdotinpath from 0 to 1. As follows

allowdotinpath=1               ; if 1, allow dots that are not file extensions

Also, you might have to add the following setting:

[options]
AllowHighBitCharacters=1

Next save the URLScan.ini and then restart the IIS service. Your wiki should now work.

For more information, please reference the Microsoft article How to configure the URLScan tool

Next Steps


问题解答

如何处理常见错误

首先遵循建议

Moin为常见使用方法提供了建议. 试着根据建议的默认值创建维基. 这样你的维基会和我们的一样被存储, 而且被命名为mywiki ... 但是在你有一个可以工作的维基之后, 你可以改变位置和名字. 默认值的选择是很谨慎的, 大多数人在大多数平台上都可以正常工作, 或者至少有一个好的开始.

  • 首先遵循建议
  • 如无必要,不要改变任何配置.
  • 在你试图自定义维基之前,现在一个正常运行的维基上使用.

一次改动一个

当你的维基运行时, 根据你的需要去自定义它既可, 但记住每次只改变一个选项. 也许你不能完全理解所有的选项是如何工作的, 如果在同一步中改动了一些东西而出现问题, 你会发现很难解决出现的问题.

检查你的网络服务器是否可以使用Python

这在帮助-安装/基本安装中也有提及. 使用这个脚本:

echo Content-Type: text/plain
echo
echo "Your web server is running as:"
id
echo "CGI scripts work"
echo "Now we try to invoke Python interpreters and get their versions:"
python -V 2>&1
python2.3 -V 2>&1
python2.4 -V 2>&1
echo "Finished."

来检查cgi是否工作. 然后你也会知道哪一个版本的python是可用的. 对于没有根用户权限的用户这非常有用.

内置测试

安装时, 有一个内置的诊断模式非常有用; 只需在你的维基URL后面添加"?action=test":

lynx --dump http://`hostname`/mywiki?action=test

如果你看到import error, 但是

python -c "import MoinMoin"

正常, 那可能是缺少文件权限或者网络服务器环境下错误的PYTHONPATH设置.

决战Pythons

你可能遇到的最常见的问题是,当你有一个较老的Python版本安装在"/usr"下, 而一个较新的Python发行版安装在"/usr/local"下; 这在GNU/Linux发行版中是很典型的情况,他们有时仍然捆绑了较老的Python版本.

在这种情况下, 如果在提示符下键入"python", 你一般可以使用较新的Python解释器, 因为"/usr/local/bin"在你的PATH中. 在网络服务器环境下情况是不同的, 因此你可能不得不改变"moin.cgi"的bang path, 就像这样:

"""
    MoinMoin - CGI Driver Script
...
"""
  • Debian stable user might want to look for backport of newer Python, or download and build Python from source.
  • 安装时, 确保使用你希望用以运行moin的python来安装. python setup.py install 会使用路径中第一个python来安装, 而这也许不是你希望使用的版本! /usr/local/bin/python2.4 会使用指定的python进行安装. 你需要在moin服务器脚本中使用相同的路径.

文件权限缺失

如果你是根用户, 则安装的文件只能被根用户读取, 但是在维基工作之前它们也必须能够被网络服务器读取. 这包括Python模块和网站本身. 对于data目录, 维基引擎也需要write权限. 为了解决这个问题, 应首先找到Python模块的目录所在; 察看install.log, 或者运行命令:

python -c "import sys; print '%s/lib/python%s/site-packages' % ( sys.prefix, sys.version[:3] )"

对于下面的这个例子, 我们假设Python模块目录是/usr/local/lib/python2.3/site-packages. 使用下面的命令是文件是全局可读的:

cd /usr/local
chmod -R a+rX lib/python2.3/site-packages/MoinMoin

小心的设置Python变量

当重新输入而不是剪切和粘贴操作时,应特别小心. 在wikiconfig.py中引用错误会导致失败. 其后的条目也是变量. 还有, 一些功能只有在wikiconfig.py或者farmconfig.py中开启他们对应的选项后才能正常使用.

moin.cgi找到, Moin不运行

如果你不得不将moin代码位置加入系统路径, 请确保指定这个路径是MoinMoin本身的上级, 这样MoinMoin这个词汇在导入时可以找到.

CSS文件不工作

丢失CSS样式是很常见的错误. 你的维基看起来很丑陋, 一点也不像现在这个漂亮的维基. 大多数情况下, 是因为你没有阅读建议而弄错了配置, 或者因为你比我们聪明,而试图自定义这些建议. :-)

解决问题很简单: 确保你的Apache Alias和ScriptAlias是一样的. 这个Apache设置永远不能工作:

Alias /wiki/ "/prefix/share/moin/htdocs/"
ScriptAlias /wiki/ "/var/www/wiki/moin.cgi"

Alias用于静态文件: css, 图片等等. ScriptAlias用于将moin.cgi从url中隐藏. 你必须使用不同的值! 对于ScriptAlias, 或者Alias, 你可以使用任何值, 但是Alias必须匹配url_prefix的设置. 这是一个可以工作的例子(默认设置):

# Apache config
Alias /wiki/ "/prefix/share/moin/htdocs/"

# Wiki config
    url_prefix = '/wiki'