Discourse程序基于Ruby on Rails, Ember.js, 以及PostgreSQL, 完全免费开源。它拥有丰富的功能,强劲的性能,高稳定性与安全性,以及可以高度自定义的界面。

官方推荐使用docker安装,借助Docker,我们可以在一个简单的容器中为您提供经过完全优化的Discourse配置,以及基于Web的GUI,使您只需单击一个按钮即可轻松升级到Discourse的新版本。这篇文章还是基于宝塔面板来安装。

宝塔服务器面板,一键全能部署及管理,送你3188元礼包,点我领取https://www.bt.cn/?invite_code=MV9ub2NxdmI=

注意,本教程的系统环境为Centos7

1、简介

项目:https://github.com/discourse/discourse

官网:https://www.discourse.org/

演示:https://try.discourse.org/

2、准备

1)硬件需求:

  • 推荐双核vps
  • 最低1 GB RAM(带有swap)
  • 与Docker兼容的64位Linux系统
  • 最小10 GB磁盘空间

2)其他准备

  • 宝塔面板
  • docker管理器(软件商店里安装)
  • 准备一个域名

3、留出80和443端口

安装需要80和443端口,所以最好是在一个全新的宝塔环境里安装该该程序。宝塔面板默认占用了80端口,我们需要稍微修改一下。

1)路径:/www/server/panel/vhost/nginx,把里面的文件端口改为其他,比如808。看图:

 

注意,这里面的2个默认文件都需要编辑默认的80端口。

4、部署

1)下载程序

  1. git clone https://github.com/discourse/discourse_docker.git /var/discourse
  2. cd/var/discourse

2)编辑app.yml

 

  1. 执行命令 cp samples/standalone.yml containers/app.yml复制配置文件到containers目录
  2. 并且根据自己环境配置app.yml配置文件,修改以下内内容

具体编辑如下:

  1. expose:
  2. - "80:80" # http 默认80端口,如果需要修改可以改为类似8080:80的形式
  3. - "443:443" # https
  4.  
  5. params:
  6. db_default_text_search_config: "pg_catalog.english"
  7.  
  8. ## Set db_shared_buffers to a max of 25% of the total memory.
  9. ## will be set automatically by bootstrap based on detected RAM, or you can override
  10. db_shared_buffers: "2048MB"
  11.  
  12. ## can improve sorting performance, but adds memory usage per-connection
  13. #db_work_mem: "40MB"
  14.  
  15. ## Which Git revision should this container use? (default: tests-passed)
  16. #version: tests-passed
  17.  
  18. env:
  19. LC_ALL:zh_CN.UTF-8
  20. LANG:zh_CN.UTF-8
  21. LANGUAGE:zh_CN.UTF-8
  22. # DISCOURSE_DEFAULT_LOCALE: en
  23.  
  24. ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  25. ## will be set automatically by bootstrap based on detected CPUs, or you can override
  26. UNICORN_WORKERS: 8
  27.  
  28. ## TODO: The domain name this Discourse instance will respond to
  29. ## Required. Discourse will not work with a bare IP number.
  30. DISCOURSE_HOSTNAME:dd.qixi.ng#这里是域名,不要忘记填写。
  31.  
  32. ## Uncomment if you want the container to be started with the same
  33. ## hostname (-h option) as specified above (default "$hostname-$config")
  34. #DOCKER_USE_HOSTNAME: true
  35.  
  36. ## TODO: List of comma delimited emails that will be made admin and developer
  37. ## on initial signup example 'user1@example.com,user2@example.com'
  38. DISCOURSE_DEVELOPER_EMAILS: 'daniao@163.com' #这里修改为自己的
  39.  
  40. ## TODO: The SMTP mail server used to validate new accounts and send notifications
  41. # SMTP ADDRESS, username, and password are required
  42. # WARNING the char '#' in SMTP password can cause problems!
  43. #这下面都是邮箱配置,根据需要来。
  44. DISCOURSE_SMTP_ADDRESS:smtp.163.com
  45. DISCOURSE_SMTP_PORT: 587
  46. DISCOURSE_SMTP_USER_NAME:daniao
  47. DISCOURSE_SMTP_PASSWORD: "123456"
  48. #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
  49. DISCOURSE_SMTP_DOMAIN:daniao.org
  50. DISCOURSE_NOTIFICATION_EMAIL:admin@daniao.org
  51.  
  52. ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  53. LETSENCRYPT_ACCOUNT_EMAIL:me@example.com
  54.  

 

3)启动安装

在程序根目录,输入以下命令开始安装。

  1. ./discourse-setup

4)在提示时回答以下问题例如:

  1. Hostname foryourDiscourse? [discourse.example.com]:
  2. Emailaddressforadmin account(s)? [me@example.com,you@example.com]:
  3. SMTP server address? [smtp.example.com]:
  4. SMTP port? [587]:
  5. SMTP user name? [user@example.com]:
  6. SMTP password? [pa$$word]:
  7. Let's Encrypt account email? (ENTER to skip) [me@example.com]:

之后,我们需要等2到8分钟的时间安装程序!!

5)如果需要更换域名,或者其他,你需要编辑app.yml文件。编辑好后,输入以下命令让修改生效。

  1. ./launcher rebuild app

5、安装向导

1)上面的程序安装完成后,打开你的域名便可以访问了。

 

2)注册新帐户并成为管理员,使用引导前输入的电子邮件地址之一注册一个新的管理员帐户。

 

3)注册成功,要验证邮箱,所以前面的smtp一定要配置正确。

 

4)注册管理员帐户后,安装向导将启动并指导您完成Discourse的基本配置。

 

5)完成设置向导后,您应该看到Staff主题和README FIRST:Admin快速入门指南

 

6、升级版本

随着新版本的Discourse的发布,您将收到电子邮件提醒。请保持最新状态以获取最新功能和安全修复程序。要将Discourse升级到最新版本,请/admin/upgrade在浏览器中访问,然后单击“升级”按钮。

launcher命令/var/discourse可用于各种维护,如下:

  1. Usage:launcher COMMAND CONFIG[--skip-prereqs] [--docker-args STRING]
  2. Commands:
  3. start: Start/initialize a container
  4. stop: Stopa running container
  5. restart: Restarta container
  6. destroy: Stop andremove a container
  7. enter: Usensenter togeta shellintoa container
  8. logs: ViewtheDockerlogsfora container
  9. bootstrap: Bootstrapa containerforthe config based on atemplate
  10. rebuild: Rebuilda container(destroy old,bootstrap,startnew)
  11. cleanup: Removeall containers that have stoppedfor > 24hours
  12.  
  13. Options:
  14. --skip-prereqsDon't check launcher prerequisites
  15. --docker-args Extra arguments to pass when running docker

举个列子:

  1. ./launcher rebuild app

7、最后

上面的app就是容器的名称,看图:

用宝塔来安装还是有点繁琐的,你如果用80端口,还需要修改宝塔默认占用的80端口。

参考:

https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md

https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247

分类: 建站教程 标签: 部署教程宝塔面板教程Discourse

评论

暂无评论数据

暂无评论数据

目录