# 如何在本地以生产模式运行 Discourse？

**URL:** https://meta.discourse.org/t/how-to-run-discourse-in-production-mode-locally/87198
**Category:** Development
**Created:** [2018年五月10日 19:19 UTC](https://meta.discourse.org/t/how-to-run-discourse-in-production-mode-locally/87198 "2018-05-10T19:19:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![eatcodetravel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eatcodetravel/32/94385_2.png) [@eatcodetravel](https://meta.discourse.org/u/eatcodetravel)
#### Post date: [2018年五月10日 19:19 UTC](https://meta.discourse.org/t/how-to-run-discourse-in-production-mode-locally/87198/1 "2018-05-10T19:19:54Z")

</div>

I’m trying to debug a plugin that works locally but doesn’t in production. I want to run Discourse locally in production but I’m having some issues and I don’t want to keep digging if this is not the right way.

What I’m doing right now that works is

1. Copy database configuration for development to production in the `config/database.yml` file
2. Remove the `database_configuration` method override in `application.rb`
3. Remove the check for puma configuration to be used in production in `config/puma.rb`
4. Set `config.public_file_server.enabled = true` in `config/environments/production.rb`
5. Compile assets with `env RAILS_ENV=production bundle exec rake assets:precompile`
6. Run the server with `env RAILS_ENV=production bundle exec rails s`

Is there an easier way to do this?

Thanks!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018年五月10日 21:56 UTC](https://meta.discourse.org/t/how-to-run-discourse-in-production-mode-locally/87198/2 "2018-05-10T21:56:04Z")

</div>

Simplest way is actually to run a docker image locally, it saves a bunch of questions.

Your steps will more-or-less work though but I would spin up unicorn not puma.

---

<div class="post-metadata">

### Author: ![eatcodetravel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eatcodetravel/32/94385_2.png) [@eatcodetravel](https://meta.discourse.org/u/eatcodetravel)
#### Post date: [2018年五月10日 23:15 UTC](https://meta.discourse.org/t/how-to-run-discourse-in-production-mode-locally/87198/3 "2018-05-10T23:15:41Z")

</div>

Wow, I don’t know why I forgot about that, next time I’ll do it that way.

Thanks!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年三月24日 09:19 UTC](https://meta.discourse.org/t/how-to-run-discourse-in-production-mode-locally/87198/5 "2024-03-24T09:19:30Z")

</div>


