2017-02-12 15:51:26 +08:00
|
|
|
# 部署
|
|
|
|
|
|
|
|
和 GitBook 生成的文档一样,我们可以直接把文档网站部署到 GitHub Pages 或者 VPS 上。
|
|
|
|
|
2017-02-13 22:43:58 +08:00
|
|
|
## GitHub Pages
|
2017-02-12 15:51:26 +08:00
|
|
|
|
|
|
|
GitHub Pages 支持从三个地方读取文件
|
|
|
|
- `docs/` 目录
|
|
|
|
- master 分支
|
|
|
|
- gh-pages 分支
|
|
|
|
|
|
|
|
我们推荐直接将文档放在 `docs/` 目录下,在设置页面开启 **GitHub Pages** 功能并选择 `master branch /docs folder` 选项。
|
|
|
|
|
|
|
|
![github pages](_images/deploy-github-pages.png)
|
|
|
|
|
2017-02-12 20:12:36 +08:00
|
|
|
!> 可以将文档放在根目录下,然后选择 **master 分支** 作为文档目录。
|
2017-02-12 15:51:26 +08:00
|
|
|
|
2017-10-12 00:36:23 +08:00
|
|
|
|
|
|
|
## GitLab Pages
|
|
|
|
|
|
|
|
If you are deploying your master branch, include `.gitlab-ci.yml` with the following script:
|
|
|
|
|
|
|
|
?> The `.public` workaround is so `cp` doesn't also copy `public/` to itself in an infinite loop.
|
|
|
|
|
|
|
|
``` YAML
|
|
|
|
pages:
|
|
|
|
stage: deploy
|
|
|
|
script:
|
|
|
|
- mkdir .public
|
|
|
|
- cp -r * .public
|
|
|
|
- mv .public public
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- public
|
|
|
|
only:
|
|
|
|
- master
|
|
|
|
```
|
|
|
|
|
|
|
|
!> You can replace script with `- cp -r docs/. public`, if `./docs` is your Docsify subfolder.
|
|
|
|
|
|
|
|
|
2017-02-13 22:43:58 +08:00
|
|
|
## VPS
|
2017-02-12 15:51:26 +08:00
|
|
|
|
2017-02-13 22:43:58 +08:00
|
|
|
和部署所有静态网站一样,只需将服务器的访问根目录设定为 `index.html` 文件。
|
2017-02-12 15:51:26 +08:00
|
|
|
|
|
|
|
例如 nginx 的配置
|
|
|
|
|
|
|
|
```nginx
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
server_name your.domain.com;
|
|
|
|
|
|
|
|
location / {
|
|
|
|
alias /path/to/dir/of/docs;
|
|
|
|
index index.html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|