欢迎光临
我们一直在努力

开源社区论坛平台 discourse 部署

  1. 平台概述

Discourse是一款基于Web的开源讨论软件,旨在提供一种更为现代、灵活且功能丰富的在线社区构建工具。它采用Ruby on Rails和Ember.js开发,注重用户体验和深度对话。

  1. 技术特点

多层架构:使用前后端分离的设计,前端由Ember.js框架驱动,后端则依赖于Ruby on Rails。
RESTful API:通过RESTful API进行通信,使得与其他系统的集成变得简单易行。
实时更新:利用WebSockets实现即时的消息推送,让讨论保持动态且实时。
数据库支持:PostgreSQL作为主要的数据存储,提供高效稳定的服务;Redis用于缓存和队列管理,提高性能并减少数据库负载。
安全性:HTTPS默认启用,确保数据传输的安全性。

  1. 功能与应用

用户权限控制:提供精细的访问权限设置,保护用户隐私。
话题导向:以话题为中心的讨论模式,避免传统论坛的混乱线程。
移动友好:响应式设计,无论是在桌面还是移动端,都能提供优秀的浏览体验。
一体化用户体验:内置私信、关注、点赞等功能,打造完整的社区参与感。
多语言支持:内置多语言包,方便全球用户使用。
易于部署和维护:提供一键部署脚本和详细的文档,对运维友好。
插件支持:提供丰富的官方和社区主题,以及各种插件支持,如Chatbot(聊天机器人)和Data Explorer(用于SQL分析)等。

  1. 适用场景

适用于在线社区、知识分享和产品支持等多种场景。无论是企业、教育机构还是开源项目,都可以用它来建立活跃的用户交流平台。

部署

  • 创建云主机

创建新的云服务器,可以在博客中找到合适的云主机:
系统Ubuntu Server/Debian 都可以,至少需要一个具有现代内核版本的64位Linux操作系统。
默认的1GB RAM对于小型Discourse社区来说很好。我们建议大型社区使用2 GB RAM。
对于大多数中国用户来说,建议备案选择阿里云腾讯云等国内大厂。或者选择一个在地理上离你的受众更近的地区。
解析您的域名discuse.example.com到云主机ip

  • 安装Docker
sudo apt install docker.io
sudo apt install git
  • 获取 Discourse
sudo -s
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
chmod 700 containers

使用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]: 
Optional Maxmind License key () [xxxxxxxxxxxxxxxx]:

使用自定义配置文件安装

vim /var/discourse/containers/app.yml

贴入下面配置

## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/cloudflare.template.yml"
  ## Uncomment the next line to enable the IPv6 listener
  #- "templates/web.ipv6.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"
  - "templates/web.socketed.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
#expose:
#  - "80:80"   # http
#  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "256MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: 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: 2

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: ug.cx

  ## 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: 'hi@ug.cx'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: smtp.qiye.aliyun.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: hi@ug.cx
  DISCOURSE_SMTP_PASSWORD: .....
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: ug.cx
  DISCOURSE_NOTIFICATION_EMAIL: hi@ug.cx

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: hi@ug.cx

  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

  ## The maxmind geolocation IP account ID and license key for IP address lookups
  ## see https://meta.discourse.org/t/-/173941 for details
  DISCOURSE_MAXMIND_ACCOUNT_ID: ...
  DISCOURSE_MAXMIND_LICENSE_KEY: ...

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## 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='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

配置文件 修改备注

多站点部署

#  - "templates/web.ssl.template.yml"
#  - "templates/web.letsencrypt.ssl.template.yml"
#expose:
#  - "80:80"   # http
#  - "443:443" # https  

- "templates/web.socketed.template.yml"  

全站cloudflare 获取ip

- "templates/cloudflare.template.yml"

根据 https://meta.discourse.org/t/-/173941 获得MAXMIND id key

执行 ./launcher rebuild app 完成安装

Nginx 配置文件

server
{
    listen 80;
    listen 443 ssl http2 ;
    listen [::]:443 ssl http2 ;
    listen [::]:80;
    server_name ug.cx;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/ug.cx;
    #CERT-APPLY-CHECK--START
    # 用于SSL证书申请时的文件验证相关配置 -- 请勿删除
    include /www/server/panel/vhost/nginx/well-known/ug.cx.conf;
    #CERT-APPLY-CHECK--END
location / {
                proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;

}
    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate    /www/server/panel/vhost/cert/ug.cx/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/ug.cx/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;

    #SSL-END

    access_log  /www/wwwlogs/ug.cx.log;
    error_log  /www/wwwlogs/ug.cx.error.log;
}

赞(0)
未经允许不得转载:主机推介 » 开源社区论坛平台 discourse 部署

声明: 博客仅为分享信息绝非推荐,网站不参与交易绝非中介,内容均仅代表个人观点绝非权威,读者请自行考虑后入手并自担风险!一分钱一分货仍是恒久不变之真理,未成年读者(包括生理和心理)请在监护人陪同下访问本站!本文由( )原创编译,转载请保留链接: >鄙视无耻复制行为!
关于隐私: 非全职打理博客,所有评论不保证审核时间进度,我有义务保证您的个人信息不经由赵容部落透露给任何第三方,随意或虚假邮箱评论会自动进入垃圾箱无法展示和给您回应.
关于安全: 任何IDC都有倒闭和跑路的可能,出口线路更不可控,月付和备份是您的最佳选择,请保持良好的、有规则的备份习惯.