精简文档 (#808)

以及 atfd 路由标题小格式
This commit is contained in:
Henry Wang
2018-09-28 19:33:52 +01:00
committed by DIYgod
parent 56529022d6
commit 3c227a6e2b
3 changed files with 73 additions and 251 deletions

View File

@@ -4,58 +4,27 @@ sidebar: auto
# Deployment
RSSHub provides painless deployment, you may open an [issue](https://github.com/DIYgod/RSSHub/issues/new) if you believe you have encountered a problem not listed [here](https://github.com/DIYgod/RSSHub/issues), the community will try to sort it out asap.
RSSHub provides a painless deployment process if you are equipped with basic programming knowledge, you may open an [issue](https://github.com/DIYgod/RSSHub/issues/new) if you believe you have encountered a problem not listed [here](https://github.com/DIYgod/RSSHub/issues), the community will try to sort it out asap.
The deployment may involve the followings:
1. Command line interface
1. [Git](https://git-scm.com/)
1. [Node.js >= 8.0.0](https://nodejs.org/)
1. [npm](https://www.npmjs.com/get-npm) or [yarn](https://yarnpkg.com/zh-Hans/docs/install)
Deploy for public access may require:
1. [Nginx](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/)
1. [Docker](https://www.docker.com/get-started) or [docker-compose](https://docs.docker.com/compose/install/)
1. [Redis](https://redis.io/download)
1. [Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs)
1. [Google App Engine](https://cloud.google.com/appengine/)
## Manual Deployment
Manually deploy a new `RSSHub` instance to a location of your choice.
## System requirement
Please ensure you have installed both [Git](https://git-scm.com/) and [Node.js >= 8.0.0](https://nodejs.org/).
### Install Git
::: tip
Entering `git` to check whether Git is already installed
Use `cmd` for windows, use `terminal` for UNIX-based OS including macOS.
```bash
$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
...
```
:::
- WindowsDownload Git [from git's official website](https://git-scm.com/downloads).
- macOSUse [Homebrew](https://brew.sh/) `$ brew install git` or [download from git's official website](https://git-scm.com/download/mac).
- UNIX: your package manager `$ sudo apt-get install git`.
### Install Node.JS
#### Windows
Windows users please download [from node's official website](https://nodejs.org/zh-cn/). During the installation, please check `Add to PATH` option.
#### UNIX-based
The easiest way to install NodeJS is using [nvm](https://github.com/creationix/nvm).
Install `nvm`
```bash
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
```
Upon completion please restart your terminal to install `Node.js`.
```bash
$ nvm install node
```
### Download RSSHub
Execute the following commands to download the source code
@@ -65,24 +34,20 @@ $ git clone https://github.com/DIYgod/RSSHub.git
$ cd RSSHub
```
Execute the following commands to the dependencies
Execute the following commands to install dependencies
Using `npm`
```bash
$ npm install
```
::: tip
[Yarn](https://yarn.bootcss.com/) is recommended over `npm` for its performance and stability
Use `Yarn` simplifies the dependency installation process
Or `yarn`
```bash
$ yarn
```
:::
### Launch
Under `RSSHub`'s root directory, execute the following commands to launch
@@ -91,8 +56,20 @@ Under `RSSHub`'s root directory, execute the following commands to launch
$ npm start
```
Or
```bash
$ yarn start
```
Visit [http://127.0.0.1:1200/](http://127.0.0.1:1200/), and enjoy it! ✅
::: tip tip
Refer to our [Guide](https://docs.rsshub.app/) for usage. Replace `https://rsshub.app/` with `http://localhost:1200` in any route example to see the effect.
:::
### Update
Under `RSSHub`'s directory, execute the following commands to pull the latest source code for `RSSHub`
@@ -121,66 +98,16 @@ To configure more options please refer to [Settings](#Settings).
By default, `RSSHub` caches everything for 5 minutes in RAM. Redis support is built-in.
::: tip
::: tip tips
Unless you are expecting high traffic or deploying in cluster-mode, Redis is not necessary.
:::
#### Install Redis
**Windows**
Please download Redis for Windows from [Redis' github](https://github.com/MicrosoftArchive/redis/releases).
Under your installation directory, execute the following commands to start Redis.
```bash
$ redis-server redis.windows.conf
```
**MacOS**
Use [Homebrew](https://brew.sh/) to install Redis.
```bash
$ brew install redis
```
Execute the following commands to start Redis.
```bash
$ brew services start redis
```
**UNIX-based**
Use your package manager to install Redis.
```bash
# apt
$ sudo apt install redis-server
# yum
$ sudo yum install redis
```
Execute `$ redis-server` to start Redis.
#### Enable RSSHub to Redis as the caching backend
Change `CACHE_TYPE` to `redis`, RSSHub will try to connect to `redis://localhost:6379/`. For changing the target address, please refer to [Settings](#Settings).
## Docker Deployment
Docker is the most popular containerization technology, it simplifies the deployment process down to one line of code.
### Install Docker
Please refer to [Docker's official guide](https://docs.docker.com/engine/installation/)
### Deployment
Execute the following command to pull RSSHub's docker image.
```bash
@@ -201,21 +128,6 @@ Execute the following command to stop `RSSHub`.
$ docker stop rsshub
```
### Update
Execute the following command to pull the latest `RSSHub` docker image.
```bash
# stop the current rsshub container
$ docker stop rsshub
# delete the existing rsshub container
$ docker rm rsshub
# pull the latest rsshub image
$ docker pull diygod/rsshub
```
### Configuration
The simplest way to configure RSSHub container is via system environment variables.
@@ -228,9 +140,7 @@ $ docker run -d --name rsshub -p 1200:1200 -e CACHE_EXPIRE=3600 -e GITHUB_ACCESS
To configure more options please refer to [Settings](#Settings).
### Docker-compose Deployment
[docker-compose](https://docs.docker.com/compose/overview/) simplifies multi-container deployment process
### docker-compose Deployment
1. Create a docker volume to persist Redis caches

View File

@@ -4,58 +4,27 @@ sidebar: auto
# 部署
部署 RSSHub 非常简单, 如果您在部署过程中遇到无法解决的问题请到 [issues](https://github.com/DIYgod/RSSHub/issues) 寻找类似的问题或 [向我们提问](https://github.com/DIYgod/RSSHub/issues/new), 我们会尽快给您答复.
部署 RSSHub 需要基本的计算机编程常识, 如果您在部署过程中遇到无法解决的问题请到 [issues](https://github.com/DIYgod/RSSHub/issues) 寻找类似的问题或 [向我们提问](https://github.com/DIYgod/RSSHub/issues/new), 我们会尽快给您答复.
部署涉及到以下基本编程常识:
1. 命令行操作
1. [Git](https://git-scm.com/)
1. [Node.js >= 8.0.0](https://nodejs.org/)
1. [npm](https://www.npmjs.com/get-npm) 或 [yarn](https://yarnpkg.com/zh-Hans/docs/install)
部署到可外网访问则可能涉及到:
1. [Nginx](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/)
1. [Docker](https://www.docker.com/get-started) 或 [docker-compose](https://docs.docker.com/compose/install/)
1. [Redis](https://redis.io/download)
1. [Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs)
1. [Google App Engine](https://cloud.google.com/appengine/)
## 手动部署
部署 `RSSHub` 最直接的方式, 您可以按照以下步骤将 `RSSHub` 部署在您的电脑、服务器或者其他任何地方.
### 在安装之前
在安装 RSSHub 之前, 请确保您的电脑中已经安装了 [Git](https://git-scm.com/) 和 [Node.js >= 8.0.0](https://nodejs.org/).
### 安装 Git
::: tip 提示
首先您应该输入 `git`, 看看系统有没有安装 Git:
windows 打开 `cmd`, macOS 打开`终端(terminal)`.
```bash
$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
...
```
:::
- Windows: 从 Git 官网直接[下载安装程序](https://git-scm.com/downloads).
- MacOS: 使用 [Homebrew](https://brew.sh/) `$ brew install git` 或者[下载安装程序](https://git-scm.com/download/mac).
- Linux: 使用您的包管理器安装例如 `$ sudo apt-get install git`.
### 安装 Node.JS
#### Windows
Windows 用户请 [下载安装程序](https://nodejs.org/zh-cn/). 安装时, 请勾选`Add to PATH`选项.
#### MacOS & Linux
安装 NodeJS 的最佳方式是使用 [nvm](https://github.com/creationix/nvm).
安装 `nvm`
```bash
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
```
安装完成后, 重启终端并执行下列命令即可安装 `Node.js`.
```bash
$ nvm install node
```
### 安装 RSSHub
首先是下载 `RSSHub` 的源码, 请执行下列命令.
@@ -67,15 +36,13 @@ $ cd RSSHub
下载完成后, 需要安装依赖.
使用 `npm`
```bash
$ npm install
```
::: tip 提示
推荐使用 [Yarn](https://yarn.bootcss.com/) , `Yarn``npm` 更快更稳定.
使用 `Yarn` 安装依赖时只需要键入
`yarn`
```bash
$ yarn
@@ -93,8 +60,20 @@ $ yarn
$ npm start
```
```bash
$ yarn start
```
在浏览器中打开 [http://127.0.0.1:1200/](http://127.0.0.1:1200/), enjoy it! ✅
::: tip tip
详细使用说明参照 [指南](https://docs.rsshub.app/). 替换所有路由例子中的 `https://rsshub.app/``http://localhost:1200` 即可正常使用.
:::
### 更新
`RSSHub` 文件夹中运行下面的命令就从 github 仓库拉取最新版本.
@@ -121,7 +100,7 @@ macOS & Linux 运行 `$ PORT=1000`
### 使用 Redis 数据库缓存
RSSHub 默认会有 5 分钟的缓存, 默认这个缓存是存放在内存中的. RSSHub 还支持 Redis 数据库缓存.
RSSHub 默认会有 5 分钟的缓存, 默认缓存是存放在内存中的. RSSHub 还支持 Redis 数据库缓存.
::: tip 提示
@@ -129,59 +108,9 @@ RSSHub 默认会有 5 分钟的缓存, 默认这个缓存是存放在内存中
:::
#### 安装 Redis
**Windows**
安装 Redis on Windows 直接[下载安装程序](https://github.com/MicrosoftArchive/redis/releases).
在安装目录中运行下面的命令启动 Redis.
```bash
$ redis-server redis.windows.conf
```
**MacOS**
使用 [Homebrew](https://brew.sh/) 安装 Redis.
```bash
$ brew install redis
```
再运行下面的命令启动 Redis.
```bash
$ brew services start redis
```
**Linux**
使用您的包管理器安装 Redis.
```bash
# apt
$ sudo apt install redis-server
# yum
$ sudo yum install redis
```
然后运行 `$ redis-server` 启动 Redis.
#### 启用 Redis 数据库缓存
修改配置项 `CACHE_TYPE``redis`, RSSHub 将使用默认地址 `redis://localhost:6379/` 连接 Redis, 如果需要修改地址请看 [应用配置](#应用配置).
## 部署到 Docker
Docker 属于 Linux 容器的一种封装, 提供简单易用的容器使用接口. 它是目前最流行的 Linux 容器解决方案.
### 安装 Docker
官方网站上有各种环境下的 [安装指南](https://docs.docker.com/engine/installation/)
### 部署
## 使用 Docker 部署
运行下面的命令下载 RSSHub 镜像.
@@ -203,24 +132,9 @@ $ docker run -d --name rsshub -p 1200:1200 diygod/rsshub
$ docker stop rsshub
```
### 更新
您可以使用下面的命令来更新镜像.
```bash
# 先关闭 rsshub
$ docker stop rsshub
# 删除现有的容器
$ docker rm rsshub
# 下载最新版的 rsshub 镜像
$ docker pull diygod/rsshub
```
### 添加配置
配置运行在 docker 中的 RSSHub, 最便利的方法是使用环境变量.
配置运行在 docker 中的 RSSHub, 最便利的方法是使用 docker 环境变量.
以设置缓存时间为 1 小时举例, 只需要在运行时增加参数: `-e CACHE_EXPIRE=3600`
@@ -232,8 +146,6 @@ $ docker run -d --name rsshub -p 1200:1200 -e CACHE_EXPIRE=3600 -e GITHUB_ACCESS
### 使用 docker-compose 部署
[docker-compose](https://docs.docker.com/compose/overview/) 是用来运行多容器 Docker 应用的小工具, 可以简化配置部署过程:
1. 创建 volume 持久化 Redis 缓存
```bash
@@ -405,7 +317,7 @@ gcloud app deploy
- `TELEGRAM_TOKEN`: Telegram 机器人 token
- `github`: [申请地址](https://github.com/settings/tokens)
- `gitHhub`: [申请地址](https://github.com/settings/tokens)
- `GITHUB_ACCESS_TOKEN`: GitHub Access Token