如何扩展现有的 Ruby on Rails CMS 以托管多个站点?

发布于 2024-09-04 15:57:26 字数 597 浏览 5 评论 0原文

我正在尝试构建一个可用于托管多个站点的 CMS。我知道我最终会在这个项目中重新发明轮子一百万次,所以我正在考虑扩展现有的开源 Ruby on Rails CMS 来满足我的需求。

这些需求之一是能够运行多个站点,同时仅使用一种代码库。这样,当我想要进行更新时,我可以在一个地方进行更新,并且更改会反映在所有网站上。我认为这将能够通过运行应用程序的多个实例来扩展。

我认为我可以使用域/子域来确定要显示哪些数据。例如,某人访问 subdomain1.mysite.com,应用程序在数据库中查找 subdomain1 的内容。

我看到的问题是大多数预构建的 CMS 解决方案,它们仅设计用于托管一个站点,包括我想要使用的站点。因此,数据库的结构适合在一个站点上使用。然而,我的想法是,我可以通过为每个站点“创建一个新数据库”来克服这个问题,然后根据我上面提到的域/子域指定要连接到的数据库。

我正在考虑在 Heroku 上托管这个,所以我想知道我对此的选择是什么。我对 Amazon S3 或 Amazon SimpleDB 不太熟悉,但我觉得有某种“云数据库”可以使这个解决方案比为每个站点创建一个新的 MySQL 数据库更加现实。

你怎么认为?我是否以错误的方式思考这个问题?您在这方面有什么建议?

I am trying to build a CMS I can use to host multiple sites. I know I'm going to end up reinventing the wheel a million times with this project, so I'm thinking about extending an existing open source Ruby on Rails CMS to meet my needs.

One of those needs is to be able to run multiple sites, while using only one code-base. That way, when there's an update I want to make, I can update it in one place, and the change is reflected on all of the sites. I think that this will be able to scale by running multiple instances of the application.

I think that I can use the domain/subdomain to determine which data to display. For example, someone goes to subdomain1.mysite.com and the application looks in the database for the content for subdomain1.

The problem I see is with most pre-built CMS solutions, they are only designed to host one site, including the one I want to use. So the database is structured to work with one site. However, I had the idea that I could overcome this by "creating a new database" for each site, then specifying which database to connect to based on the domain/subdomain as I mentioned above.

I'm thinking of hosting this on Heroku, so I'm wondering what my options for this might be. I'm not very familiar with Amazon S3, or Amazon SimpleDB, but I feel like there's some sort of "cloud database" that would make this solution a lot more realistic, than creating a new MySQL database for each site.

What do you think? Am I thinking about this the wrong way? What advice do you have to offer in this area?

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

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

发布评论

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

评论(2

墨小沫ゞ 2024-09-11 15:57:26

我曾经开发过这样的 Rails 应用程序,其实现方式是基于命名的虚拟主机,每个运行的站点都有数据库条目。如有必要,每个记录的范围都限定在一个站点(博客文章等),而用户可以访问该数据库之外的所有站点。管理员权限可以是全局的,也可以限于一个或多个站点。

当您说您将在项目期间重新发明轮子一百万次时,您是绝对正确的。插件可能需要对 CMS 本身进行黑客攻击。

在我的情况下,最终浪费了近一百万美元的公司资金来构建代码库来运行多个站点,同时仍然能够满足每个客户站点的突发奇想。它有效,但由于随后进入代码库的特定站点黑客的数量而不太可维护。如果您不必担心迎合在您的平台上运行的特定客户端网站,您也许能够使其发挥作用。

最后,无论采用何种方法,您都需要一个间接层来处理不同的站点。我们最终将其放入数据库本身。如果您使用您提到的 different-db-for-each-site 方法,您将将该层放入代码中。我不确定哪一种是更好的方法。

我希望你能成功。我失败了。

另外,正如我今天了解到的,Heroku 为 Rails 应用程序提供了 postgres 而不是 mysql。

I've worked on a Rails app like this, and the way it was done there was named-based virtual hosts, with db entries for each site running. Each record was scoped to a site if necessary (blog posts, etc.) while users would have access to all sites running out of that db. Administrator permissions could be global or scoped to one or more sites.

You're absolutely correct when you say you'll reinvent the wheel a million times during the project. Plugins will likely require hacking on top of the CMS itself.

In my situation, it ended up being a waste of almost a million dollars of company money to build that codebase to run multiple sites while still being able to cater to the whims of each client site. It worked, but was not very maintainable due to the number of site-specific hacks that subsequently entered the codebase. You may be able to make it work if you don't have to worry about catering to specific client sites running on your platform.

In the end, you're going to need a layer of indirection to handle the different sites regardless of methodology. We ended up putting it in the database itself. If you go with the different-db-for-each-site method you mentioned, you'll put that layer in your code instead. I'm not sure which one is the better method.

I hope you're able to pull this off. I failed.

Also, as I learned today, Heroku offers postgres instead of mysql for rails apps.

堇年纸鸢 2024-09-11 15:57:26

有 James Stewart 的用于 Rails 2.3 的 主题支持插件,以及 lucasefe 的 主题支持插件。 com/lucasefe/themes_for_rails" rel="nofollow">themes_for_rails gem 适用于 Rails 3+。

我刚刚开始使用2.3版本,到目前为止运行良好。

There's James Stewart's Theme Support Plugin for Rails 2.3, and lucasefe's themes_for_rails gem for Rails 3+.

I just started using the 2.3 version and it's working well so far.

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