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.
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:
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'
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.
If that went ok, then you can now run the mighty:
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
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!