在nginx上与乘客一起运行roundcube

我最近试图在nginx上安装乘客。 安装工作,一切都很好。 不过,我想在我的服务器上运行roundcube webmail。

基本上我的问题是,nginx的根指令设置为乘客应用程序:

root /home/me/www/hello/public 

并且将roundcube创build为服务器上的符号链接,如下所示:

 /home/me/www/webmail 

我的问题如何获得URL www.my-server.com引用正常的根,但www.my-server.com/webmail引用roundcube文件夹?

我已经试过在我的nginx.conf中没有运气的变化:

 location /webmail/ { #root /home/me/www; alias /home/me/www; try_files $uri /index.php; passenger_enabled off; } 

当使用www.my-server.com/webmail时,上述configuration导致403禁止,使用URI:www.my-server.com/webmail/index.php时找不到File。

有任何想法吗?

这有点棘手,但我find了有关位置的nginx文档的解决scheme。

由于有一个匹配.php文件的位置指令,这将优先于/ webmail /位置,因为这不会声明根位置,所以将使用全局根目录,该根目录仍然指向乘客文件夹。

解决的办法是添加一个根指令到php匹配位置,并限制php执行到webmailpath,如下所示:

 index index.html index.htm index.php location /webmail/ { root /home/me/www; } location ~ /webmail/.*\.php$ { root /home/me/www; ... } 

现在一切正常。