如何使用基于 Rack 的应用程序配置 Vagrant + Apache + Passenger?

How to configure Vagrant + Apache + Passenger with Rack-based application?

我正在研究 Ruby 并尝试使用 Apache 和 Passenger 在 Vagrant 上 运行 this application。如果我在本地计算机上 运行 应用程序工作正常,但如果我尝试在 Vagrant 上 运行 它只显示 404 "nothing found" 页面。 我想我的问题是我无法正确编写 Vagrantfile 和 Apache 中的所有配置。我的应用程序有 404 页,因此它可以工作。但它在我尝试输入的任何 URL 上显示 404。 VagrantFile 包括:

  config.vm.box = "ubuntu/trusty32"
  config.vm.network :forwarded_port, guest: 80, host: 8080
  config.vm.synced_folder "./html/", "/var/www/html"

并提供(安装 apache2、Ruby 2.3.3、RVM 和 passenger)

在/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public
    PassengerRuby /home/vagrant/.rvm/gems/ruby-2.3.3/wrappers/ruby

<Directory /var/www/html/public>
      PassengerEnabled on
      Allow from all
      Options -MultiViews
      Require all granted
</Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

在 html 文件夹中 我还需要 apache 文件夹(tmp 和 public)

原来 REQUEST_PATH 变量在 Apache 上有另一个名字 (REQUEST_URI),这就是路由器总是返回 "Nothing found" 的原因。 所以我只是更改了这个变量,现在一切正常。