Discourse是一个免费的、开源的社区论坛。
与其它论坛不同的是它有时尚的外观和感觉,响应即时。Discourse有很多特点,如社区节制(禁止不当言论),概括话题,内嵌上下文,支持25种语言。支持实时通知,悬浮编辑器,桌面通知,文件附件等,支持社交账户登录。提供搜索引擎优化,支持诸多插件和扩展。
要求:至少1G内存,root权限,一个域名
更新库
yum -y update
安装git
yum -y install git
如果你的服务器只有2G内存或更少的话,那么Discourse 需要2G交换文件。
检查是否有交换文件:
swapon -s
如果无响应,则没有交换文件,需要创建:
dd if=/dev/zero of=/swapfile count=2048 bs=1MiB
显示:048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 29.8985 s, 71.8 MB/s
更改文件权限,仅限root读取:
chmod 600 /swapfile
创建交换空间:
mkswap /swapfile
结果如下:
[root@liptan-pc ~]# mkswap /swapfile
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=b26c5ac6-6c5a-4a0b-9776-aaf3fd72f18b
编辑/etc/fstab文件,使交换文件永久化
vim /etc/fstab
文本最后添加
/swapfile swap swap sw 0 0
告诉系统使用交换文件
swapon /swapfile
检查是否有交换文件:
swapon -s
将显示:
[root@liptan-pc ~]# swapon -s
Filename Type Size Used Priority
/swapfile file 2097148 0
优化:
sysctl vm.swappiness=10
sysctl vm.vfs_cache_pressure=50
vim /etc/sysctl.conf
添加下面2行到文件尾
vm.swappiness = 10
vm.vfs_cache_pressure = 50
注:vm.swappiness表示内存交换的频率
vm.vfs_cache_pressure表示内核回收用于directory和inode cache内存的倾向;缺省值100表示内核将根据pagecache和swapcache,把directory和inode cache保持在一个合理的百分比;降低该值低于100,将导致内核倾向于保留directory和inode cache;增加该值超过100,将导致内核倾向于回收directory和inode cache
查看内存
free -m
将显示:
[root@liptan-pc ~]# free -m
total used free shared buff/cache available
Mem: 991 70 69 12 852 743
Swap: 2047 0 2047
安装docker:参见《CentOS8安装Docker折腾记》一文
创建discourse目录
mkdir /var/discourse
克隆映像
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
拷贝配置文件
cp samples/standalone.yml containers/app.yml
配置
vim containers/app.yml
db_shared_buffers: "256MB"
# Uncomment it and change its value to 128MB if you have 1GB actual memory or 256MB if you have 2GB actual memory in #your system.
UNICORN_WORKERS: 3
#Uncomment it and change the value of unicorn workers to 2 if you have 1GB actual memory or 3 or 4 if you have 2GB or more actual memory in your system
DISCOURSE_HOSTNAME: 'www.example.com'
DISCOURSE_DEVELOPER_EMAILS: 'admin1@qinqingshouhu.com,admin2@qinqingshouhu.com'
#管理员邮箱
## 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: mail.qinqingshouhu.com
DISCOURSE_SMTP_PORT: 465
DISCOURSE_SMTP_USER_NAME: admin@qinqingshouhu.com
DISCOURSE_SMTP_PASSWORD: xxxxxx
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
#SMTP
env:
LANG: zh_CN.UTF-8
DISCOURSE_DEFAULT_LOCALE: zh_CN
#语言配置
安装
./launcher bootstrap app
运行
./launcher start app
如果配置错了,修改app.yml后,需重新编译
./launcher rebuild app
编译好后会自动运行,无需再次启动
.
参考文章 https://hostpresto.com/community/tutorials/install-discourse-community-forum-on-centos-7/