Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Apache2和Passenger部署基于机架的Ruby应用程序?_Ruby_Apache2_Passenger_Rack - Fatal编程技术网

如何使用Apache2和Passenger部署基于机架的Ruby应用程序?

如何使用Apache2和Passenger部署基于机架的Ruby应用程序?,ruby,apache2,passenger,rack,Ruby,Apache2,Passenger,Rack,我已经写了一个非常简单的“HelloWorld”ruby脚本,我想在apache2(2.4)和Ubuntu14.04上运行它。这不是rails应用程序,我不想使用rails框架,这只是一个单页应用程序 到目前为止,我只能得到一个目录列表。这是我的档案 正常运行时间.rb class Uptime def call(env) [200, {"Content-Type" => "text/plain"}, ["Hello world!"]] end end Gemfile

我已经写了一个非常简单的“HelloWorld”ruby脚本,我想在apache2(2.4)和Ubuntu14.04上运行它。这不是rails应用程序,我不想使用rails框架,这只是一个单页应用程序

到目前为止,我只能得到一个目录列表。这是我的档案

正常运行时间.rb

class Uptime
  def call(env)
     [200, {"Content-Type" => "text/plain"}, ["Hello world!"]]
  end
end
Gemfile

source 'https://rubygems.org'
gem 'rack', '~>1.5.1'
config.ru

require './uptime'
run Uptime.new
/etc/apache2/mods可用/乘客负载

LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
/etc/apache2/mods可用/passenger.conf

<IfModule mod_passenger.c>
  PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  PassengerDefaultRuby /home/mark/.rbenv/shims/ruby
</IfModule>

PassengerRoot/usr/lib/ruby/vendor\u ruby/phusion\u passenger/locations.ini
PassengerDefaultRuby/home/mark/.rbenv/shimmes/ruby
/etc/apache2/sites available/000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    PassengerRuby /home/mark/.rbenv/versions/2.3.1/bin/ruby      

    <Directory /var/www/html>
      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>

服务器管理员webmaster@localhost
DocumentRoot/var/www/html
PassengerRuby/home/mark/.rbenv/versions/2.3.1/bin/ruby
乘客继续往前走
通融
选项-多视图
要求所有授权
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合

乘客希望您的应用程序有一个
公用
tmp
目录:

  • public
    目录必须是您的
    DocumentRoot
    。如果Passenger被禁用/不工作,它将由Apache提供服务,因此没有人可以看到应用程序的源代码

  • tmp
    目录用于乘客的
    restart.txt

您的目录树应该如下所示:

/var/www/html/
├── config.ru
├── uptime.rb
├── Gemfile
├── public/
└── tmp/
在您的配置中:

<VirtualHost *:80>
    DocumentRoot /var/www/html/public
    # ...

    <Directory /var/www/html/public>
        # ...
    </Directory>

    # ...
</VirtualHost>

DocumentRoot/var/www/html/public
# ...
# ...
# ...

我以为公共目录是/var/www/html。这是我的文件所在的地方。这很有效,你能写下来作为回答吗?