Code, Computers & Random Junk

Deploy Octopress to a VirtualHost

When I was setting up this Octopress blog, I needed a function that was missing in the Rakefile. First, I wanted to test everything, not only use the preview function, but to test the deploy function as well. Also I figured if I have a local server to serve a blog (later)… One really doesn’t need the ssh keys etc.

Here’s the code I use.

In Rakefile: ~ line 250-252, add…

# === Custom: deploy to local server (eg virtual host) =================== #
# === Edits for Rakefile (Octopress)
# === After ":rsync", before ":push". (~ line: 250-252)

# Config :: path to folder (make sure it has a "/" in the end)
vhost_root = "/srv/www/"

desc "Changing default deploy method to rsync_vhost"
task :vhost do
  deploy_default = "rsync_vhost"

# Local environment
desc "Deploy website to virtual host (folder), via rsync"
task :rsync_vhost do
  exclude = ""
  if File.exists?('./rsync-exclude')
    exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'"
  puts "## Deploying to virtual host (#{vhost_root}), via rsync"
  ok_failed system("rsync -avz #{"--delete" unless rsync_delete == false} #{exclude} #{rsync_args} #{public_dir}/ #{vhost_root}")

# ======================================================================== #

Change this line to where you want your blog.

vhost_root = "/srv/www/"


rake vhost