Search code examples
ruby-on-railsapachepassengercapistranohttp-status-code-403

403 error after rails app deploy (apache + passenger)


This is my first rails app deploy, so please forgive me if the solution to this problem is obvious... I've been getting a 403 error (Forbidden) whenever I try to load my rails app in a browser. The deploy (using capistrano) is finally going ahead without errors, but there seems to be something wonky about my apache or passenger settings. It seems apache is trying to load an index file from the public folder rather than letting passenger intervene. I don't even get a passenger error screen when I load the app domain in a browser. I just get a Forbidden message. Has anyone else encountered the same problem?

Here's the actual error log:

[Mon Feb 27 10:03:12 2012] [error] [client xxx.xxx.xxx.xx] Directory index forbidden by Options directive: /usr/local/www/sites/project.example.ca/public/

I'm assuming this basically means it's erroring out because it can't find an index.html file, but Passenger should be intercepting it before it tries to look for an index file. So this is probably an apache error, but the virtual host is configured according to the tutorial...

I'm running rails 3.1.3, ruby 1.9.2-p290, capistrano 2.1.12, Apache 2.2, rvm 1.10.2 and whichever version of passenger would have been installed by the install script about a month ago. I followed this guide while setting up passenger: http://beginrescueend.com/integration/passenger/

Any help would be hugely appreciated! It feels like I've been trying to deploy this app FOREVER.

Here's my deploy file in case it helps:

$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) 
require "rvm/capistrano"

set :application, "Project"

set :scm, "git"
set :repository,  "ssh://[email protected]/usr/local/git_root/project.git"
set :user, "deploy"

#set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_ruby_string, "ruby-1.9.2-p290@project"
set :normalize_asset_timestamps, false

ssh_options[:forward_agent] = true

set :branch, "master"

set :deploy_via, :remote_cache

set :deploy_to, "/usr/local/www/sites/project.example.ca/public/"

set :use_sudo, false

set :domain, 'project.example.ca'

role :app, domain
role :web, domain
role :db,  domain, :primary => true

Solution

  • We figured out the 403 error. We were deploying to /usr/local/sites/www/project.example.ca/public. However, the way capistrano deploys, the actual application was at /usr/local/sites/www/project.example.ca/public/current/public. I blew away everything already there and tweaked the deploy.rb to point to /usr/local/www/sites/project.example.ca, and changed the virtual host to point to /usr/local/sites/www/project.example.ca/current/public, and now we get a Phusion Passenger error page at least.