本指南介绍 macOS 开发环境的安装说明。如需生产环境指南,请访问:Install Discourse in production with the official supported instructions
您想在 macOS 上设置 Discourse 以进行开发吗?
我们将假设您的 Mac 上尚未安装 Ruby/Rails/Postgres/Redis。让我们开始吧
!
安装 Discourse 依赖项
您的系统需要以下软件包:
- Git
- rbenv 或 asdf
- ruby-build
- Ruby(最新稳定版)
- Rails
- PostgreSQL
- SQLite
- Redis
- Node.js
- pnpm
- MailHog**
- ImageMagick**
** 可选
重启您的终端
安装完 Discourse 依赖项后,让我们继续安装 Discourse 本身。
重启您的终端
退出并重新启动 shell 可确保终端正确识别已安装软件包的路径。
克隆 Discourse
将 Discourse 仓库克隆到 ~/discourse 文件夹:
git clone https://github.com/discourse/discourse.git ~/discourse
~ 表示主文件夹,因此 Discourse 源代码将位于您的主文件夹中。
引导 Discourse
切换到您的 Discourse 文件夹:
cd ~/discourse
安装所需的 gem:
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 和 Ember CLI:
bundle exec rails server
和
bin/ember-cli
选项 2:仅使用一个终端标签页/窗口:
bin/ember-cli -u # 将在后台运行 Pitchfork 服务器
现在您应该可以访问 http://localhost:4200 查看您的本地 Discourse 安装。(请注意,首次加载可能需要长达一分钟,因为服务器正在预热。)
您还可以尝试运行测试:
bundle exec rake autospec
所有(或几乎所有)测试都应通过。
创建新管理员
要创建新管理员,请运行以下命令:
RAILS_ENV=development bundle exec rake admin:create
按照提示创建管理员账户。
配置邮件
运行 MailHog:
mailhog
恭喜!您现在已成为自己 Discourse 安装的管理员!
愉快开发!要开始开发,请参阅 Discourse 插件创建入门指南。
本文档已进行版本控制 - 如有修改建议,请在 GitHub 上提出。