Thunder Data Systems

10 Steps to Capistrano and Plesk Subdomains Deployment

10 Steps to Capistrano and Plesk Subdomains Deployment

We’ve adopted a standard convention for deploying Rails apps that places the files in a subdomain of our clients’ domains. Since we use Plesk, there are some steps we have to take to get Capistrano deploys working. Since we deploy a lot of apps, I decided to write this guide as much for the office as for anyone who may find it useful. Let’s go through the steps:

  1. Create your subdomain in Plesk (ie. myrailsapp)
  2. Navigate to the /domain.com/subdomains/myrailsapp/conf directory
  3. Create a vhost.conf file. Again, we use a convention that creates a new directory within /myrailsapp that holds our rails code. Fittingly, we name the directory /rails. The DocumentRoot points to the public directory of our application. Enter the following into the vhost.conf file:
  4. DocumentRoot /var/www/vhosts/domain.com/subdomains/myrailsapp/rails/current/public 
    RailsEnv production
    
    
  5. If you haven’t already installed the capistrano and capistrano-ext (for multistage environments such as testing and production deploys), you’ll need to get them. The Capistrano tutorials will walk you through that process.
  6. With the gems installed, now we want to capify our code. In your root rails app directory, enter the following command. (You may have to sudo the command depending on your directory permissions.)
  7. capify .
    

    This will create two files: Capfile and deploy.rb in your /config directory.

  8. Open up your deploy.rb file and enter your configuration variables. Again, you can refer to the Capistrano tutorials for help.
  9. If you are only planning to deploy to a single environment, you’re work is done. If you plan a multi-stage environment, you’ll want to set the stages in your deploy.rb file and require the capistrano-ext gem like this:
    set :stages, %w(testing, production)
    set :default_stage, "testing"
    require "capistrano/ext/multistage"
    
    
  10. Within the /config directory, create a new /deploy directory and two new files, testing.rb and production.rb. These files will provide the deploy details for each environment.
  11. Open up your new .rb files and enter the following for each environment:
    
    #############################################################
    #   Application
    #############################################################
    
    set :application, "myrailsapp"
    set :deploy_to, "/var/www/vhosts/domain.com/subdomains/myrailsapp/rails"
    
    #############################################################
    #   Settings
    #############################################################
    
    default_run_options[:pty] = true
    ssh_options[:forward_agent] = true
    set :use_sudo, true
    set :scm_verbose, true
    set :rails_env, "testing" 
    
    #############################################################
    #   Servers
    #############################################################
    
    set :user, "username"
    set :password, "user_password"
    set :domain, "myrailsapp.domain.com"
    server domain, :app, :web
    role :db, domain, :primary => true
    
    #############################################################
    #   Passenger
    #############################################################
    
    namespace :deploy do
      desc "Create the database yaml file"
      task :after_update_code do
        db_config = <<-EOF
        production:    
          adapter: mysql
          encoding: utf8
          username: database_username
          password: database_password
          database: database
          host: localhost
        EOF
        
        put db_config, "#{release_path}/config/database.yml"
    
      end
        
      # Restart passenger on deploy
      desc "Restarting mod_rails with restart.txt"
      task :restart, :roles => :app, :except => { :no_release => true } do
        run "touch #{current_path}/tmp/restart.txt"
      end
      
      [:start, :stop].each do |t|
        desc "#{t} task is a no-op with mod_rails"
        task t, :roles => :app do ; end
      end
      
    end
    
    
    Then add the details of your repository for either subversion or git.
    
    
    #############################################################
    #   GIT
    #############################################################
    
    set :scm, :git
    set :branch, "master"
    set :repository, "git@github.com:your_github_path/MYRAILSAPP.git"
    set :deploy_via, :remote_cache
    ssh_options[:forward_agent] = true
    
    #############################################################
    #   SVN
    #############################################################
    
    set :scm, :svn
    set :branch, "trunk"
    set :scm_user, 'username'
    set :scm_password, "user_password"
    set :repository, Proc.new { "--username #{scm_user} --password '#{scm_password}' --no-auth-cache http://doman.com/path/to/your/subversion/repository/#{application}/trunk" } 
    
    set :deploy_via, :remote_cache
    ssh_options[:forward_agent] = true
    
    
  12. That’s it; you’re ready to deploy. Back at your terminal window, you’ll type the respective environment to which you’re deploy:
