Skip to content

Deploy Setup

jnand edited this page Oct 28, 2015 · 1 revision

Deploy user

Create a dedicated deploy user on the target host with primary group same as the webserver

on targethost:

$ sudo adduser --ingroup www-data deploy    

SSH Keys

Create an ssh key pair so the deploy user can access any remote repos

on targethost:

$ cd /home/deploy
$ ssh-keygen

Add the generated public key to github's allowed keys

Add your local machines public key to the deploy user's ~/.ssh/authorized_keys file on the target host. Now capistrano can SSH without prompting for a password.

on localhost:

$ scp ~/.ssh/id_dsa.pub deploy@targethost:~/
$ ssh deploy@targethost

on targethost:

$ cd ~/
$ cat id_dsa.pub > .ssh/authorized_keys

Install drush

on localhost: repeat on targethost:

$ git clone git@github.com:drush-ops/drush.git
$ cd drush
$ git checkout 6.x
$ ln -s /path/to/drush/drush ~/bin/drush

Install rvm and gemset

on localhost: repeat on targethost:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

$ rvm gemset create gladstone_org
$ rvm use @gladstone_org
$ cd gladstone_org.git
$ gem install bundler
$ bundler install

Test if cap can connect

Test that capistrano can connect to the deploy target, assuming the stage config file is set up correctly and specifies the deploy user we just created

on localhost:

$ cd /path/to/gladstone_org.git
$ rvm use @gladstone_org
$ rvm cap stage deploy:check

Webserver

Setup the remote target's host webserver to serve pages from "current" under the deploy_to path, via the vhost.conf's DocumentRoot

on targethost:

$ cd deploy_to_path/current
"path/to/deploy_to/current"
$ vim /etc/apache/vhost.conf

Mysql

Make sure both the local host and target host have mysql installed and listening on the standard port on 127.0.0.1

Deploy the projects

on localhost:

$ cd gladstone_org.git
$ rvm use @gladstone_org
$ cap stage deploy 
$ cap stage drupal:migrate init=true

Notes

The deploy user might also need passwordless sudo for chgrp and chmod depending on the target host's configuration.