Discourse是在线讨论和论坛的强大平台,对于希望促进引人入胜和富有成效的讨论的社区和组织来说,这是一个不错的选择。Discourse是用Ruby on Rails编写的,并使用现代Web架构,包括实时更新,移动友好的设计和复杂的API。它是高度可定制的,并提供一系列功能,旨在使在线讨论引人入胜、富有成效且易于访问。)” data-mce-src=”https://idroot.us/wp-content/uploads/2021/11/discourse-logo.png”>
在 Rocky Linux 9 上安装 Discourse(英语:Rocky Linux <>)
第 1 步。第一步是将系统更新到最新版本的软件包列表。为此,请运行以下命令:
<span class="pln">sudo dnf check</span><span class="pun">-</span><span class="pln">update sudo dnf install dnf</span><span class="pun">-</span><span class="pln">utils epel</span><span class="pun">-</span><span class="pln">release</span>
第 2 步。安装 Git。
默认情况下,Git 在 Rocky Linux 9 AppStream 存储库中可用。现在运行以下命令将稳定版本的 Git 安装到您的系统中:
<span class="pln">sudo dnf install git</span>
您可以使用以下命令验证已安装的版本:
<span class="pln">git </span><span class="pun">--</span><span class="pln">version</span>
现在我们设置标准设置,例如名称和电子邮件,主要围绕 git 提交消息:
<span class="pln">git config </span><span class="pun">--</span><span class="kwd">global</span><span class="pln"> user</span><span class="pun">.</span><span class="pln">name </span><span class="str">"idroot"</span><span class="pln"> git config </span><span class="pun">--</span><span class="kwd">global</span><span class="pln"> user</span><span class="pun">.</span><span class="pln">email </span><span class="str">"godetz@idroot.us"</span>
要验证您的姓名和电子邮件是否已配置,请执行以下操作:
<span class="pln">git config </span><span class="pun">--</span><span class="pln">list</span>
有关安装 Git 的其他资源,请阅读下面的帖子:
- 如何在 Rocky Linux √ 上安装 Git
第 3 步。安装 Docker。
默认情况下,Docker 在 Rocky Linux 9 基础存储库中不可用。现在运行以下命令将 Docker CE 存储库添加到您的系统中:
<span class="pln">sudo dnf config</span><span class="pun">-</span><span class="pln">manager </span><span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">repo</span><span class="pun">=</span><span class="pln">https</span><span class="pun">:</span><span class="com">//download.docker.com/linux/centos/docker-ce.repo</span>
将存储库添加到系统后,现在运行以下命令来安装 Docker CE Rocky Linux:
<span class="pln">sudo dnf install docker</span><span class="pun">-</span><span class="pln">ce docker</span><span class="pun">-</span><span class="pln">ce</span><span class="pun">-</span><span class="pln">cli containerd</span><span class="pun">.</span><span class="pln">io docker</span><span class="pun">-</span><span class="pln">compose</span><span class="pun">-</span><span class="pln">plugin </span><span class="pun">--</span><span class="pln">allowerasing</span>
安装完成后,在 Rocky Linux 上启动 Docker 服务,并使其在系统启动时自动运行:
<span class="pln">sudo systemctl enable docker sudo systemctl start docker</span>
接下来,使用以下命令将用户添加到 Docker 组:
<span class="pln">sudo usermod </span><span class="pun">-</span><span class="pln">aG docker $USER</span>
然后,创建一个新组:
<span class="pln">newgrp docker</span>
验证是否已安装 Docker 版本:
<span class="pln">docker version</span>
有关安装 Docker 的其他资源,请阅读下面的帖子:
- 如何在 Rocky Linux √ 上安装 Docker。
第 3 步。下载话语。
首先,我们将官方的 Discourse Docker GitHub 仓库克隆到目录:/var/discourse
<span class="pln">sudo git clone https</span><span class="pun">:</span><span class="com">//github.com/discourse/discourse_docker.git /var/discourse</span>
接下来,切换到 Discourse 目录并从目录中删除写入和可执行权限:containers
<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">discourse sudo chmod </span><span class="lit">700</span><span class="pln"> containers</span>
第 4 步。配置话语。
下载 Discourse Docker 镜像后,下一步是对其进行配置。您可以通过编辑文件来执行此操作。下面是如何配置文件的示例:containers/app.yml
<span class="pln">cp samples</span><span class="pun">/</span><span class="pln">standalone</span><span class="pun">.</span><span class="pln">yml containers</span><span class="pun">/</span><span class="pln">app</span><span class="pun">.</span><span class="pln">yml nano containers</span><span class="pun">/</span><span class="pln">app</span><span class="pun">.</span><span class="pln">yml</span>
将变量设置为域名:DISCOURSE_HOSTNAME
<span class="pln">DISCOURSE_HOSTNAME</span><span class="pun">:</span> <span class="str">'your-domain.com'</span>
将行更改为 。这会将 Discourse 的外部 HTTP 端口更改为 8080,因为我们将在端口 80 使用 Nginx。注释掉:"80:80
"8080:80"
"443:443"
<span class="pln">expose</span><span class="pun">:</span> <span class="pun">-</span> <span class="str">"8080:80"</span> <span class="com"># http</span> <span class="com">#- "443:443" # https</span>
为管理员设置电子邮件:
<span class="pln">DISCOURSE_DEVELOPER_EMAILS</span><span class="pun">:</span> <span class="str">'idroot@your-domian.com,admin@your-domian.com'</span>
设置 SMTP 设置:
<span class="pln">ISCOURSE_SMTP_ADDRESS</span><span class="pun">:</span><span class="pln"> smtp</span><span class="pun">.</span><span class="pln">your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com DISCOURSE_SMTP_PORT</span><span class="pun">:</span> <span class="lit">587</span><span class="pln"> DISCOURSE_SMTP_USER_NAME</span><span class="pun">:</span><span class="pln"> user@your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com DISCOURSE_SMTP_PASSWORD</span><span class="pun">:</span><span class="pln"> your</span><span class="pun">-</span><span class="pln">strong</span><span class="pun">-</span><span class="pln">smtp</span><span class="pun">-</span><span class="pln">password </span><span class="com">#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)</span><span class="pln"> DISCOURSE_SMTP_DOMAIN</span><span class="pun">:</span><span class="pln"> your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com </span><span class="com"># (required by some providers)</span><span class="pln"> DISCOURSE_NOTIFICATION_EMAIL</span><span class="pun">:</span><span class="pln"> noreply@your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com </span><span class="com"># (address to send notifications from)</span>
第5步。在 Rocky Linux 9 上安装 Discourse。
配置文件设置好后,我们可以使用以下命令启动 Discourse:
<span class="pln">sudo </span><span class="pun">./</span><span class="pln">launcher bootstrap app</span>
启动话语应用程序:
<span class="pln">sudo </span><span class="pun">./</span><span class="pln">launcher start app</span>
第 6 步。安装和配置 Nginx for Discourse。
默认情况下,Nginx 在 Rocky Linux 9 基础存储库中不可用。现在运行以下命令将 Nginx 稳定存储库添加到您的系统中:
<span class="pln">sudo tee </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">yum</span><span class="pun">.</span><span class="pln">repos</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">-</span><span class="pln">stable</span><span class="pun">.</span><span class="pln">repo</span><span class="pun"><<</span><span class="pln">EOF </span><span class="pun">[</span><span class="pln">nginx</span><span class="pun">-</span><span class="pln">stable</span><span class="pun">]</span><span class="pln"> name</span><span class="pun">=</span><span class="pln">nginx stable repo baseurl</span><span class="pun">=</span><span class="pln">http</span><span class="pun">:</span><span class="com">//nginx.org/packages/centos/9/x86_64/</span><span class="pln"> gpgcheck</span><span class="pun">=</span><span class="lit">1</span><span class="pln"> enabled</span><span class="pun">=</span><span class="lit">1</span><span class="pln"> gpgkey</span><span class="pun">=</span><span class="pln">https</span><span class="pun">:</span><span class="com">//nginx.org/keys/nginx_signing.key</span><span class="pln"> module_hotfixes</span><span class="pun">=</span><span class="kwd">true</span><span class="pln"> EOF</span>
现在,运行以下命令将 Nginx 的最新稳定版本安装到您的服务器上:
<span class="pln">sudo dnf update sudo dnf install nginx</span>
安装完成后,启动 Nginx 服务并使其能够在重新启动时自动启动,一次性完成:
<span class="pln">sudo systemctl enable </span><span class="pun">--</span><span class="pln">now nginx</span>
要验证是否已安装最新版本的 Nginx,请运行:
<span class="pln">nginx </span><span class="pun">-</span><span class="pln">v</span>
下面是一个如何配置 Nginx 以服务于话语的示例:
<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">discourse</span><span class="pun">.</span><span class="pln">conf</span>
添加以下文件:
<span class="com"># enforce HTTPS</span><span class="pln"> server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln"> listen </span><span class="pun">[::]:</span><span class="lit">80</span><span class="pun">;</span><span class="pln"> server_name discourse</span><span class="pun">.</span><span class="pln">example</span><span class="pun">.</span><span class="pln">com</span><span class="pun">;</span><span class="pln"> location </span><span class="pun">/</span> <span class="pun">{</span> <span class="kwd">return</span> <span class="lit">301</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//$host$request_uri; }</span> <span class="pun">}</span><span class="pln"> server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">443</span><span class="pln"> ssl http2</span><span class="pun">;</span><span class="pln"> listen </span><span class="pun">[::]:</span><span class="lit">443</span><span class="pln"> ssl http2</span><span class="pun">;</span><span class="pln"> server_name discourse</span><span class="pun">.</span><span class="pln">example</span><span class="pun">.</span><span class="pln">com</span><span class="pun">;</span><span class="pln"> access_log </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">discourse</span><span class="pun">.</span><span class="pln">access</span><span class="pun">.</span><span class="pln">log</span><span class="pun">;</span><span class="pln"> error_log </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">discourse</span><span class="pun">.</span><span class="pln">error</span><span class="pun">.</span><span class="pln">log</span><span class="pun">;</span><span class="pln"> http2_push_preload on</span><span class="pun">;</span> <span class="com"># Enable HTTP/2 Server Push</span> <span class="com"># Enable TLSv1.3's 0-RTT. Use $ssl_early_data when reverse proxying to</span> <span class="com"># prevent replay attacks.</span> <span class="com">#</span> <span class="com"># @see: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_early_data</span><span class="pln"> ssl_early_data on</span><span class="pun">;</span> <span class="com"># Security / XSS Mitigation Headers</span> <span class="com"># NOTE: X-Frame-Options may cause issues with the webOS app</span><span class="pln"> add_header X</span><span class="pun">-</span><span class="typ">Frame</span><span class="pun">-</span><span class="typ">Options</span> <span class="str">"SAMEORIGIN"</span><span class="pun">;</span><span class="pln"> add_header X</span><span class="pun">-</span><span class="pln">XSS</span><span class="pun">-</span><span class="typ">Protection</span> <span class="str">"1; mode=block"</span><span class="pun">;</span><span class="pln"> add_header X</span><span class="pun">-</span><span class="typ">Content</span><span class="pun">-</span><span class="typ">Type</span><span class="pun">-</span><span class="typ">Options</span> <span class="str">"nosniff"</span><span class="pun">;</span><span class="pln"> add_header X</span><span class="pun">-</span><span class="typ">Early</span><span class="pun">-</span><span class="typ">Data</span><span class="pln"> $tls1_3_early_data</span><span class="pun">;</span><span class="pln"> client_max_body_size </span><span class="lit">100m</span><span class="pun">;</span><span class="pln"> location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln"> proxy_pass http</span><span class="pun">:</span><span class="com">//your-domain.com:8080/;</span><span class="pln"> proxy_set_header </span><span class="typ">Host</span><span class="pln"> $http_host</span><span class="pun">;</span><span class="pln"> proxy_http_version </span><span class="lit">1.1</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Forwarded</span><span class="pun">-</span><span class="typ">Proto</span><span class="pln"> $scheme</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Forwarded</span><span class="pun">-</span><span class="typ">For</span><span class="pln"> $proxy_add_x_forwarded_for</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Real</span><span class="pun">-</span><span class="pln">IP $remote_addr</span><span class="pun">;</span> <span class="pun">}</span> <span class="pun">}</span> <span class="com"># This block is useful for debugging TLS v1.3. Please feel free to remove this</span> <span class="com"># and use the `$ssl_early_data` variable exposed by NGINX directly should you</span> <span class="com"># wish to do so.</span><span class="pln"> map $ssl_early_data $tls1_3_early_data </span><span class="pun">{</span> <span class="str">"~."</span><span class="pln"> $ssl_early_data</span><span class="pun">;</span> <span class="kwd">default</span> <span class="str">""</span><span class="pun">;</span> <span class="pun">}</span>
保存并关闭文件,然后重新启动 Nginx 服务以启用新配置:
<span class="pln">sudo systemctl restart nginx</span>
有关安装 Nginx 的其他资源,请阅读下面的帖子:
- 如何在 Rocky Linux √ 上安装 Nginx
步骤 7.使用Let’s Encrypt SSL保护话语。
首先,使用以下命令安装 Certbot 客户端:
<span class="pln">sudo dnf install certbot python3</span><span class="pun">-</span><span class="pln">certbot</span><span class="pun">-</span><span class="pln">nginx</span>
接下来,按照以下步骤使用Let’s Encrypt获取SSL证书:
<span class="pln">sudo certbot </span><span class="pun">--</span><span class="pln">nginx </span><span class="pun">-</span><span class="pln">d your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span>
让我们加密证书的有效期为 90 天,强烈建议在证书过期之前续订证书。您可以通过运行以下命令来测试证书的自动续订:
<span class="pln">sudo certbot renew </span><span class="pun">--</span><span class="pln">dry</span><span class="pun">-</span><span class="pln">run</span>
第8步。配置防火墙。
默认情况下,Nginx 侦听端口 80 和 443。如果您的服务器上安装并配置了任何防火墙,则需要通过 firewalld 允许这两个端口。您可以使用以下命令允许它们:
<span class="pln">sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="pln">zone</span><span class="pun">=</span><span class="kwd">public</span> <span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">service</span><span class="pun">=</span><span class="pln">http sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="pln">zone</span><span class="pun">=</span><span class="kwd">public</span> <span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">service</span><span class="pun">=</span><span class="pln">https sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">reload</span>
您可以通过列出当前防火墙设置进行验证:
<span class="pln">sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="pln">list</span><span class="pun">-</span><span class="pln">all</span>
第9步。访问话语网络界面。
成功安装后,打开您的 Web 浏览器并使用 URL 访问话语 Web UI。您应该看到以下页面:https://.your-domain.com
感谢您使用本教程在您的 Rocky Linux 9 系统上安装 Discourse 讨论平台。如需其他帮助或有用信息,我们建议您查看官方话语网站。