## Please edit system and help pages ONLY in the moinmaster wiki! For more
## information, please see MoinMaster:MoinPagesEditorGroup.
##master-page:HelpOnConfiguration/IntegratingWithApache
##master-date:2006-05-01 13:33:20
#acl MoinPagesEditorGroup:read,write,delete,revert All:read
#format wiki
#language zh

''' 如何与 Apache 整合 '''

目前有5种运行 MoinMoin 维基的方式：使用CGI，FastCGI，Mod Python，独立模式或者 Twisted 服务器，最好的方式是 FastCGI 或者 Mod Python，但是它们不能在所有的系统上使用，而且配置上也有问题。另一种方式是使用 Twisted 或者 独立模式，它们比 CGI 速度快得多，配置也比较容易。

但是，很多人已经使用网络服务器提供静态网页或者其他应用程序，只是希望在目前的基础上增加一个维基。The best option is to run MoinMoin as a Standalone or Twisted server proxied behind your existing web server. In release 1.5 this works out of the box with simple setup.

在下面的示例中,我们会把 MoinMoin 维基与 http://www.example.com/exwiki/ 整合到一起。

 (!) New in release 1.5

= 系统要求 =

 1. 如["帮助-安装"] 所述，安装独立模式或者Twisted服务器
 1. 确认 mod_proxy 已经安装并载入了。请参考 [http://localhost/manual Apache Documentation].

= 与 Apache 2 整合 =

== 设置独立模式或 Twisted ==

如果你想使用 Twisted，请编辑 {{{mointwisted.py}}} 并设置如下选项:
{{{
    port = 8000
    interfaces = ['localhost']
}}}

如果你想使用独立模式，请编辑 {{{standalone.py}}} 并设置如下选项:
{{{
    port = 8000
    interface = 'localhost'
}}}

现在运行 moin 服务器，检查 http://localhost:8000 是否工作正常。

== 设置 Apache 2 ==

编辑 Apache 的配置文件 `httpd.conf` 或者其他导入的配置文件:
{{{
# Must be off to run a reverse proxy
ProxyRequests Off

Alias /wiki/ "/usr/share/moin/htdocs/"

<Location /exwiki/>
    ProxyPass http://localhost:8000/
    ProxyPassReverse http://localhost:8000/
    RequestHeader set X-Moin-Location /exwiki/
</Location>
}}}

现在重新启动 Apache，检查维基 http://localhost/exwiki/ 或者 http://www.example.com/exwiki/

这个设置过程已在 Mac OS X 上验证通过。


= 与 Apache 1 整合 =

== 设置独立模式或 Twisted ==

如果你想使用 Twisted，请编辑 {{{mointwisted.py}}} 并设置如下选项:
{{{
    properties = {'script_name': '/mywiki', 'http_host': 'yourdomain'}
    port = 8000
    interfaces = ['localhost']
}}}

如果你想使用独立模式，请编辑 {{{standalone.py}}} 并设置如下选项:
{{{
    properties = {'script_name': '/mywiki', 'http_host': 'yourdomain'}
    port = 8000
    interface = 'localhost'
}}}

 (!) 另一种方法是使用 url_mapping 选项。

== 设置 Apache 1 ==

继续操作之前，请确认已经安装和加载 mod_proxy。

编辑 Apache 的配置文件 `httpd.conf` 或者其他导入的配置文件:
{{{
# Must be off to run a reverse proxy
ProxyRequests Off

Alias /wiki/ "/usr/share/moin/htdocs/"

<Location /exwiki/>
    ProxyPass http://localhost:8000/
    ProxyPassReverse http://localhost:8000/
</Location>
}}}

现在重新启动 Apache，检查维基 http://www.example.com/exwiki/

 (!) 注意，如果使用这种安装方法，你的维基不能通过 http://localhost:8000 访问。

 <!> Tested with Apache 2, should work also on Apache 1.

= 设置 Farm =

不使用代理来运行 Twisted 和独立模式的时候，维基 url 含有服务器名字(可能还有端口)和页面名字。 比如: `localhost:8000/pagename`. 

但是，在代理后运行时，维基 url 含有代理的名字而不是服务器的名字，可能还包括 "script_name"。这样的话，当你通过代理访问维基时，运行在 `localhost:8000` 上的维基可能具有 `www.example.com/exwiki/pagename` 一样的链接，在当地访问维基时，链接可能是 `localhost:8000/pagename`。

如果你想对当地访问和外部访问使用同样的配置文件，请在 `farmconfig.py` 文件中使用如下设置:
{{{
wikis = [('exwiki', r'^(localhost:8000|www.example.com/exwiki).*')]
}}}

如果你想对当地访问和外部访问使用不同的配置文件:
{{{
wikis = [('exwiki_local', r'^localhost:8000.*'),
         ('exwiki_world', r'^www.example.com/exwiki.*'),]
}}}

= 取消 host rewriting =

如果你想取消 new transparent host rewriting，请在服务器脚本中设置 `http_host`:
{{{
    properties = {'http_host': 'hostname'}
}}}
