简体   繁体   English

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

[英]Nginx and Phusion Passenger (Configuring mutliple Virtual Hosts)

I am trying to setup multiple Ruby on Rails apps on my local machine with Phusion Passenger and Nginx.我正在尝试在我的本地机器上使用 Phusion Passenger 和 Nginx 在 Rails 应用程序上设置多个 Ruby。 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.我见过的一些解决方案包括创建一个符号链接,但基本上我想做的是每个项目有一个不同的 nginx.conf 并让 Phusion Passenger 从我的 ~/Sites/project/config/nginx.conf 加载该文件Ruby on Rails 应用程序。 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/使用 RVM 我创建了一个新的 gemset,然后在该 gemset 下安装了 phusion 乘客 gem,在 nginx 的安装过程中,我指定了 nginx 安装在 ~/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.在 project/config/conf 中存在 nginx.conf 文件,/project/config/sbin/nginx 使用它来创建自己的虚拟主机。 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.虽然我确信我可以在 /opt/nginx 中使用我的集中式 nginx 配置,但不同之处在于这有助于创建一个可以轻松分发给其他正在从事该项目的开发人员的项目。 Any thoughts/concerns?有什么想法/担忧吗?

Since you're on Mac, try out http://pow.cx/由于您使用的是 Mac,请尝试http://pow.cx/

To create a new project/site创建新项目/站点

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

Then you'll access via http://myapp.dev然后您将通过http://myapp.dev访问

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.这基本上是根据请求 URL 将传入请求指向不同的服务器集群(即使在本地运行)。

http://purab.wordpress.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/ 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.此示例在后端使用 Mongrel 集群,但只需将其与您当前的配置进行比较,并针对您的特定后端进行调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM