在nginx上托管多个网站,类似于apache

时间:2012-07-23 20:31:07

标签: ruby-on-rails ruby deployment nginx

我试图在nginx中托管多个类似于apache的网站。在apache中,我们有一个名为htdocs的文件夹。我们将目录和文件放在htdocs中,如果URL类似于

www.example.com

然后我们可以访问htdocs文件夹中的目录和文件

www.example.com/exampledir1www.example.com/exampledir2

我想对nginx做同样的事情。可能吗。我公司的服务器有静态IP。我已经在它上面安装了nginx,默认情况下,我在nginx.conf文件中使用以下几行托管了一个rails应用程序

server {
  listen 80;
  server_name mycomp.does-it.net;
  root /var/www/mysamplerails/public;
  passenger_enabled on;
  rails_env development;
}

如果我访问网址“mycomp.does-it.net”,我可以访问此网站

现在我想要做的是拥有另一个rails应用程序并以mycomp.does-it.net/mysecondrailsapp作为根访问它。

我已经google了很多,我最终没有在哪里。我来自apache背景,这些是我在nginx中的第一次尝试。

1 个答案:

答案 0 :(得分:0)

使用 passenger_base_uri 选项。请参阅文档:Deploying to a sub URI