我很难学习如何使用Sinatra。我终于安装了phusion-passenger,并在Ubuntu上使用我的apache2。我有以下的目录和文件hello world sinatra app error
/var/www/html
/var/www/html/public
/var/www/html/tmp
/var/www/html/config.ru # this is a file
的/var/www/html/config.ru
内容是从https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#_tutorial_example_writing_and_deploying_a_hello_world_rack_application复制。
当我启动这个应用程序,我得到你好世界,这是伟大的。
接下来,我想构建一个Sinatra应用程序。我继续创建文件
/var/www/html/myapp.rb
与http://www.sinatrarb.com/intro.html描述的内容。我也做了一个gem install sinatra
。我重新启动了Apache。然后我去了http://localhost/
,但我仍然看到我的config.ru
的hello world
。于是我用myapp.rb
重写了config.ru
的内容。我重新启动了Apache。但现在我收到一条错误消息
missing run or map statement (RuntimeError)
/usr/lib/ruby/vendor_ruby/rack/builder.rb:133:in `to_app'
config.ru:1:in `<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in `eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'
我在做什么错?我如何构建一个Hello World世界的Sinatra应用程序?
我建议先学习并测试Sinatra的独立模式。一旦你对此感到满意,然后将其连接到Passenger。尝试使用Passenger最初只会让你需要理解的内容变得更多,并且使得更难确定哪些内容会在堆栈中发挥作用。就其本身而言,Sinatra非常易于使用,并且不需要其他任何东西来处理HTTP请求。这是一个相当有能力的小型网络服务器DSL,特别是在与Haml和Thin配合使用时。 Sinatra的主页显示了如何创建一个“hello world”应用程序,它只需要三行代码就可以完成。 – 2014-10-16 17:10:06