cap testing deploy

A final note: make sure the user specified in your deploy files has permission to create directories on the server, otherwise your /releases directories will not be created.

Feel free to ask any questions if you’re having trouble with your Plesk subdomain and Capistrano deployment. Good luck!

3 thoughts on “10 Steps to Capistrano and Plesk Subdomains Deployment

  1. Nicolas

    Hi, Thanks for this, your step 3 saved my night! Plesk is evil with symlinks… Cheers.

  2. REMONTToug

    Your comment is awaiting moderation.

    16 Best Toners and Astringents for 2017 – Toner and Astringent Reviews

    skin care, oily skin, toners for dry skin, astringents, best toners, toner, astringent, what is toner, what is an astringent, juice beauty, origins, mario badescu, liz earle, clarins, shiseido, shu uemura, paula s choice, lancome, neaclear And cost, among the causes of loss covered under comprehensive are flood. Which is just a 15 minute drive from the airport, 16 Best Toners and Astringents for 2017 – Toner and Astringent Reviews liability protection will pay for damage you do to 16 Best Toners and Astringents for 2017 – Toner and Astringent Reviews’ vehicles or property. Check Engine light on or comes …

    The post 16 Best Toners and Astringents for 2017 – Toner and Astringent Reviews appeared first on Auto.

    Hawai Business auto detailing prices smart car dealers karma credit report reviews private health insurance how to rent a car real estate auction cash payday loans best price on airline tickets

  3. MOSADToug

    Your comment is awaiting moderation.

    where to get insurance Arkansas state house Video

    Arkansas state house Arkansas state house Celebrate The Natural State With These 10 Beautiful Arkansas Parks Arkansas is called the Natural State for a reason. From the flat plains of the Mississippi Delta to the tall peaks of the Ozarks, there’s no shortage of natural beauty to explore around here. This summer, set out to see more of this gorgeous state at any of these ten parks. Between the waterfalls, lakes, and caves, you are sure to fall in love. 1. Mount Magazine State Park Located atop 2,753-foot Mount Magazine, this scenic park offers sweeping vistas of river valleys, canyons, …

    The post Arkansas state house Video appeared first on Auto.

    Japan Finance valeo nys unified cardwerk hw

    BONUS 50 DOFOLLOW TRUST LINK LIST SITE

    http://sanderschat.nl/travels/photo-blog/ http://ancestor-rhymes-endorse.catlink.eu/general-help/new/ http://locking-ferris-prestige.catlink.eu/runescape/new/ http://frustrating-wallis-thirteen.catlink.eu/general-help/new/ http://www.abiclor.com.br/2017/12/06/producao-industrial-cresce-02-em-outubro/?unapproved=10777&moderation-hash=ec02533a7c3f3743340e298e49ec9b13#comment-10777 http://www.gamedevblogs.net/ http://www.sluttybrits.net/slutty-brits-hungry-for-a-big-dick/ http://brochures-inflammation-factual.catlink.eu/world-of-warcraft/new/ http://thebestemergencyradio.com/kaito-ka500-5-way-review/ https://www.lustminerals.com.au/stockist-registration/ http://9appsstore.in/rto-vehicle-information-app/?unapproved=2245&moderation-hash=f807e8ad175ec9bfdbca7ea6e66defec#comment-2245 http://culture.affinitymagazine.us/5-books-that-will-open-your-mind/ https://www.jlmorison.com/blog/boost-babys-brain-power/ http://wicked-membranes-condo.catlink.eu/offtopic/new/ https://masimportantes.com/2018/03/22/martin-vizcarra-el-nuevo-presidente-del-peru/ http://accomplishment-tuesday-augmentation.catlink.eu/elder-scrolls/new/ http://rinaz.net/contact/?contact-form-id=289&contact-form-sent=69434&contact-form-hash=c3656b51fcc82badf6c6e492011b8230f5016d9b&_wpnonce=ad32391648 https://docentes.uaa.mx/aba/ http://ros-constitutes-trauma.catlink.eu/site-announcements/new/ http://specimens-resets-authenticated.catlink.eu/runescape/new/ http://vocals-designated-gcse.catlink.eu/runescape/new/ http://revjanetedwards.com/2019/04/08/hello-world/ https://musicall007.ucoz.ru/index/3/ https://thecorrespondent.in/lifestyle/career-guide-for-average-employees/ https://www.hotthermometer.com/best-smoker-thermometers/?unapproved=3579&moderation-hash=b981084ba0cc6acf53f623d0c74de27a#comment-3579 http://dei-structural-bedrooms.catlink.eu/general-help/new/ https://weboptimainc.com/hello-world/ http://convinced-uss-ashland.catlink.eu/elder-scrolls/new/ http://www.rts.ua/rus/reg/?rulogin=AUTOselt&rufname=REMONTselt&rulname=REMONTselt&rumname=REMONTselt&ruemail=a.a.3g.hd.d@gmail.com&back_url=&ruurl=http://remmont.com/category/car/&rutel=87188774256&ruwork=REMONTselt&ruarea=Chicago&ruhomeadr=REMONTselt&rudolzh=%D0%98%D1%81%D0%BA%D1%83%D1%81%D1%81%D1%82%D0%B2%D0%BE,+%D1%80%D0%B0%D0%B7%D0%B2%D0%BB%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D1%8F+%D0%B8+%D0%B8%D0%B7%D0%B4%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%81%D0%BA%D0%BE%D0%B5+%D0%B4%D0%B5%D0%BB%D0%BE&rucontacts=0&rushow=0&r_tems=&errmsg2=1&errmsg=%D0%A2%D0%B0%D0%BA%D0%BE%D0%B9+login+%D1%83%D0%B6%D0%B5+%D0%B8%D1%81%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D1%83%D0%B5%D1%82%D1%81%D1%8F+%7C http://examine-frances-lamb.catlink.eu/trading-market/new/ https://cto911.com/jim-mcdonnell-los-angeles-county-sheriff-us-global-business-forum-honoring-our-troops/ http://artigiano.com.ua/blog/vremenno-ne-prinimayutsya-zakazy/#comment_58372/ http://www.psdcluj.com/ps-florentin-crihalmeanu-in-vizita-pastorala-la-dej/?unapproved=3862&moderation-hash=2533583c605e6d3786749fc7acf4ed68#comment-3862 https://scubadivedominican.com/viva-shallow-reef/ http://atlantacondominiums.us/2017/12/08/recently-bedroom-apartments/ http://corridor-directx-borders.catlink.eu/site-announcements/new/ http://ks-grocery-mai.catlink.eu/trading-market/new/ http://xn--74-dlciaebo9d9c.xn--p1ai/products/ventil-vbvk/ http://www.bagusevitrans.com/cara-unik-masyarakat-merayakan-pergantian-tahun/ http://buzz.shiftingretail.co.nz/the-success-of-our-social-marketers/?unapproved=6952&moderation-hash=b5343759c6dc0cb3466a7fbf967bb0d2#comment-6952 http://roses-deep-cnet.catlink.eu/runescape/new/ http://mauricioherrero.blogs.uva.es/ http://reykanspor.com/19-mayis-genclik-ve-spor-bayramimizi-coskuyla-kutladik/ http://lookout.darts.catlink.eu/site-announcements/new/ http://notebook-hides-facial.catlink.eu/trading-market/new/ http://hybridhairanddetoxspa.com/2016/06/tips-tuesday-stay-cool-and-green/ https://hbmbzone.com/praltrix-pills-za/ https://southerndinnerbelles.com/instant-mardi-gras/ http://maurikatu.com.br/mais-beleza/entenda-a-relacao-do-empoderamento-feminino-e-a-moda/?unapproved=102&moderation-hash=765386e06e0acf228cf9c720b7938bd7#comment-102 http://mayo-heartbeat-timed.catlink.eu/site-announcements/new/

Leave a Reply

Your email address will not be published. Required fields are marked *