Low commit activity in last 3 years
No release in over a year
Deploy your WordPress projects with Capistrano 3.x
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 0

Runtime

 Project Readme

Capistrano::WordPress

A set of recipes for working with WordPress (via WP CLI) and Capistrano 3.

Installation

Add this line to your application's Gemfile:

gem 'capistrano', '~> 3.0.0'
gem 'wordpress-capistrano'

And then execute:

$ bundle

Or install it yourself as:

$ gem install wordpress-capistrano

Usage

Require the module in your Capfile:

require 'capistrano/wordpress'

wordpress/capistrano comes with 4 tasks:

  • wordpress:db:push - Exports your local database and imports it on remote server
  • wordpress:db:pull - Exports your remote database and imports it on your local
  • wordpress:db:deploy - Uploads the .sql in your version control and imports in on remote
  • wordpress:uploads:sync - Synchronises your local and remote wp-content/uploads folder so that you have all assets
  • wordpress:uploads:push - Pushes your local wp-content/uploads folder to the remote.
  • wordpress:uploads:pull - Pulls the remote wp-content/uploads folder to your local installation.
  • wordpress:paths - Updates WordPress paths to match latest release folders

You can run any of these by issuing the following commands..

$ bundle exec cap production wordpress:db:push
$ bundle exec cap production wordpress:db:pull
$ bundle exec cap production wordpress:db:deploy
$ bundle exec cap production wordpress:uploads:sync
$ bundle exec cap production wordpress:uploads:pull
$ bundle exec cap production wordpress:uploads:push
$ bundle exec cap production wordpress:paths

None of these tasks are built into the default Capistrano deploy as they are potentially damaging.

To add any of them, add the following code into your deploy.rb

after :updated, 'wordpress:db:deploy'
after :updated, 'wordpress:uploads:sync'

These are useful on sites where all content is under version control

Other Recommended Settings

This gem does not have libraries to perform common tasks like symlinking wp-content/uploads or symlinking database configuration files. Some recommended settings to go along with your deploy.rb are below.

Use Composer for WordPress and Plugins

{
	"repositories": [
		{
			"type": "composer",
			"url": "http://wpackagist.org"
		},
		{
			"type": "package",
			"package": {
				"name": "wordpress",
				"type": "webroot",
				"version": "3.8.1",
				"dist": {
					"type": "zip",
					"url": "http://en-au.wordpress.org/wordpress-3.8.1-en_AU.zip"
				},
				"require": {
					"fancyguy/webroot-installer": "1.0.0"
				}
			}
		},
	],
	"require": {
		"php": ">=5.3.0",
		"wordpress": "3.8.1",
		"fancyguy/webroot-installer": "1.0.0",
		"wpackagist/advanced-custom-fields": "*",
		"wpackagist/codepress-admin-columns": "*",
		"wpackagist/custom-post-type-ui": "*",
		"wpackagist/wordpress-importer": "*",
		"wpackagist/duplicate-post": "*",
		"wpackagist/simple-page-ordering": "*",
		"wpackagist/adminimize": "*"
	},
	"require-dev": {
		"wpackagist/debug-bar": "*",
		"wpackagist/pretty-debug": "*"
	},
	"extra": {
		"webroot-dir": "wp",
		"webroot-package": "wordpress"
	}
}

Use Linked Dirs and Linked Files

set :linked_dirs, %w{wp-content/uploads}
set :linked_files, %w{wp-config.local.php}

Configuration

Configurable options, shown here with defaults:

set :url, 'www.wordpress.org'
set :local_url, 'localhost'
set :wp_path, '.'
set :local_wp_path, '.'
set :wp_uploads, 'wp-content/uploads'
set :local_wp_uploads, 'wp-content/uploads'
set :wp_themes, 'wp-content/themes'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Also, please ask the owner of the capistrano-wordpress gem to give up his name!

Credits