开发、暂存和生产环境 Rails 应用

发布于 2024-11-04 04:24:27 字数 765 浏览 0 评论 0原文

我正在创建一个应用程序,除了实时生产环境之外,还需要开发和暂存环境。生产环境目前已上线并位于其自己的 VPS 实例上。记录:

myapp.com  1.2.3.4

开发和登台环境将位于它们自己的 VPS 实例上。我已经配置了适当的 DNS 记录,因此每个环境都有自己的子域(myapp.com 域中指向开发/登台服务器的记录:

dev.myapp.com 5.6.7.8
staging.myapp.com 5.6.7.8

Nginx confix(Rails、Passenger)为每个服务器设置根(wild)卡 SSL 在 http 定义中配置,端口 80 重定向到端口 443):

server {
   listen 443;
   server_name dev.myapp.com
   root /apps/myapp/dev/public
}

server {
   listen 443;
   server_name staging.myapp.com
   root /apps/myapp/staging/public
}

我在 Rails 方面有点困惑,我还需要做什么来配置环境,以便我可以通过 URL 访问单独的开发和临时环境:

staging.myapp.com
dev.myapp.com

我知道 Capistrano 允许您设置生产和暂存环境,但我需要开发和暂存 URL 都处于活动状态,还是这应该足够了?

I'm creating an app that in addition to the live production environment requires a development and staging environment. The production environment is currently live and on its own VPS instance. A record:

myapp.com  1.2.3.4

The development and staging environments will be on their own VPS instance. I've configured the appropriate DNS records so each environment has its own sub-domain (A record in the myapp.com domain pointing to the dev/staging server:

dev.myapp.com 5.6.7.8
staging.myapp.com 5.6.7.8

The Nginx confix (Rails, Passenger) sets the root for each server (wild card SSL is configure in the http definition and port 80 redirects to port 443):

server {
   listen 443;
   server_name dev.myapp.com
   root /apps/myapp/dev/public
}

server {
   listen 443;
   server_name staging.myapp.com
   root /apps/myapp/staging/public
}

I'm a bit confused on the Rails side what else do I need to do to configure the environments so I can access the individual dev and staging environments by URL:

staging.myapp.com
dev.myapp.com

I know Capistrano allows you to set production and staging environments but I need both the dev and staging URLs to be live or should this be sufficient?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失眠症患者 2024-11-11 04:24:27

您可以使用 rails_env 选项。例如:

server {
  listen 443;
  server_name staging.myapp.com;
  root /apps/myapp/staging/public;
  passenger_enabled on;
  rails_env staging;
}

You can set the environment for each instance using the rails_env option. For example:

server {
  listen 443;
  server_name staging.myapp.com;
  root /apps/myapp/staging/public;
  passenger_enabled on;
  rails_env staging;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文