Provisioning & Deploying a LAMP Wordpress Stack with Sprinkle and Capistrano

Matt Swasey, Former Viget

Article Category: #Code

Posted on

Recently I had to provision a number of slices for use as LAMP stacks running Wordpress installs. Creating a LAMP stack is not exactly difficult but it's also not that fun, so I decided to use Sprinkle and Capistrano to aid in my task.

In the end, I had a Sprinkle recipe and Capistrano script that saved me a lot of time. Here's what I came up with and how I used it.


After creating your slice / vps and adding a user with sudo privileges for yourself, clone the lamp-sprinkle repository I've created on Github and edit the contained deploy.rb file:

 git clone git:// cd lamp-sprinkle/ // edit deploy.rb changing: role :app, "" set :user, "username" 

Then, issue the Sprinkle command and point it at the lamp recipe:

 sprinkle -c -s lamp.rb 

When the script is done running, you should have a fully functioning LAMP stack running on your slice, ready for your Wordpress or any other PHP application.


Having used Capistrano with version control for a while now, I couldn't bring myself to deploy any manner of web application using a method like straight (s)ftp. I went searching for people deploying PHP applications with Capistrano and found Duncan's post on doing just that.

Assuming you've got your wordpress install in a git repository, place this Capfile in your local working copy.

Now just run the normal Capistrano deployment commands:

 cap deploy:setup cap deploy 

All the normal rules apply here, your deploy user will need write permission to the deploy_to directory, and you will need an apache vhost file in your /etc/apache/sites-available turned on.

Other Ideas

You could take these two scripts and run with them in different directions if desired. The Sprinkle script could go inside your wordpress repo, use the Capistrano information in the Capfile, and contain code to configure your vhost file for you. Since I was provisioning a couple slices at the same time, I decided to go with the above, more general approach.

If you've found a nicer approach to provisioning LAMP stacks or deploying PHP applications, let me know in the comments.

Related Articles