溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

開(kāi)源論壇之discourse搭建

發(fā)布時(shí)間:2020-07-05 12:11:37 來(lái)源:網(wǎng)絡(luò) 閱讀:16288 作者:dl528888 欄目:編程語(yǔ)言

快2個(gè)月沒(méi)寫(xiě)博客,最近一個(gè)是忙著開(kāi)發(fā)docker平臺(tái),另外一個(gè)是接手了公司私有云,所以比較忙。

公司最近有個(gè)新項(xiàng)目,想弄個(gè)技術(shù)的問(wèn)答論壇,挑選了半天,選擇ruby語(yǔ)言的discourse,這個(gè)是完全開(kāi)源的,界面簡(jiǎn)潔,支持中文,有管理后臺(tái),滿足需求。

discourse的地址是https://www.discourse.org

界面如下

開(kāi)源論壇之discourse搭建下面是安裝過(guò)程

系統(tǒng)環(huán)境

官方推薦使用ubuntu,并且安裝的程序也是支持ubuntu系統(tǒng),docker安裝模式,所以我選擇了云主機(jī)ubuntu 14.04系統(tǒng),discourse是最新的1.5.0版本。

安裝地址可以參考https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md

1、更新源

apt-get update

2、安裝依賴軟件

apt-get install ruby git

3、安裝docker

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

安裝完成后可以使用docker version查看

root@i-chxjfvpy:/tmp# docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:12:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:12:04 UTC 2015
 OS/Arch:      linux/amd64

當(dāng)前我的是1.9.1版本

4、安裝discourse

mkdir /data/discourse
git clone https://github.com/discourse/discourse_docker.git /data/discourse
cd /data/discourse
cp samples/standalone.yml containers/app.yml

ps:默認(rèn)官方是放入/var目錄里,我這里放入/data是因?yàn)檫@個(gè)目錄是我云主機(jī)掛載的盤(pán)

root@i-chxjfvpy:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        18G  1.8G   15G  11% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            3.9G  8.0K  3.9G   1% /dev
tmpfs           799M  412K  799M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            3.9G     0  3.9G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/vdb1       193G   60M  183G   1% /data

5、修改discourse配置

root@i-chxjfvpy:/data/discourse# grep -v "^  #" containers/app.yml |grep -v "^#"|sed '/^$/d'
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.china.template.yml"
expose:
  - "80:80"   # fwd host port 80   to container port 80 (http)
  - "2222:22" # fwd host port 2222 to container port 22 (ssh)
params:
  db_default_text_search_config: "pg_catalog.english"
  db_shared_buffers: "2GB"
  db_work_mem: "40MB"
env:
  LANG: en_US.UTF-8
  UNICORN_WORKERS: 6
  DISCOURSE_DEVELOPER_EMAILS: 'xxx@163.com'
  DISCOURSE_HOSTNAME: 'discuss.xxx.net'
  DISCOURSE_SMTP_ADDRESS: smtp.163.com         # (mandatory)
  DISCOURSE_SMTP_PORT: 25                        # (optional)
  DISCOURSE_SMTP_USER_NAME: xxx     # (optional)
  DISCOURSE_SMTP_PASSWORD: 123123               # (optional, WARNING the char '#' in pw can cause problems!)
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)
volumes:
  - volume:
      host: /data/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /data/discourse/shared/standalone/log/var-log
      guest: /var/log
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
run:
  - exec: echo "Beginning of custom commands"
  - exec: echo "End of custom commands"
  - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "Authorized SSH keys for this container:"; } NF>=2 {print $NF;}'

下面是需要修改的

DISCOURSE_DEVELOPER_EMAILS是你郵件地址;
DISCOURSE_HOSTNAME是你web端打開(kāi)的地址,可以是公網(wǎng)IP,也可以是dns域名;
DISCOURSE_SMTP_ADDRESS、DISCOURSE_SMTP_PORT、DISCOURSE_SMTP_USER_NAME、DISCOURSE_SMTP_PASSWORD是你郵箱信息,這個(gè)郵箱是用戶注冊(cè)或其他行為時(shí),發(fā)送給用戶進(jìn)行驗(yàn)證的郵箱,其中密碼DISCOURSE_SMTP_PASSWORD里不能包含#,否則會(huì)被識(shí)別有問(wèn)題;
默認(rèn)authentication是plain,但我測(cè)試使用163郵箱的話,無(wú)法登陸,所以改為login;
默認(rèn)enable_starttls_auto是開(kāi)啟tls驗(yàn)證,我這里也給改為false;
另外在template里加入一行
  - "templates/web.china.template.yml"
不加入的話,默認(rèn)使用ruby的庫(kù)是國(guó)外的ruby.org鏡像源,加上這個(gè)后是使用國(guó)內(nèi)taobao的ruby鏡像源
具體配置參考注釋?zhuān)热鏳b_shared_buffers、db_work_mem、UNICORN_WORKERS根據(jù)你內(nèi)存來(lái)配置。

6、生成鏡像

默認(rèn)是先下載一個(gè)公共的discourse/discourse鏡像,然后會(huì)根據(jù)你的配置生成一個(gè)本地的鏡像local_discourse/app,如下

root@i-su8g5dng:/tmp# docker p_w_picpaths
REPOSITORY            TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
local_discourse/app   latest              4272aa220d69        2 hours ago         1.877 GB
discourse/discourse   1.0.15              cb7b58c22b11        2 weeks ago         1.265 GB

下面是生成的命令

./launcher bootstrap app
86c397191c205624ded7181c06b1d73ea1856abe126a717354dc308d2964282a
cfbab5cb2ff9745616cb0e604c47644d2a7041445fda6b0da0aa697714bf466b
Successfully bootstrapped, to startup use ./launcher start app
root@i-chxjfvpy:/data/discourse# ./launcher start app

然后使用./launcher start app啟動(dòng)

root@i-chxjfvpy:/data/discourse# docker ps -a
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                                      NAMES
d0b519f15db7        local_discourse/app   "/sbin/boot"        35 seconds ago      Up 33 seconds       0.0.0.0:80->80/tcp, 0.0.0.0:2222->22/tcp   app

之后直接在web里輸入域名或者ip就可以直接訪問(wèn)

7、配置管理員用戶

參考https://meta.discourse.org/t/create-admin-account-from-console/17274

或者直接按照下面操作

進(jìn)入容器

./launcher enter app

創(chuàng)建管理員賬戶

rake admin:create

下面是官方的介紹

You will be asked for Email, Password and Confirm Password.

After providing required information a new account will be created with random username.

Now you will be asked: Do you want to grant Admin privileges to this account? (Y/n). Press enter to continue.

You will see success message: Your account now has Admin privileges!.

That's it, you have created a new account with Admin privileges.

8、登陸驗(yàn)證

開(kāi)源論壇之discourse搭建

登陸后的界面為

開(kāi)源論壇之discourse搭建

9、修改為中文界面

開(kāi)源論壇之discourse搭建

修改后刷新,然后顯示為

開(kāi)源論壇之discourse搭建

10、FAQ

如果遇到無(wú)法發(fā)送驗(yàn)證郵件,檢測(cè)問(wèn)題為

553 Mail from must equal authorized user

開(kāi)源論壇之discourse搭建需要你修改

開(kāi)源論壇之discourse搭建

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI