Changing WeBrick Server Root
Ruby on Rails July 30th, 2008Recently I needed to change my WeBrick’s application root from /public to something else. If you need to have it running under a different directory, all of your routing to public stylesheets, images, etc. will have errors.
In your Rails directory open the file /vendor/rails/railties/lib/commands/servers/webrick.rb (or where you have installed Rails):
... OPTIONS = { :port => 3000, :ip => "0.0.0.0", :environment => (ENV['RAILS_ENV'] || "development").dup, :server_root => File.expand_path(RAILS_ROOT + "/public_html/"), :server_type => WEBrick::SimpleServer, :charset => "UTF-8", :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes, :debugger => false } ... |
You may change the settings for WeBrick including the port, environment and server root to use. Very handy stuff!
Recent Comments