我正在尝试设置一个设置,我想在同一个 Apache 服务器上运行 squirrelmail 和 Passenger,让一个 URL 指向 squirrelmail,其他一切都由 Passenger 处理。到目前为止,squirrelmail 和 Passenger 都可以自行正常运行,但当 Passenger 运行时,它会处理全部网址。
到目前为止,我已经尝试使用别名和重定向将 webmail/url 指向 squirrelmails 目录,但是没有作用。
这是我的 httpd.conf 文件:
<VirtualHost *:80>
ServerName not.my.real.server.name
DocumentRoot /var/www/sinatra/public
# Does not work:
#Redirect webmail/ /usr/share/squirrelmail/
#<Directory /usr/share/squirrelmail>
# Require all granted
#</Directory>
<Directory /var/www/sinatra/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
apache2.conf 为乘客添加了这些文件,除此之外,我没有对 Apache 的标准 Ubuntu Server 12.04 安装进行任何更改:
# passenger config
LoadModule passenger_module /home/kenneth/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
PassengerRoot /home/kenneth/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15
PassengerRuby /home/kenneth/.rvm/wrappers/ruby-1.9.3-p194/ruby
passanger config.ru 文件:
require './index'
run Sinatra::Application
答案1
尝试这个:
<VirtualHost *:80>
ServerName not.my.real.server.name
DocumentRoot /var/www
Alias /webmail "/usr/share/squirrelmail"
<Directory /usr/share/squirrelmail>
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/sinatra>
RackBaseURI /sinatra
PassengerResolveSymlinksInDocumentRoot On
PassengerAppRoot /var/www/sinatra
</Directory>
</VirtualHost>
更新
我认为我们可以告诉 Rails 忽略特定的 URL,方法是关闭PassengerEnabled
:
<VirtualHost *:80>
ServerName not.my.real.server.name
DocumentRoot /var/www/sinatra/public
<Directory /var/www/sinatra/public>
Order allow,deny
Allow from all
</Directory>
Alias /webmail "/usr/share/squirrelmail"
<Location /webmail>
PassengerEnabled off
</Location>
</VirtualHost>
试一试!