在 macOS 上安装 Discourse 进行开发

:warning: 本指南涵盖 macOS 开发环境的安装说明。如需生产环境指南,请参阅:Install Discourse in production with the official supported instructions

所以你想在 macOS 上设置 Discourse 以进行开发?

我们假设你的 Mac 上尚未安装 Ruby/Rails/Postgres/Redis。让我们开始吧 :rocket:

安装 Discourse 依赖项

你的系统需要以下软件包:

** 可选

重启你的终端

现在我们已经安装了 Discourse 的依赖项,接下来安装 Discourse 本身。

重启你的终端

退出并重新启动你的 shell,以确保终端能正确识别已安装软件包的路径。

克隆 Discourse

~/discourse 文件夹中克隆 Discourse 仓库:

git clone https://github.com/discourse/discourse.git ~/discourse

~ 表示主目录,因此 Discourse 源代码将位于你的主目录中。

引导 Discourse

切换到你的 Discourse 文件夹:

cd ~/discourse

安装所需的 gems

bundle install

安装 JS 依赖项

pnpm install

接下来,运行以下命令来设置你的本地 Discourse 实例:

bundle exec rake db:create
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate

启动 Rails 和 Ember 服务器,你有两种选择。

选项 1:使用两个独立的终端标签页/窗口,分别运行 Rails 和前端打包工具:

bundle exec rails server

bin/dev --only ember

选项 2:仅使用一个终端标签页/窗口:

bin/dev # 同时运行 Pitchfork 和前端打包工具

:tada: 现在你应该能够访问 http://localhost:3000 查看你的本地 Discourse 安装。(请注意,首次加载可能需要长达一分钟,因为服务器需要预热。)

你也可以尝试运行测试:

bundle exec rake autospec

所有(或几乎所有)测试都应该通过。

创建新管理员

要创建新管理员,请运行以下命令:

RAILS_ENV=development bundle exec rake admin:create

按照提示创建管理员账户。

配置邮件

运行 MailHog:

mailhog

恭喜!你现在已成为自己 Discourse 安装的管理员!

愉快开发!要开始动手,请参阅 Discourse 插件创建入门指南


本文档已进行版本控制 - 如有修改建议,请 在 GitHub 上提交

78 个赞
Setup discourse on Mac OS
Running Discourse on Docker for Mac
Localhost:3000/users gives no-results
How to install Discourse on windows
How to install Discourse locally?
Best dev installation method for running on macOS?
Migrate a NodeBB forum with Redis to Discourse
Starting discourse fails with bootstrap error
Please help, how do I install Discourse on macOS?
MacOS Installation Gem::FilePermissionError
Help me setup my Discourse development environment
Error after cleaning tmp folder
UndefinedTable: ERROR: relation "web_hook_event_types" when trying to run rspec test
Local installation internal use only
Discourse standalone
Ember-cli error on local MacOS development
Importing / migrating from Zendesk Community to Discourse
Change unicorn port from 3000 in development
Redis version error when I run bundle exec db:create
Category option: max topics per user (2 use-case examples)
Dev environment setup failed on bundle install
Set up a local Discourse Development Environment?
[Need help][MacOS M1 dev installation] ArgumentError unknown keywords
How to connect to an external database running on localhost
Migrate a PunBB forum to Discourse
Migrate a phpBB3 forum to Discourse
Migrate a FluxBB forum to Discourse
Migrate a vBulletin 3 forum to Discourse via XenForo
Migrate a MyBB forum to Discourse
Regarding the installation - docker
Migrate a NodeBB forum with MongoDB to Discourse
Migrate a Ning forum to Discourse
Migrate a Phorum forum to Discourse
Migrate from another forum to Discourse
Migrate a Kunena 3 forum to Discourse
Migrate a bbPress WordPress plugin forum to Discourse
Install Discourse for development using Docker
Use the Discourse API ruby gem
Vagrant based server failing on db:migrate
Please help, how do I install Discourse on macOS?
Can't start localhost server -- file was built for x86_64 which is not the architecture being linked (i386)
Discourse Connect on Local instance is not working
Local development and deploying from same repo
Enable CORS on localhost for DiscourseConnect
Set Environmental Variables
Need help integrating code wrote on Edittext to the Discourse
Keyboard navigation messes up the search menu
WP-Discourse not connected and admin email not recognized
Contributing to Discourse development
How to install discussions on localhost in my mac?
How to install Discourse for Wordpress locally running on MAMP
Error when building: "Runtime Error: discourse does not support compiling scss/sass files via sprockets"
Disabling SSO in development environment
Install on macOS – Failure: Scheduler::Defer can pause and resume
Stuck in infinite loop in Mac terminal after source ~/.bashrc
Can't set up dev environment due to cppjieba_rb failing to install
Override profile background via SSO
Installing Discourse for macOS Development Using asdf and docker-compose
How to relax Content Security Policy
How to add a new language
How to edit the discourse files? A development box?
Can't set up dev environment due to cppjieba_rb failing to install
Install error : Protocol violation
Cannot Backup my Development Instance (Fails)
Update PhantomJS to latest for Ubuntu dev guide?
Rake aborted message is showing when installing vagrant development
[PAID] Import from Legacy Postgres DB
Nginx Performance Report plugin incompatible with development environment setup script
Discourse as Your First Rails App
Installing problem - bundle install
Migrate from GetSatisfaction to Discourse
Case study of an amateur plugin author
Upgrading Mathjax to version 4
Windows server publish method
Rails server --daemon and plugins
Moderation Tools
Can't deploy to heroku
Topic List Previews (TLP)
Global messages on 94632 timed out, restarting process, 95535 successfully terminated by `TERM` signal
How can I include discourse in my local dev stack?
Cannot get embedding to work
/admin/config/emoji non responsive/locks up
App.yml file does not exist when installing Discourse locally
I want to build a debug version of discourse