在 Windows 上安装 Discourse 用于开发

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

要在 Windows 上设置 Discourse 的开发环境,你可以使用 Windows 子系统 for Linux 功能。

此设置需要安装 WSL 2。它仅适用于 Windows 10 版本 18917 或更高版本。 我们假设你已经在 Windows 10 系统上安装了 Windows 子系统 for Linux 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?
Error installing `bullseye-backports` when trying to install for Development
How can i install Discourse forum on my win 10 dedicated server OVH
How to install on localhost
Trying to set up Discourse on my website
Restoring backup fails in Win10/Ubuntu development environment
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
Restoring backup fails in Win10/Ubuntu development environment
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
Use the Discourse API ruby gem
Migrate a Ning forum to Discourse
Windows server publish method
什么时候支持使用 wsl 容器部署 Discourse 开发环境?
No such file or directory - convert (Errno::ENOENT)
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