title: Deploying rails with capistrano, passenger and apache
body: <p>I have recently set up a VPS and am trying to deploy a rails app. I watched a screencast: <a href="http://railscasts.com/episodes/335-deploying-to-a-vps" rel="nofollow noreferrer">http://railscasts.com/episodes/335-deploying-to-a-vps</a> which explained how to setup capistrano and unicorn with nginx, but also gave examples for apache.</p>
  <p>I followed online guide for setting up passenger and adapted the railscasts capistrano recipe. When I run <code>cap deploy:setup</code> some directories are created on my server in the root of the application. Then when I run <code>cap deploy</code> the rails app is put into the releases folder and in a directory named by timestamp. So that part seems to work just fine.</p>
  <p>So then for a while when i navigated to <a href="http://dev.gregchapple.com/site/index" rel="nofollow noreferrer">http://dev.gregchapple.com/site/index</a> I got some passenger errors saying that certain gems were missing, so I installed them on the server using bundler then the errors went away. Thats when the current problem arose. Now when I go to <a href="http://dev.gregchapple.com/site/index" rel="nofollow noreferrer">http://dev.gregchapple.com/site/index</a> all it says is: &quot;We're sorry, but something went wrong.&quot;</p>
  <p>The apache log contains this:</p>
  <pre><code>cache: [GET /site/index] miss
  cache: [GET /] miss
  </code></pre>
  <p>Does anyone know what the problem is?
  My apache config file has been altered to set the document root to the public directory as specified by the passenger docs. I dont know what the problem is and its driving me insane!</p>
  <p>Any help is greatly appreciated :)</p>
  <h1>UPDATE</h1>
  <p>This is what appears the production.log file:</p>
  <pre><code>Started GET &quot;/site/index&quot; for 109.255.221.170 at 2012-08-06 13:26:13 -0700
  
  Mysql2::Error (Access denied for user 'root'@'localhost' (using password: NO)):
  mysql2 (0.3.11) lib/mysql2/client.rb:44:in `connect'
  mysql2 (0.3.11) lib/mysql2/client.rb:44:in `initialize'
  activerecord (3.2.1) lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
  activerecord (3.2.1) lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:277:in `new_connection'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:287:in `checkout_new_connection'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:235:in `block (2 levels) in checkout'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `loop'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `block in checkout' /home/greg/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
  activerecord (3.2.1) lib/active_record/query_cache.rb:67:in `rescue in call'
  activerecord (3.2.1) lib/active_record/query_cache.rb:61:in `call'
  activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__3520547282522082875__call__1971459733125288916__callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.1) lib/rails/engine.rb:479:in `call'
  railties (3.2.1) lib/rails/application.rb:220:in `call'
  railties (3.2.1) lib/rails/railtie/configurable.rb:30:in `method_missing'
  passenger (3.0.15) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.15) lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
  passenger (3.0.15) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
  passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
  passenger (3.0.15) lib/phusion_passenger/utils.rb:470:in `safe_fork'
  passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
  passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:180:in `start'
  passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
  passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
  passenger (3.0.15) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
  passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
  passenger (3.0.15) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
  &lt;internal:prelude&gt;:10:in `synchronize'
  passenger (3.0.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
  passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
  passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.15) helper-scripts/passenger-spawn-server:99:in `&lt;main&gt;'
  </code></pre>
  <h1>Update 2</h1>
  <h2>database.yml</h2>
  <pre><code>development:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: gregchapple_development
    pool: 5
    host: localhost
    username: root
    password: *****
    socket: /tmp/mysql.sock
  
  test:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: gregchapple_test
    pool: 5
    host: localhost
    username: root
    password: *****
    socket: /tmp/mysql.sock
  
  production:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: gregchapple_production
    pool: 5
    host: localhost
    username: root
    password: *****
    socket: /tmp/mysql.sock
  </code></pre>