在 Windows 上安装 Discourse 进行开发

:information_source: 本教程已在 Windows 10 和 11 上测试通过。

要在 Windows 上为 Discourse 搭建开发环境,您可以使用 适用于 Linux 的 Windows 子系统 功能。

此设置需要安装 WSL 2。它仅在 Windows 10 版本 18917 或更高版本中可用。 我们假设您已经在 Windows 10 系统上安装了 适用于 Linux 的 Windows 子系统 2 (Ubuntu)警告: 请安装 Ubuntu 18.04,而不是 20.04,因为在 20.04 上某些安装会失败。更多信息请参阅本文底部的 2020 年 6 月 30 日备注。

让我们开始吧!

安装 Discourse

  1. 最初请按照主题 在 Ubuntu 上安装 Discourse 进行开发的初学者指南 中的步骤操作,直到 克隆 Discourse 这一步。
  1. 在设置数据库之前,您必须使用以下命令手动启动 PostgreSQL 服务和 Redis 服务器:

    sudo service postgresql start
    redis-server --daemonize yes
    
  2. 然后完成 Ubuntu 指南 中的所有剩余步骤。

创建启动 Discourse 的命令

现在您的开发环境几乎已经准备就绪。 唯一的问题是,每次在 Windows 上打开 Ubuntu 时,您都必须手动启动 PostgreSQL 服务和 Redis 服务器。别担心,我们可以通过创建一个自定义命令来解决这个问题::wink:

cd ~

使用命令 nano start-discourse 创建一个新文件,粘贴以下内容,然后保存并退出。

#!/bin/bash

# 启动 PostgreSQL
sudo service postgresql start

# 启动 Redis 服务器
redis-server --daemonize yes

现在使用以下命令修改 CHMOD

chmod +x start-discourse

并将文件复制到您的 bin 文件夹

sudo cp start-discourse /usr/bin/

完成了。 现在,每次打开 Ubuntu bash 时,只需运行下面的命令即可开始开发::+1:

start-discourse

或者,如果您使用的是 Windows 10 企业版、专业版或教育版,则可以在 hyper-v 中创建 Linux 虚拟机来设置 Discourse 开发环境。

关于 Windows 环境的备注

截至 2020 年 6 月 30 日:
截至 2020 年 7 月 1 日

最后由 @SaraDev2022-06-16T02:00:00Z 审阅


本文档已进行版本控制 - 请在 GitHub 上提出更改建议。

52 个赞
How to install Discourse on windows
Help installing Discourse for Developer
Database connection error when setting up Discourse development environment using Linux Bash Shell on Windows 10
Restoring backup fails in Win10/Ubuntu development environment
How to Install Discourse on LocalHost in Windows?
How can i install Discourse forum on my win 10 dedicated server OVH
Error installing `bullseye-backports` when trying to install for Development
How to install on localhost
Restoring backup fails in Win10/Ubuntu development environment
Trying to set up Discourse on my website
Help with setting up discourse An error occurred while installing xorcist (1.1.2), and Bundler cannot continue
Migrate a MyBB forum to Discourse
Migrate a NodeBB forum with MongoDB to Discourse
Migrate a Phorum forum to Discourse
Migrate a PunBB forum to Discourse
Migrate from another forum to Discourse
Unable to setup discourse in my windows 10
Self hosting discourse with WSL shows an error, the command shown also doesnt work
No such file or directory - convert (Errno::ENOENT)
PG::UndefinedTable: ERROR: relation "pg_range" does not exist
I'm having trouble installing a local Discourse instance on Windows 11
Issues while installing Discourse on WSL
Guide to Setting Up Discourse Development Environment - Windows 11
Need help integrating code wrote on Edittext to the Discourse
Problem in development Installation
Contributing to Discourse development
Subscribe to post an ad
Restoring backup fails in Win10/Ubuntu development environment
Migrate a Ning forum to Discourse
Windows server publish method
Use the Discourse API ruby gem
Topics which users cannot directly reply to, but can create a linked topic?
How to add a new language
How to Start Sidekiq When Using Puma
Discourse-webpack: A boilerplate for developing JS-heavy Discourse components
How can I directly edit Discourse database from a GUI?
Can't set up dev environment due to cppjieba_rb failing to install
Cloning and making our own Discourse community
How to Add Ngrok to Allowed Hosts
»vagrant up« hangs
Discourse installation end to end on Windows Server 2016
No connection to db issue
How to Install Discourse on LocalHost in Windows?
WSL environment deadlocks
Problem with development on Windows with Docker and mounted volume
Please help, how do I install Discourse on macOS?
Discourse standalone
Set up a local Discourse Development Environment?
Migrate a NodeBB forum with Redis to Discourse