开源论坛之discourse搭建
快2个月没写博客,最近一个是忙着开发docker平台,另外一个是接手了公司私有云,所以比较忙。
公司最近有个新项目,想弄个技术的问答论坛,挑选了半天,选择ruby语言的discourse,这个是完全开源的,界面简洁,支持中文,有管理后台,满足需求。
discourse的地址是https://www.discourse.org
界面如下
下面是安装过程
系统环境
官方推荐使用ubuntu,并且安装的程序也是支持ubuntu系统,docker安装模式,所以我选择了云主机ubuntu 14.04系统,discourse是最新的1.5.0版本。
安装地址可以参考https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md
1、更新源
apt-getupdate
2、安装依赖软件
apt-getinstallrubygit
3、安装docker
wget-qO-https://get.docker.com/|sh
安装完成后可以使用docker version查看
root@i-chxjfvpy:/tmp#dockerversionClient:Version:1.9.1APIversion:1.21Goversion:go1.4.2Gitcommit:a34a1d5Built:FriNov2013:12:04UTC2015OS/Arch:linux/amd64Server:Version:1.9.1APIversion:1.21Goversion:go1.4.2Gitcommit:a34a1d5Built:FriNov2013:12:04UTC2015OS/Arch:linux/amd64
当前我的是1.9.1版本
4、安装discourse
mkdir/data/discoursegitclonehttps://github.com/discourse/discourse_docker.git/data/discoursecd/data/discoursecpsamples/standalone.ymlcontainers/app.yml
ps:默认官方是放入/var目录里,我这里放入/data是因为这个目录是我云主机挂载的盘
root@i-chxjfvpy:~#df-hFilesystemSizeUsedAvailUse%Mountedon/dev/vda118G1.8G15G11%/none4.0K04.0K0%/sys/fs/cgroupudev3.9G8.0K3.9G1%/devtmpfs799M412K799M1%/runnone5.0M05.0M0%/run/locknone3.9G03.9G0%/run/shmnone100M0100M0%/run/user/dev/vdb1193G60M183G1%/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"#fwdhostport80tocontainerport80(http)-"2222:22"#fwdhostport2222tocontainerport22(ssh)params:db_default_text_search_config:"pg_catalog.english"db_shared_buffers:"2GB"db_work_mem:"40MB"env:LANG:en_US.UTF-8UNICORN_WORKERS:6DISCOURSE_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,WARNINGthechar'#'inpwcancauseproblems!)DISCOURSE_SMTP_AUTHENTICATION:loginDISCOURSE_SMTP_OPENSSL_VERIFY_MODE:noneDISCOURSE_SMTP_ENABLE_START_TLS:false#(optional,defaulttrue)volumes:-volume:host:/data/discourse/shared/standaloneguest:/shared-volume:host:/data/discourse/shared/standalone/log/var-logguest:/var/loghooks:after_code:-exec:cd:$home/pluginscmd:-gitclonehttps://github.com/discourse/docker_manager.gitrun:-exec:echo"Beginningofcustomcommands"-exec:echo"Endofcustomcommands"-exec:awk-F\#'{print$1;}'~/.ssh/authorized_keys|awk'BEGIN{print"AuthorizedSSHkeysforthiscontainer:";}NF>=2{print$NF;}'
下面是需要修改的
DISCOURSE_DEVELOPER_EMAILS是你邮件地址;DISCOURSE_HOSTNAME是你web端打开的地址,可以是公网IP,也可以是dns域名;DISCOURSE_SMTP_ADDRESS、DISCOURSE_SMTP_PORT、DISCOURSE_SMTP_USER_NAME、DISCOURSE_SMTP_PASSWORD是你邮箱信息,这个邮箱是用户注册或其他行为时,发送给用户进行验证的邮箱,其中密码DISCOURSE_SMTP_PASSWORD里不能包含#,否则会被识别有问题;默认authentication是plain,但我测试使用163邮箱的话,无法登陆,所以改为login;默认enable_starttls_auto是开启tls验证,我这里也给改为false;另外在template里加入一行-"templates/web.china.template.yml"不加入的话,默认使用ruby的库是国外的ruby.org镜像源,加上这个后是使用国内taobao的ruby镜像源具体配置参考注释,比如db_shared_buffers、db_work_mem、UNICORN_WORKERS根据你内存来配置。
6、生成镜像
默认是先下载一个公共的discourse/discourse镜像,然后会根据你的配置生成一个本地的镜像local_discourse/app,如下
root@i-su8g5dng:/tmp#dockerp_w_picpathsREPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZElocal_discourse/applatest4272aa220d692hoursago1.877GBdiscourse/discourse1.0.15cb7b58c22b112weeksago1.265GB
下面是生成的命令
./launcherbootstrapapp
86c397191c205624ded7181c06b1d73ea1856abe126a717354dc308d2964282acfbab5cb2ff9745616cb0e604c47644d2a7041445fda6b0da0aa697714bf466bSuccessfullybootstrapped,tostartupuse./launcherstartapproot@i-chxjfvpy:/data/discourse#./launcherstartapp
然后使用./launcher start app启动
root@i-chxjfvpy:/data/discourse#dockerps-aCONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMESd0b519f15db7local_discourse/app"/sbin/boot"35secondsagoUp33seconds0.0.0.0:80->80/tcp,0.0.0.0:2222->22/tcpapp
之后直接在web里输入域名或者ip就可以直接访问
7、配置管理员用户
参考https://meta.discourse.org/t/create-admin-account-from-console/17274
或者直接按照下面操作
进入容器
./launcherenterapp
创建管理员账户
rakeadmin:create
下面是官方的介绍
YouwillbeaskedforEmail,PasswordandConfirmPassword.Afterprovidingrequiredinformationanewaccountwillbecreatedwithrandomusername.Nowyouwillbeasked:DoyouwanttograntAdminprivilegestothisaccount?(Y/n).Pressentertocontinue.Youwillseesuccessmessage:YouraccountnowhasAdminprivileges!.That'sit,youhavecreatedanewaccountwithAdminprivileges.
8、登陆验证
登陆后的界面为
9、修改为中文界面
修改后刷新,然后显示为
10、FAQ
如果遇到无法发送验证邮件,检测问题为
553 Mail from must equal authorized user
需要你修改
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。