Nginx 和 Phusion Passenger(配置多个虚拟主机)

发布于 2024-11-04 19:17:54 字数 762 浏览 3 评论 0原文

我正在尝试使用 Phusion Passenger 和 Nginx 在本地计算机上设置多个 Ruby on Rails 应用程序。不幸的是,我似乎无法通过谷歌搜索找到一个好的解决方案。我见过的一些解决方案包括创建符号链接,但本质上我想做的是每个项目有一个不同的 nginx.conf ,并让 Phusion Passenger 从我的 ~/Sites/project/config/nginx.conf 加载该文件Ruby on Rails 应用程序。这可能吗?如果是这样,我怎样才能实现这一目标?如果没有,还有哪些其他解决方案可以为我指明正确的方向?

感谢您的帮助!

==========

可能的解决方案

==========

使用 RVM 我创建了一个新的 gemset,然后在该 gemset 下安装了 phusion guest gem,并且在安装 nginx 的过程中,我指定了nginx 安装在 ~/Sites/project/config/ 下

这实际上创建了以下目录

    • 配置
      • 会议
      • sbin

project/config/conf 内部存在 nginx.conf 文件,/project/config/sbin/nginx 使用该文件创建自己的虚拟主机。虽然我确信我可以在 /opt/nginx 中使用我的集中式 nginx 配置,但不同之处在于,这有助于创建一个可以轻松分发给也在该项目上工作的其他开发人员的项目。有什么想法/疑虑吗?

I am trying to setup multiple Ruby on Rails apps on my local machine with Phusion Passenger and Nginx. Unfortunately I can't seem to find a good solution for doing this with a google search. Some solutions I've seen included creating a symlink but essentially what I would like to do is have a different nginx.conf per project and have Phusion Passenger load that file up from perhaps ~/Sites/project/config/nginx.conf in my Ruby on Rails app. Is this possible? If so, how can I achieve that? and If not, what other solutions are there that might point me in the right direction?

Thanks for your help!

==========

Possible Solution

==========

Using RVM I created a new gemset, I then installed the phusion passenger gem under that gemset and during the installation of nginx, I specified the nginx to be installed under ~/Sites/project/config/

This essentially created the following directories:

  • project
    • config
      • conf
      • sbin

Inside of the project/config/conf exists the nginx.conf file which /project/config/sbin/nginx uses to create its own virtual host. Although I'm sure I can use my centralized nginx configuration at /opt/nginx , the difference is that this helps create a project that can be easily distributable to other devs who are working on the project as well. Any thoughts/concerns?

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

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

发布评论

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

评论(2

顾挽 2024-11-11 19:17:54

由于您使用的是 Mac,请尝试 http://pow.cx/

创建一个新项目/站点

cd ~/.pow
ln -s /path/to/myapp

然后您'将通过 http://myapp.dev 访问

Since you're on Mac, try out http://pow.cx/

To create a new project/site

cd ~/.pow
ln -s /path/to/myapp

Then you'll access via http://myapp.dev

久光 2024-11-11 19:17:54

这看起来可能适合您(请参阅以“上游...”开头的部分)。其基本作用是根据请求 URL 将传入请求指向不同的服务器集群(即使在本地运行)。

http://purab. wordpress.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/

此示例在后端使用 Mongrel 集群,但只需将其与当前配置进行比较,然后针对您的特定后端进行调整。

This looks like it might do it for you (see the sections starting with "upstream ..."). What this basically does is point the incoming requests to different server clusters (even if running locally) based on the request URL.

http://purab.wordpress.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/

This example uses Mongrel clusters on the back end, but just compare it to your current config, and make adjustments for your specific back end.

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