discourse网站搭建

环境准备

  1. ubuntu18
  2. 设置一个域名,例如discourse.example.com,添加NDS使其能够解析该域名
  3. sudo apt-get install docker.io ruby git
  4. 等会需要一个邮箱服务器,这里介绍用qq邮箱普通用户每天100封,选取一个qq邮箱名,获取授权码(SMTP的密码)

    附:邮箱测试http://tool.chacuo.net/mailserversend
  5. 如果想搭建一个https网站,准备一份网站的可信证书(.crt和.key),或者自签名证书也可以

安装

  1. 建议全程用root权限

    sudo -s
    git clone https://github.com/discourse/discourse_docker.git /home/discourse
    cd /home/discourse
    
  2. 如果是https网站,则替换成你的证书名字vim ./templates/web.letsencrypt.ssl.template.yml:111-125,否则在containers/app.yml中注释以下两行

    templates:
    - "templates/postgres.template.yml"
    - "templates/redis.template.yml"
    - "templates/web.template.yml"
    - "templates/web.ratelimited.template.yml"
    ## Uncomment these two lines if you wish to add Lets Encrypt (https)
    # - "templates/web.ssl.template.yml"
    # - "templates/web.letsencrypt.ssl.template.yml"
    
  3. 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邮件服务器地址,qq邮箱填写]
    SMTP port? [587]: [SMTP邮件服务器端口]
    SMTP user name? [user@example.com]: [论坛自动发信邮箱账号,qq邮箱名]
    SMTP password? [pa$$word]: [论坛自动发信邮箱账号的密码,qq邮箱授权码]
    Let's Encrypt account email? (ENTER to skip) [me@example.com]: [自动更新证书的通知邮箱地址]
    
  4. 如果是https网站,则将你的证书放到/var/discourse/shared/standalone/ssl目录下

  5. launcher restart app
    现在可以访问域名

    尝试注册管理员,注册时使用管理员邮箱,自动注册管理员用户

  6. launcher enter app
    如果没有创建好管理员,则用命令创建管理员

    rake admin:create
    

    现在你的邮箱系统可能还没有设置发送邮箱地址,需要用管理员登录网站后,设置notification email

    现在用户就可以正常注册了

参考文章

[1] 用全站 CDN 部署 Discourse 论坛

[2] 在阿里云上搭建Discourse轻论坛教程

[3] 在同一台机器上运行 Discourse 和其他站点

[4] Discourse中文论坛

原文地址:https://www.cnblogs.com/macrored/p/13173340.html