在 Ubuntu22.04 上搭建 Discourse 论坛
买服务器,系统为 Ubuntu 22.04 - x86_64
买域名,托管到 CloudFlare(开DNS only),指向服务器IP
插播:Flarum论坛也好看,还轻量
Chore
SSH终端颜色
# 进入 /etc/profile 文件
vim /etc/profile
# 增加这一行
PS1='[\[\e[32m\]\u\[\e[0m\]\[\e[35m\]@\[\e[0m\]\[\e[33m\]\h\[\e[0m\]\[\e[36m\] \W\[\e[0m\]]\$ '
# 更新文件
source /etc/profile
安装常用工具
apt-get install curl wget screen tree git htop bash-completion fail2ban ufw -y
开放端口
ufw allow OpenSSH
ufw enable
ufw allow http
ufw allow https
ufw allow 80/tcp
ufw allow 443/tcp
ufw status
检查 80 端口有无被占用
netstat -tuln | grep 80# 返回为空说明没有
service nginx stop # nginx占了,停止nginx
SMTP 配置
刚开始用的 Mailjet,什么都配置好了,服务已经跑起来了,发不了邮件导致连管理员也注册不了 😅 原来是要发工单人工审核,还被拒了。转Mailgun
[测试SMTP配置]
./launcher enter app
x86_64 arch detected.
rake emails:test[your-email@gmail.com]
本体
Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
Discourse
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
chmod 700 containers
# 启动容器
./discourse-setup
#报错:输入 Hostname for your Discourse? [discourse.example.com]:
后:
Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname: xxx.com.
WARNING: Connection to http://xxx.com (port 80) also fails.
This suggests that xxx.com resolves to some IP address that does not reach this
machine where you are installing discourse.
The first thing to do is confirm that xxx.com resolves to the IP address of this server.
You usually do this at the same place you purchased the domain.
If you are sure that the IP address resolves correctly, it could be a firewall issue.
A web search for "open ports YOUR CLOUD SERVICE" might help.
This tool is designed only for the most standard installations. If you cannot resolve
the issue above, you will need to edit containers/app.yml yourself and then type
./launcher rebuild app
解决:cloudflare里开启 DNS only
成功启动容器后访问域名,注册管理员账户 🎉
参考 & 致谢
安装依赖:php_serialize、miro、mysql2
apt-get install build-essential ruby-dev libmysqlclient-dev
apt-get install rubygems
gem install php_serialize
gem install miro
gem install mysql2