大家好!
这是我的第一篇帖子。
我是 phpBB 的新 Discourse 用户。
两周前,我使用 Nginx 在 Docker 容器中安装了 Discourse,因为 Apache 默认使用端口 80 和 443。我仔细遵循了安装指南和 Nginx 多站点配置中的步骤。
我能够运行并使用论坛一周,只是偶尔登录以熟悉该平台。当我让一位用户注册并测试时,论坛在第二天崩溃了。浏览器显示消息:“为该讨论论坛提供支持的软件遇到了意外问题。” 我无法修复它,因此我从头开始重新安装了整个论坛,然后从最后一个可用备份中恢复了帖子。这是上周四。在此之后,论坛恢复正常运行。现在,它再次出现 502 Bad Gateway Nginx 错误。我直接进行了重建应用程序,但它再次崩溃并出现错误:
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 580 exit 1>
上周同样的事情一次又一次地发生,这导致我从头开始重新安装一切。论坛几乎不活跃,因为我还没有公开它。我担心如果它在没有活动的情况下持续崩溃,那么当用户群体更大时会发生什么?运行这些命令:./launcher enter app
**cd /var/www/discourse**
**su discourse -c 'bundle exec rake db:migrate'**
在响应中,我看到了这个引起我注意的内容:
connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: the database system is starting up
我尝试手动重启 Postgres 并再次运行重建,但进程再次被中断,并出现此错误消息:
FAILED
--------------------
Pups::ExecError: if [ -f /root/install_postgres ]; then
/root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi
failed with return #<Process::Status: pid 18 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"tag"=>"db", "cmd"=>"if [ -f /root/install_postgres ]; then\n /root/install_postgres && rm -f /root/install_postgres\nelif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then\n socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container exit ; 1\nfi\n"}
bootstrap failed with exit code 1
我并不是一个经验丰富的用户,无法识别错误,但我怀疑 Postgres 最终会崩溃。这导致我上周重新启动一切并从头开始,但我认为这对任何人来说都不是常见或健康的做法。
Discourse 运行在一个拥有 4 核、6GB RAM 和 180GB 磁盘空间的服务器上。我目前只运行这个 Discourse 安装,据我所知,我没有受到硬件限制。
pfaffman
(Jay Pfaffman)
2025 年3 月 20 日 14:39
3
欢迎您,@Gustavo_Rip !很抱歉您遇到了麻烦。
您是否进行了标准安装?通过标准安装,您既不需要 Nginx,也不需要 Apache(两者都默认使用端口 80 和 443)。如果您安装了其中任何一个,都应该在开始之前将其删除。
您需要多站点吗?即使需要,我也建议先进行标准安装,然后遵循本指南:使用 Let’s Encrypt 和无反向代理设置多站点配置 。我昨天帮助某人解决了这个问题,看起来如果您使用正确的域名并且不使用带橙色云的 Cloudflare,它就能正常工作。
2 个赞
谢谢您,pfaffmann!!
幸运的是,我不是那种轻易放弃的人,尽管这些后续问题让我担心,尤其是因为我对这个平台还不太熟悉。
默认情况下,我的 CloudServer 安装了 Apache,如果我卸载它,会给 CPanel 和其他功能带来问题。在第一次安装时我尝试过卸载,因为我读到 nginx 要好得多,速度也更快,但遇到了我提到的问题。因此,我重新安装了服务器操作系统,并按照以下建议重新开始:
@pfaffman edited this heavily 2022.02.24. Blame me if it’s broken.
If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container.
NOTE: This is for advanced admins
This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working.
You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will …
我并没有运行多个网站,至少目前还没有,因为我的 CloudServer 最多允许 5 个账户。
至于标准安装,我遵循了安装 Docker、Discourse、Certbot 和下载 Let’s Encrypt 证书的所有步骤,但在运行 discourse-setup 时,我不得不按照上面的链接进行手动配置,并手动配置 app.yml 文件以执行重建。
pfaffman
(Jay Pfaffman)
2025 年3 月 20 日 15:42
5
你真的不想要CPanel。它没有任何用处,并且会大大增加安装Discourse的难度。如果你有它,你将无法遵循NGinx的说明,因为Apache已经碍事了。
如果你能卸载Apache和CPanel,那就这样做。如果不能,我建议换一个托管服务。
实际上,你现在的情况可能根本行不通,你能运行
docker run hello-world
1 个赞
您推荐哪个托管服务?或者哪个是安装 Discourse 最常用的?
pfaffman:
docker run hello-world
是的!这是消息:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
pfaffman
(Jay Pfaffman)
2025 年3 月 20 日 16:15
7
Gustavo_Rip:
您推荐哪个托管服务?
任何不安装 CPanel 的服务。有几个关于推荐服务的帖子。Digital Ocean 很简单。
Gustavo_Rip:
是的!
啊。那么,如果您能摆脱 Apache 和 CPanel,您就会处于有利地位。这似乎是您前进的最简单方法。
另一种方法是保留 CPanel 并设法让您现有的 Apache 成为反向代理。不过,您将孤军奋战,因为安装特定的漏洞太多,人们很难提供太多帮助。
感谢 @pfaffman 的时间和回复!!
我不认为我可能会移除 Apache 和 CPanel。也许我的云服务器提供商可以修改 Apache 的端口,使其不与 Discourse 使用相同的端口,从而消除 nginx,或者修改 CPanel 以支持 Ferozo 或其他服务。我不知道,但我会问问。
此致敬礼!
1 个赞