这个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 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:
    • 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. The script takes a single parameter: the location of your wiki instance (see "Choose a location" section below):
    # ./createinstance.sh /path/to/mywiki
  4. 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.


使用独立服务和 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

系统路径配置

如果你进行了标准安装,而且你不是开发