MediaWiki§
使用 Unit 运行 MediaWiki 协作和文档平台
使用 PHP 语言模块安装 Unit。
安装 MediaWiki 的 核心文件。此处,我们将其安装在 /path/to/app/;在配置中使用真实路径。
运行以下命令,以便 Unit 可以访问 应用程序目录
# chown -R unit:unit /path/to/app/
有关更多详细信息,包括权限,请参阅 安全检查清单。
接下来,准备 Unit 的 MediaWiki 配置(对 share 和 root 使用真实值)
{ "listeners": { "*:80": { "pass": "routes" } }, "routes": [ { "match": { "uri": [ "!/tests/qunit/*", "/cache/*", "/includes/*", "/languages/*", "/maintenance/*", "/tests/*", "/vendor/*" ] }, "action": { "return": 404 } }, { "match": { "uri": [ "/api.php*", "/img_auth.php*", "/index.php*", "/load.php*", "/mw-config/*.php", "/opensearch_desc.php*", "/profileinfo.php*", "/rest.php*", "/tests/qunit/*.php", "/thumb.php*", "/thumb_handler.php*" ] }, "action": { "pass": "applications/mw/direct" } }, { "match": { "uri": [ "!*.php", "!*.json", "!*.htaccess", "/extensions/*", "/images/*", "/resources/assets/*", "/resources/lib/*", "/resources/src/*", "/skins/*" ] }, "action": { "share": "/path/to/app$uri" } }, { "action": { "pass": "applications/mw/index" } } ], "applications": { "mw": { "type": "php", "targets": { "direct": { "root": "/path/to/app/" }, "index": { "root": "/path/to/app/", "script": "index.php" } } } } }
注意
pass 目标之间的区别在于它们对 script 设置 的使用
直接目标从 URI 运行 .php 脚本,如果没有 URI,则默认为 index.php。
索引目标指定 Unit 为目标接收的任何 URI 运行的脚本。
上传更新后的配置。假设上述 JSON 已添加到
config.json
# curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock http://localhost/config/
浏览至 http://localhost/mw-config/index.php 并使用前面记录的设置设置 MediaWiki
下载新生成的 LocalSettings.php 文件并将其放置在 适当的位置
$ chmod 600 LocalSettings.php # chown unit:unit LocalSettings.php # mv LocalSettings.php /path/to/app/
安装后,向第一步添加匹配条件以禁用对 mw-config/ 目录的访问
# curl -X POST -d '"/mw-config/*"' \ --unix-socket /path/to/control.unit.sock \ http://localhost/config/routes/mediawiki/0/match/uri/ { "success": "Reconfiguration done." }
更新成功后,MediaWiki 应可在侦听器的 IP 地址和端口上使用