如何在一个域上部署多个 Rails 应用程序而无需符号链接

发布于 2024-10-17 06:27:18 字数 547 浏览 7 评论 0原文

根据乘客文档,可以通过设置中央 Rails 应用程序在一个域上部署多个 Rails 应用程序,然后通过在此应用程序的公共目录中创建符号链接来链接其他应用程序(并告知网络服务器)。

这实际上是相当混乱的。有没有办法仅通过网络服务器配置来实现此行为?我正在使用 apache2 和 mod_rails。

我想要的是以下内容:

myapp.subdomain.domain.tld myapp.subdomain.domain.tld/staging myapp.subdomain.domain.tld/development

其中每个 URL 都指向不同的 Rails 项目,该项目驻留在服务器上的以下目录中:

/var/www/myapp/products/current/public /var/www/myapp/staging/current/public /var/www/myapp/development/current/public

在这种情况下,我需要将符号链接放在生产文件夹的公共文件夹中,这不是我想要的(感觉很脏)。这些项目甚至可能稍后将驻留在不同的服务器上。

According to the passenger documentation it is possible to deploy multiple rails apps on one domain by setting a central rails app and then link in other apps by creating symbolic links in the public directory of this app (and tell the webserver about it).

This is actually pretty messy. Is there a way to achieve this behaviour just with the webserver configuration? I am using apache2 with mod_rails.

What i want is the following:

myapp.subdomain.domain.tld
myapp.subdomain.domain.tld/staging
myapp.subdomain.domain.tld/development

Where each of the URLs point to a different rails project which reside in the following directories on the server:

/var/www/myapp/production/current/public
/var/www/myapp/staging/current/public
/var/www/myapp/development/current/public

In this scenario i would need to place the symbolic links in the public folder of the production folder, which is not what i want (it feels very dirty). It might even be that these projects will later reside on different servers.

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

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

发布评论

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

评论(1

过气美图社 2024-10-24 06:27:18

您所需要的只是启用 mod_alias 并使用 alias 指令来映射不同的位置
myapp.subdomain.domain.tld 默认情况下将映射到文档根目录中定义的位置
然后
对于 myapp.subdomain.domain.tld/staging
指令

Alias staging /var/www/myapp/staging/current/public 

使用myapp.subdomain.domain.tld/development
使用指令

Alias development /var/www/myapp/development/current/public 

有关更多信息,请查看以下 mod_alias 文档: http://httpd .apache.org/docs/2.0/urlmapping.html

All you need is to enable mod_alias and use alias directive to map different locations
myapp.subdomain.domain.tld will map by default to the location as defined in the document root
then
for myapp.subdomain.domain.tld/staging
use the directive

Alias staging /var/www/myapp/staging/current/public 

for myapp.subdomain.domain.tld/development
use the directive

Alias development /var/www/myapp/development/current/public 

For further informations, take a look at the following mod_alias doc : http://httpd.apache.org/docs/2.0/urlmapping.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文