Browse files

initial commit

  • Loading branch information...
Adam Hunter
Adam Hunter committed Jun 3, 2009
0 parents commit 664caa6a15ffc7d942e43cb2eb0a56312a3ebb47
Showing with 111 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +2 −0 Capfile
  3. +36 −0 README
  4. +71 −0 config/deploy.rb
  5. 0 public/.gitignore
@@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+load 'config/deploy'
@@ -0,0 +1,36 @@
+Deploying WordPress with Capistrano
+Although anyone can use this, I doubt for the WP hobbiest it would be easier than FTP. However, I use Capistrano to deploy all of my Ruby on Rails application and thought it would be really nice to manage my WordPress blog with Capistrano. There are dozens of tutorials on setting up Capistrano, so be sure to check them out. This will require Ruby and the Capistrano Ruby Gem.
+Intended Directory structure:
+ /config/
+ /public/
+ /wp-config.php (this will be created upon deploy)
+There is a deploy.rb file inside of config already. Your WordPress installation should go in the public folder. Move wp-config-sample.php from public to config so that it can be copied and used on different development machines (like a database.yml.example).
+Once you have your files all set, you will need to convert this into a git repository so that you can do a Capistrano deployment. Since you're getting this from github, I am assuming you know how to do this.
+When you are ready to deploy your app for the first time, make sure you edit deploy.rb with your production environment specific information. You will need to set:
+application: this is the name of your application and the folder it will reside in on your server
+domain: this is the domain of your app as well as the git repository, you can setup a git_domain variable if they are different
+user: this is the user that will be used to ssh for cloning the repository and copying your files to your server
+port: this is the SSH port, I don't use 22 but if you do you won't need this
+db_name, db_user, db_pass, db_host and db_prfx are all pretty self explanatory if you have ever read through wp-config-sample.php. If you haven't, go do that right now.
+Once that is all set, you need to run:
+cap deploy:setup
+This will create the basic files and folders that you need for using a Capistrano deployed app. This will also create your wp-config.php and store it in the config folder. You do not need to create a wp-config.php file for your production machine. (Even the secret keys will be downloaded from WordPress). You only need to run "cap deploy:setup" to first time you want to deploy your application.
+cap deploy
+This is the command that you will run every time that you want to deploy updates to your WordPress app. It will symlink the wp-config from /config/wp-config.php to /root/wp-config.php because WordPress will look one directory up for a non public wp-config.php.
+Once everything is deployed you will need to make sure apache is serving from the app_path/current/public folder NOT the root folder.
+If you have any question or this isn't working for you, please let me know or fork it on github! If you can get the security keys to download over HTTPS (instead of HTTP) for auto-generating the wp-config.php that would be great!
@@ -0,0 +1,71 @@
+set :application, "NAME_OF_APP"
+set :domain, "DOMAIN_APP_AND_REPO_ARE_ON"
+set :user, "USERNAME"
+set :port, "PORT_IF_NOT_22"
+set :use_sudo, false
+set :scm, :git
+set :deploy_via, :remote_cache
+set :repository, "ssh://#{user}@#{domain}:#{port}/var/repos/#{application}.git"
+set :deploy_to, "/absolute/path/to/app/#{application}"
+role :app, domain
+role :web, domain
+role :db, domain, :primary => true
+namespace :deploy do
+ [:start, :stop, :finalize_update, :restart].each do |t|
+ desc "#{t} task is a no-op with just apache"
+ task t, :roles => :app do ; end
+ end
+ desc "Setup deploy"
+ task :setup, :roles => :app do
+ run "mkdir -p #{deploy_to} #{deploy_to}/releases #{deploy_to}/shared && chmod g+w #{deploy_to} #{deploy_to}/releases #{deploy_to}/shared"
+ end
+require 'erb'
+require 'open-uri'
+before "deploy:setup", :db
+after "deploy:update_code", "db:symlink"
+set :db_name, 'NAME'
+set :db_user, 'USER'
+set :db_pass, 'PASS'
+set :db_host, 'localhost'
+set :db_prfx, 'wp_'
+# https doesn't seem to work :(
+set :secret_keys, open('').read
+namespace :db do
+ desc "Create wp-config.php in shared path"
+ task :default do
+ db_config = <<-EOF
+ <?php
+ define('DB_NAME', '#{db_name}');
+ define('DB_USER', '#{db_user}');
+ define('DB_PASSWORD', '#{db_pass}');
+ define('DB_HOST', '#{db_host}');
+ define('DB_CHARSET', 'utf8');
+ define('DB_COLLATE', '');
+ #{secret_keys}
+ $table_prefix = '#{db_prfx}';
+ define ('WPLANG', '');
+ if ( !defined('ABSPATH') )
+ define('ABSPATH', dirname(__FILE__) . '/');
+ require_once(ABSPATH . 'wp-settings.php');
+ run "mkdir -p #{shared_path}/config"
+ put db_config.result, "#{shared_path}/config/wp-config.php"
+ end
+ desc "Make symlink for wp-config.php"
+ task :symlink do
+ run "ln -nfs #{shared_path}/config/wp-config.php #{release_path}/wp-config.php"
+ end
No changes.

0 comments on commit 664caa6

Please sign in to comment.