使用 Apache 虚拟主机设置乘客?

dan*_*mcc 5 phusion-passenger ruby-on-rails-3 apache-2.2

我正在设置一个新服务器,我打算在该服务器上托管多个 Ruby on Rails 应用程序。

服务器正在运行 Ubuntu 10.04 LTS,我已经设置了 Apache 虚拟主机,因此每个应用程序都有自己的站点可用配置文件(指向 Rails 公共目录)。然后我建立了一个从sites-enabled/(CONFIG FILE HERE)到的符号链接sites-available/(CONFIG FILE HERE)

可用站点

root@HAH-UBUNTU-GER /etc/apache2/sites-available # ls
default  default-ssl  application1.com  application2.com
Run Code Online (Sandbox Code Playgroud)

启用站点(符号链接)

root@HAH-UBUNTU-GER /etc/apache2/sites-enabled # ls
000-default  application1.com  application2.com
Run Code Online (Sandbox Code Playgroud)

有关符号链接的更多信息:

root@HAH-UBUNTU-GER /etc/apache2/sites-enabled # ls -l
total 0
lrwxrwxrwx 1 root root 26 2012-05-04 11:41 000-default -> ../sites-available/default
lrwxrwxrwx 1 root root 39 2012-05-04 12:28 application1.com -> ../sites-available/application1.com
lrwxrwxrwx 1 root root 37 2012-05-04 12:09 application2.com -> ../sites-available/application2.com
Run Code Online (Sandbox Code Playgroud)

我已将所有 Rails 应用程序文件上传到/var/www/vhosts/application1.com并确保 Apache 配置文件指向公共目录。

Bundler、ruby gems 等工作正常,但我无法让乘客加载应用程序。

像往常一样,我使用 bash 脚本设置了服务器,该脚本包含以下与乘客安装相关的部分:

# Install and setup the Apache Passenger Module
yes '' | sudo /usr/local/bin/passenger-install-apache2-module

# Add the Passenger config to /etc/apache2/httpd.conf
sudo cat > /etc/apache2/httpd.conf << HTTPD_CONF
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-      3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
PassengerRuby /usr/local/bin/ruby
HTTPD_CONF
Run Code Online (Sandbox Code Playgroud)

application1.com 的完整虚拟主机配置文件是:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName application1.com
    DocumentRoot /var/www/vhosts/application1.com/public
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/vhosts/application1.com/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
Run Code Online (Sandbox Code Playgroud)

如果它有所不同,我将通过编辑我的主机文件以将服务器 IP 地址指向各个域来访问该网站。

当我访问该域时,我会得到一个公共目录的列表:

/public的目录列表

我认为我正在做一些明显错误的事情,但我无法弄清楚。任何帮助,将不胜感激。

有关更多信息,我使用的完整 bash 脚本在这里:https : //raw.github.com/deanperry/onelineserver/master/ruby192.sh

更新

Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK
Run Code Online (Sandbox Code Playgroud)

And*_* M. 4

根据文档,您将需要禁用乘客站点上的多视图。此外,您DocumentRoot应该指向包含 public 的目录,即 Passenger通过检查来检查所选目录是否包含乘客应用程序{DocumentRoot}/../config/environment.rb,因此请验证这是正确的。

如果您仍然感到困惑,请启用日志记录并找出为什么它认为您在该位置没有 Passenger 应用程序。