安装 discourse

安装 discourse 到 ubuntu 14.04。详见 Set up Discourse in the cloud in under 30 minutes

安装 docker

命令:wget -qO- https://get.docker.com/ | sh

安装 discourse

1
2
3
4
sudo -s
mkdir /var/discourse
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse

配置 app.xml

app 的名称自取,此处直接命名为 app。

  • 拷贝默认配置文件
1
cp samples/standalone.yml containers/app.yml
  • 配置 ruby 国内源

在 app.yml 添加一行 templates/web.china.template.yml

1
2
3
4
5
6
templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/web.template.yml"
- "templates/web.ratelimited.template.yml"
- "templates/web.china.template.yml"
  • 配置默认端口

这里改默认端口为 10080。

1
2
3
expose:
- "10080:80" # http
- "10443:443" # https

  • 配置邮箱

用于 administrator 的激活邮件。至关重要!
此处用的 163 邮箱。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
env:
LANG: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en

## How many concurrent web requests are supported? Depends on memory and CPU cores.
## will be set automatically by bootstrap based on detected CPUs, or you can override
#UNICORN_WORKERS: 3

## TODO: The domain name this Discourse instance will respond to
## 此处我个人直接配置 IP
DISCOURSE_HOSTNAME: '172.18.xxx.xxx'

## Uncomment if you want the container to be started with the same
## hostname (-h option) as specified above (default "$hostname-$config")
#DOCKER_USE_HOSTNAME: true

## TODO: List of comma delimited emails that will be made admin and developer
## on initial signup example 'user1@example.com,user2@example.com'
## 管理员邮箱列表,多个以逗号隔开
DISCOURSE_DEVELOPER_EMAILS: 'your@163.com'

## TODO: The SMTP mail server used to validate new accounts and send notifications
DISCOURSE_SMTP_ADDRESS: 'smtp.163.com' # required
DISCOURSE_SMTP_PORT: 25 # (optional, default 587)
DISCOURSE_SMTP_USER_NAME: 'your@163.com' # required
DISCOURSE_SMTP_PASSWORD: 'password' # required, WARNING the char '#' in pw can cause problems!
DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

配置邮件的默认发送者:

##- exec: rails r "SiteSetting.notification_email...# 号去掉,并把邮箱设置为你自己的邮箱。

1
2
3
4
5
6
7
## Any custom commands to run after building
run:
- exec: echo "Beginning of custom commands"
## If you want to set the 'From' email address for your first registration, uncomment and change:
## After getting the first signup email, re-comment the line. It only needs to run once.
- exec: rails r "SiteSetting.notification_email='your@163.com'"
- exec: echo "End of custom commands"

调试邮件发送情况,查看 Log 文件 shared/standalone/log/rails/production.log。一个样例:

1
2
3
4
5
6
Sent mail to sunnogo@163.com (20111.6ms)
Job exception: end of file reached


Sent mail to sunnogo@163.com (20241.3ms)
Job exception: end of file reached

编译、启动 app

bootstrap 或 rebuild 的时间很长,特别是第一次运行时,要下载多个组件。

1
2
sudo ./launcher bootstrap app
sudo ./launcher start app

即可登陆你的 discourse 论坛开始配置了。