Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:09:00+00:00 2026-06-14T06:09:00+00:00

I am trying to get a multistage deployment on my server and I am

  • 0

I am trying to get a multistage deployment on my server and I am having trouble getting a staging and production configuration running.

Server: Ubuntu 11.10 (GNU/Linux 3.0.0-19-server x86_64)

Here is what I have done so far:

  1. I created a new project called form_tester on my local machine. I am using a simple database with sqlite3 locally. I wish to use mysql2 on both staging and production.

  2. Setup directories for staging and production on server.

    /home/username/form_tester/staging
    /home/username/form_tester/production
    
  3. Made two databases on server for staging and production. I also configured them for access by a user with the correct privileges since I am able to generate the tables in them.

    ftstaging
    ftproduction
    
  4. Configured the config/database.yml file for both staging and production.

    staging: 
      adapter: mysql2 
      encoding: utf8 
      reconnect: false
      database: ftstaging
      pool: 5 
      username: dbuser 
      password: pass 
      host: server.com
    
    production: 
      adapter: mysql2 
      encoding: utf8 
      reconnect: false
      database: ftproduction
      pool: 5 
      username: dbusr 
      password: pass 
      host: server.com
    
  5. Configured the Gemfile for both staging and production.

    source ‘https://rubygems.org’

    gem 'rails', '3.2.8'
    gem 'jquery-rails'
    gem 'capistrano'
    
    group :development do
      gem 'sqlite3'
    end
    
    group :staging do
      gem 'activerecord-mysql2-adapter'
      gem 'mysql2'
    end
    
    group :production do
      gem 'activerecord-mysql2-adapter'
      gem 'mysql2'
    end
    
    # Gems used only for assets and not required
    # in production environments by default.
    group :assets do
      gem 'sass-rails',   '~> 3.2.3'
      gem 'coffee-rails', '~> 3.2.1'
      gem 'uglifier', '>= 1.0.3'
    end
    
  6. Ran Capify to get deployment files. Deleted everything from the deploy.rb file. Left the Capfile alone.

  7. Created deploy directory and made two files.

    config/deploy/production.rb
    config/deploy/staging.rb
    
  8. Added the following details for configuration:

For config/deploy/production.rb:

    server "server.com", :app, :web, :db, :primary => true
    set :deploy_to, "/home/username/form_tester/production"
    set :rails_env, "production"

For config/deploy/staging.rb:

    server "server.com", :app, :web, :db, :primary => true
    set :deploy_to, "/home/username/form_tester/staging"
    set :rails_env, "staging"

For config/deploy.rb:

    set :stages, ['production', 'staging']
    set :default_stage, 'staging'
    require 'capistrano/ext/multistage'

    # Set application name
    set :application, 'form_tester'
    set :domain, 'server.com'
    set :user, 'username'

    # Use Git source control
    set :scm, :git
    set :repository, "ssh://#{user}@#{domain}/home/#{user}/git/#{application}.git"
    set :branch, 'master'
    set :deploy_via, :remote_cache
    set :scm_verbose, true

    default_run_options[:pty] = true
    set :use_sudo, false

    namespace :deploy do
      task :start do ; end
      task :stop do ; end

      desc "Restart application"
      task :restart, :roles => :app, :except => { :no_release => true } do
        run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
      end
    end

9.Initialized git repo on server with git –bare init and made sure I have proper access to the directory for the current username.

10.Initialized git repo on dev machine and pushed the files to the server repo at
ssh://username@server.com/home/username/git/form_tester.git.

11.Begin deployment from local machine to staging on server. I run all the following commands with no errors.

To build the directory tree under /home/username/form_tester/staging

    $ cap deploy:setup
    $ cap deploy:check
    $ cap deploy:update

    *ssh'ed into my server*

    $ rake schema:db:load
    $ rake db:seed
    $ rails console
    > app.get('/')
    I get a '200' returned
    > exit

still ssh’ed into my server

12.I made a symlink from /var/www/staging to my application public directory

    /home/username/form_tester/staging/current/public.

    $ sudo ln -s /home/username/form_tester/staging/current/public /var/www/staging

13.Modified the /etc/apache2/sites-available/default file to add a subURI for the staging app.

    $ sudo vi /etc/apache2/sites-available/default

    …
            RailsBaseURI /staging
            <Directory /var/www/staging>
                    Options -MultiViews
            </Directory>
    …

14.At this point (locally) I run cap deploy:restart and it seems to restart the server since there is no error. (logged into the server) I also tried sudo service apache2 restart, which also restarts the server fine.

15.At this point I pull up the url server.com/staging but don’t see my app.

Other files:

config/application.rb:

    require File.expand_path('../boot', __FILE__)

    require 'rails/all'

    if defined?(Bundler)
      Bundler.require(*Rails.groups(:assets => %w(development test)))
    end

    module FormTester
      class Application < Rails::Application
        config.encoding = "utf-8"
        config.filter_parameters += [:password]
        config.active_support.escape_html_entities_in_json = true   
        config.active_record.whitelist_attributes = true
        config.assets.enabled = true
        config.assets.version = '1.0'
      end
    end

config/environments/staging.rb and production.rb

    FormTester::Application.configure do
      config.cache_classes = true
      config.consider_all_requests_local       = false
      config.action_controller.perform_caching = true
      config.serve_static_assets = false
      config.assets.compress = true
      config.assets.compile = false
      config.assets.digest = true
      config.i18n.fallbacks = true
      config.active_support.deprecation = :notify
    end

