skip down to the 3 comments

Deploying WordPress to SliceHost using Capistrano and Git

Skip straight to the how-to if you don’t care about an introduction.

This post has been in my drafts folder for about 6 months, and I intended to be much more detailed, but I don’t think I’m gonna ever get round to it, so here is the shortened version.

I did a post a while back on how to deploy WordPress to TextDrive using Capistrano, which people seemed to find useful. I still use WordPress, and I still find Capistrano perfect for deployment in this situation. They’re the only two constants though, as I have now changed hosts, changed source control systems, oh and Capistrano has jumped up a major release and many minor releases, so the interface is slightly different.

I moved over to SliceHost because I wanted the control that virtual hosting gives you, and those guys are cheap, as well as having an awesome service thus far.

The actual installation of Apache, MySQL and PHP is quite simple through YUM and well documented via the Slicehost support area so I won’t repeat this. I also moved over to Git a while back, after researching distributed source control systems, and playing with Mercurial for a while. Git just seemed to tick more boxes for my current needs both at work, and home play.

1. Assumptions

I have based the post on the fact I choose to put all the sites I deploy in a my home directory. Some other assumptions are:

  • You have Apache, MySQL and PHP installed
  • You have an account on the machine with sudo access
  • You have a Git installed on the machine you will be deploying from

Now you need to organise your wordpress source into this structure:

README
Capfile
public/
    + index.php
    + wp-admin/
    + wp-xxxx
     etc ....

2. Configure Capistrano

You can download my basic Capfile that should help get you started. The only things you will need to change are :domain and :user. For example, for my site I may use:

set :domain, "whomwah.com"
set :user, "websites"

This would mean that I can normally access my server using:

ssh websites@whomwah.com

3. Initialise your Git repo

I kind of expect you to have already done this, but if you haven’t, change into the root directory (The one with the Capfile in it) and run:

git init
git add .
git commit -a -m 'initial import into Git'

4. Deploy

You should now have enough initial information to let Capistrano deploy WP to your server. First though, you need to run the Capistrano setup command to stick a bunch of folders on your server ready to hold your site. This is a good test command too as it lets you know if you have setup your :domain and :user ok.

cap deploy:setup

If that went ok, then you can now run the mighty:

cap deploy

That’s it! you should now have your blog deploying to your server.

5. Apache setup

All you need to do now is setup Apache to point to the folder. You can use this vhost file. Rename it and edit it’s contents to suit your site, then stick it in your

/etc/httpd/conf.d/

folder. Restart Apache:

sudo /sbin/services httpd restart

Now browse to your sites url and to the admin area and setup your blog as per the WordPress instructions. Best of luck!

There have been 3 responses to this post.

  1. Ionut G. Stan

    In the Assumptions section you said:

    You have HTTP, MySQL and PHP installed

    I believe you meant Apache, MySQL and PHP, but you were probably thinking to httpd :)

    Nice post otherwise. It helped me. Thanks.

  2. Duncan

    @Ionut G. Stan updated, thanks, can’t believe I never spotted that :)

  3. Marc Shaw

    Hey, I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog!…..I”ll be checking in on a regularly now….Keep up the good work! :)

    - Marc Shaw


back to the top