本指南介绍 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 # 将在后台运行 Unicorn 服务器
你现在应该能够导航到 http://localhost:4200 来查看你的本地 Discourse 安装。(请注意,首次加载可能需要一分钟,因为服务器正在预热。)
你也可以尝试运行测试:
bundle exec rake autospec
所有(或几乎所有)测试都应该通过。
创建新管理员
要创建新管理员,请运行以下命令:
RAILS_ENV=development bundle exec rake admin:create
按照提示创建管理员帐户。
配置邮件
运行 MailHog:
mailhog
恭喜!你现在是自己 Discourse 安装的管理员了!
祝你修改愉快!要开始着手进行,请参阅 创建 Discourse 插件的初学者指南。
此文档是版本控制的 - 在 github 上 建议更改。