質問

I'm new to ruby on rails and I have been using JustHost to try my test rails app. However, according to my understanding, JustHost uses Phusion Passenger to deploy rails app. I can get the local version to work, it is just a new app created by using "rails new testapp", but I keep getting this error:

No such file or directory - config.ru

I'm able to run rails s on the server and receive the following results:

=> Booting WEBrick
=> Rails 4.0.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-03-21 12:35:49] INFO  WEBrick 1.3.1
[2014-03-21 12:35:49] INFO  ruby 1.9.3 (2013-05-15) [x86_64-linux]
[2014-03-21 12:35:49] INFO  WEBrick::HTTPServer#start: pid=17181 port=3000

And running bundle exec passenger start gives me the following:

=============== Phusion Passenger Standalone web server started ===============
PID file: /home4/USER/APPNAME/tmp/pids/passenger.3000.pid
Log file: /home4/USER/APPNAME/log/passenger.3000.log
Environment: development
Accessible via: http://0.0.0.0:3000/

You can stop Phusion Passenger Standalone by pressing Ctrl-C.
Problems? Check http://www.modrails.com/documentation/Users%20guide%20Standalone.html#troubleshooting
===============================================================================
App 23867 stdout: 
[ 2014-03-21 12:36:54.9704 23567/7f2d68154700 Pool2/SmartSpawner.h:301 ]: Preloader for /home4/USER/APPNAME started on PID 23867, listening on unix:/tmp/passenger.1.0.23557/generation-0/backends/preloader.23867
App 24159 stdout: 


Started HEAD "/" for 127.0.0.1 at 2014-03-21 12:36:55 -0600
Processing by Rails::WelcomeController#index as HTML
  Rendered /home4/USER/ruby/gems/gems/railties-4.0.3/lib/rails/templates/rails/welcome/index.html.erb (4.8ms)
Completed 200 OK in 92ms (Views: 54.4ms | ActiveRecord: 0.0ms)

I followed the tutorial on JustHost, but I still cannot access the page. my.justhost.com/cgi/help/rails

And I've also modified my .htaccess in public folder to the following without success. After changing to the following code, when I visit the public folder for my rails app, I would see a list of files in the folder, ex. 404.html, 422.html etc.

<IfModule mod_passenger.c>
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Set this to whatever environment you'll be running in
RailsEnv production
#Set this to work with Phusion Passenger online 
RackBaseURI /home4/USER/APPNAME
SetEnv GEM_HOME /home1/examplec/ruby/gems
</IfModule>

USER is my username and APPNAME is the name for my rails app.

Thanks for all your help.

In addition to all the above information, I am attaching my Gemfile as a reference too:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
gem 'passenger', :require => false
# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

gem 'execjs'
gem 'therubyracer', :platforms => :ruby

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]
役に立ちましたか?

解決

I had the exact same problem. Took me an hour to figure something out.

No such file or directory - config.ru

This line tells you the problem. It cannot find "config.ru" file. My version of the config.ru file reads:

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run Broadsheet::Application

For me, this config.ru file is found in my "/home4/USER/rails_apps/APPNAME" folder so it may be in your "/home4/USER/APPNAME" folder. It auto-generated so it wasn't something I added myself but you may have to.

Since Passenger cannot find this config.ru file, perhaps it is missing from the folder I specified or there is something wrong inside your "home4/USER/APPNAME/public/.htaccess" file, particularly the line that reads:

RackBaseURI /home4/USER/APPNAME

This is the directory that Passenger seems to use in order to find the config.ru file. I would double-check to make sure that line doesn't have a typo somewhere.


As a sidenote, currently I've gotten the Passenger error to go away but I still can't get any of the views or anything except the static pages in the public folder to show or not give me 404 not found errors.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top