/var/log/apache2/error.log

There seems to be nothing ruby related showing up here except phusion passenger, but it’s not an error.

    [Thu Nov 01 01:16:11 2012] [notice] caught SIGTERM, shutting down
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gd.so' - /usr/lib/php5/20090626/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/mcrypt.so' - /usr/lib/php5/20090626/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
    [Thu Nov 01 01:16:12 2012] [notice] Apache/2.2.20 (Ubuntu) DAV/2 SVN/1.6.12 PHP/5.3.6-13ubuntu3.7 with Suhosin-Patch Phusion_Passenger/3.0.17 configured -- resuming normal operations
    [Thu Nov 01 01:16:20 2012] [error] [client 68.6.38.254] File does not exist: /var/www/favicon.ico
    [Thu Nov 01 01:16:22 2012] [error] [client 68.6.38.254] File does not exist: /var/www/favicon.ico
    [Thu Nov 01 01:23:07 2012] [error] [client 68.6.38.254] File does not exist: /var/www/favicon.ico

Observations:

  1. Running rake schema:db:load appears to build the tables properly for my database but its actually building them for the development.sqlite3 file.

  2. If I open the rails console and run Rails.env, I get “staging” as the environment.

  3. This is most likely tied with #1, rake db:seed doesn’t seem to fill my database called “ftstaging” in mysql on the server even though it executes.

  4. cap deploy doesn’t seem to do anything different than cap deploy:update.

  5. The end result is a page at server.com/staging that says “We’re sorry, but something went wrong.”

  6. There doesn’t seem to be anything shown in my

  7. Running rake about shows that I am still in development mode.

    About your application's environment
    Ruby version              1.9.3 (x86_64-linux)
    RubyGems version          1.8.24
    Rack version              1.4
    Rails version             3.2.8
    JavaScript Runtime        Node.js (V8)
    Active Record version     3.2.8
    Action Pack version       3.2.8
    Active Resource version   3.2.8
    Action Mailer version     3.2.8
    Active Support version    3.2.8
    Middleware                ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000002796948>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport
    Application root          /home/username/form_tester/staging/releases/20121101080752
    Environment               development
    Database adapter          sqlite3
    Database schema version   20121030011807
    

I have tried the following tutorials with little luck:

  • https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
  • http://trevmex.com/post/367574671/steps-for-setting-up-a-capistrano-multistage-deployment
  • http://cjohansen.no/en/apache/multi_staging_environment_for_rails_using_capistrano_and_mod_rails
  • http://guides.beanstalkapp.com/deployments/deploy-with-capistrano.html#prepare-project

Questions:

I’m sure there is someone out there that understands the deployment process in and out, what am I missing?
What should I check for?
From what I have shown here, what can I do differently?

Any help is greatly appreciated at this point. I have been fighting with this issue for two days now and don’t know what I’m doing wrong and don’t know what else to try. I just started using rails about 3 weeks ago and most of my frustration has been due to not being able to find a clear description of the process for deployment. I hope to gain clarity on this issue and in return help others get from idea to multistage deployment easily.

On another note, why would someone “down vote” this post? I’m asking a legit question with information to back it up. If it’s not a good question please tell me why. Thanks


11/1/12 – UPDATE:

I figured out how to get my app into the “staging” environment but it still doesn’t load at server.com/staging.

I added “Rails.env = ActiveSupport::StringInquirer.new(‘staging’)” into my config/application.rb file, but I don’t know why this forces the environment. Is this the correct way to do it?

I then deployed, ssh’ed into my server as username, and ran rake db:migrate and rake db:seed. I now see my database populated.

What else could be going on? Is there something wrong with my environments/staging.rb file?


/etc/apache2/httpd.conf

ServerName server.com

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:09:01+00:00Added an answer on June 14, 2026 at 6:09 am

    I FINALLY discovered the the primary issue: the asset pipeline

    First issue: I didn’t uncomment the following line form the Capfile

    load 'deploy/assets'
    

    AND

    Second issue: I never compiled the assets (on development machine or server side. big whoops!)

    $ bundle exec rake assets:precompile
    

    References

    • http://guides.rubyonrails.org/asset_pipeline.html
    • Rails/Bundler precompile vs lazy compile

    Followup question to anyone who may know:
    I noticed that when I compiled the assets, it says RAILS_ENV=production instead of staging. When making the staging.rb file I basically copied the production.rb file. I’m not sure if that has anything to do with it saying production.

    Is this expected?

    /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p194@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a multistage capistrano deployment to my production and staging servers.
Hello everyone I been trying get php uploader working but having a lot of
I'm having trouble setting up a new server using Moonshine and Capistrano. It seems
When trying get in memcache client, getting the below excepton. Caused by: java.io.IOException: com.fet.myclass.webservice.data.DataList
Trying to get a login script working, I kept getting the same login page
Hi am trying get GPS using network provider and GPS provider. but am getting
I am trying get content from the link https://....com:8455 where Server's certificate is not
I'm trying get online friends by user in XMPP server (Ejabberd). I'm using Ruby
I am trying get the data from my database but i am not getting
http://lxr.linux.no/linux+v2.6.35/include/linux/preempt.h#L21 I am just trying get the linux source. I saw this preempt count

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.