Discourse 部署笔记
环境参数
操作系统: | Ubuntu 18.04 LTS x64 |
内存: | 最低 1GB 推荐 2GB 以上 |
安装 Docker
wget -qO- https://get.docker.com/ | sh
安装 Discourse
创建目录 /var/discourse
,克隆 Discourse docker 官方镜像。
sudo -s
mkdir /var/discourse
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
准备 E-mail 服务
特别注意:Discourse 的注册和通知功能依赖 E-mail 服务,务必提前准备好可用的 E-mail 服务,否则成功安装也无法正常运转。
应该优先考虑使用独立的 E-mail 服务,免费邮箱的 SMTP 服务的可靠性不理想。
推荐的 E-mail 推送服务:https://github.com/discourse/discourse/blob/master/docs/INSTALL-email.md
准备域名
特别注意:Discourse 无法通过 IP 访问,必须绑定独立域名。
推荐绑定的二级域名(参考任选):forum.example.com
、discourse.example.com
、talk.example.com
编辑 Discourse 配置文件
运行安装工具:
./discourse-setup
交互式回答以下问题:
Hostname for your Discourse? [discourse.example.com]:
Email address for admin account(s)? [me@example.com,you@example.com]:
SMTP server address? [smtp.example.com]:
SMTP port? [587]:
SMTP user name? [user@example.com]:
SMTP password? [pa$$word]:
Let's Encrypt account email? (ENTER to skip) [me@example.com]:
安装工具会根据提供的信息生成一个 app.yml
配置文件并尝试启动程序,大概需要 2~8 分钟的初始设置时间。修改配置信息可以再次运行 ./discourse-setup
或手动编辑 /containers/app.yml
配置文件并执行 ./launcher
让新的配置生效。
成功启动即可通过绑定的域名 discourse.example.com
访问 Discourse 程序了!
注册管理员账号
使用安装设置的管理员 E-mail 注册管理员账号。如果没有收到激活邮件,则检查 /var/discourse/shared/standalone/log/rails/production.log
或查阅 Email Troubleshooting checklist。
Post-Install Maintenance
- We strongly suggest you turn on
automatic security updates
for your OS. In Ubuntu use thedpkg-reconfigure -plow unattended-upgrades
command. - If you are using a password and not a SSH key, be sure to enforce a strong root password. In Ubuntu use the
apt-get install libpam-cracklib
package. We also recommendapt-get install fail2ban
which will default block any IP addresses for 10 minutes that attempt more than 3 password retries. - If you need or want a default firewall, turn on ufw.