:::tips
适用范围:
系统
- Windows
:::Microsoft 的 Internet Information Server (IIS) 是 Windows 的内置网页服务器。为了利用 IIS 功能 (如 URL 重写、静态档托管和崩溃后的自动重新开机),有助于在 IIS 中托管 TiddlyWiki。
1. 激活 IIS
- 在 Windows 中,请访问控制台,然后点击 添加或移除程序
- 在 添加或移除程序 窗口中,点击 添加/移除 Windows 组件.
- 勾选 Internet Information Services (IIS) 核取方块
- 点击 下一步,然后点击 完成
2. 安装所需的工具
- 从 https://www.iis.net/downloads/microsoft/httpplatformhandler 安装 IIS 模块 HttpPlatformHandler
- 从 https://nodejs.org/ 安装 Node.js
- 从 https://git-scm.com/ 安装 Git
- 为维基创建一个合适的目录 (例如,C:\MyStuff)
在其中创建一个名为 C:\MyStuff\package.json 的文件,内容如下: :::
{"name": "MyStuff","description": "A description of this wiki","dependencies": {"sax": "1.2.4","tiddlywiki": "*"}}
:::danger
同时创建一个名为 C:\MyStuff\web.config 的文件,内容如下: :::
<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><handlers><addname="httpplatformhandler"path="*"verb="*"modules="httpPlatformHandler"resourceType="Unspecified"requireAccess="Script" /></handlers><httpPlatformstdoutLogEnabled="true"stdoutLogFile=".\node.log"startupTimeLimit="20"processPath="C:\Program Files\nodejs\node.exe"arguments=".\node_modules\tiddlywiki\tiddlywiki.js ./wiki --listen port=PORT path-prefix=/MyApp"><environmentVariables><environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" /><environmentVariable name="NODE_ENV" value="Production" /></environmentVariables></httpPlatform></system.webServer></configuration>
:::danger
创建一个名为 “wiki” 的子目录 (即 C:\MyStuff\wiki)
创建一个名为 C:\MyStuff\wiki\tiddlywiki.info 的文件,内容如下: :::
{"description": "My wiki","plugins": ["tiddlywiki/tiddlyweb","tiddlywiki/filesystem"],"themes": ["tiddlywiki/vanilla","tiddlywiki/snowwhite"]}
:::danger
创建一个,名为 “tiddlers” 的子目录 (即 C:\MyStuff\wiki\tiddlers)
在其中创建一个名为 C:\MyStuff\wiki\tiddlers\config-tiddlyweb-host.tid 的文件,内容如下: :::
title: $:/config/tiddlyweb/hosttext: $protocol$//$host$/MyApp/
:::danger
- (有关 HttpPlatformHandler 配置字段的详细信息,请参考微软的文档
- 在 C:/MyStuff 目录下运行 npm install 命令
:::
:::success
4. 在 IIS 中设置应用程序
- 在 Windows 中,运行 IIS 管理程序 (使用 “开始” 功能表运行 inetmgr.exe)
- 在左侧的 连接 栏中找到该服务器,然后按一下 “显示三角形” 显示其内容 *
- 打开 “网站” 文件夹
- 在默认网站项目点击右键,然后从功能表中选择添加应用程序。
- 在对话框中输入以下信息:
- Alias: MyApp
- Physical path: C:\MyStuff
-
5. 测试应用程序
在浏览器中访问 http://localhost/MyApp/ 来测试应用程序。 ::: :::tips
注意事项
如果需要身份验证,请在 web.config 中的 —listen 命令中指定用户名和密码。例如:
- 复制到剪贴板
- 注意在非字母、数字的密码前后,需使用双引号, 并将其 HTML 编码为 "
- 如果更改了 web.config 档中的设置,或者修改了应用程序代码,则需要使用 IIS 管理程序,重新启动服务器 :::
