Deploying sites with SVN

Ever got fed up with FTP uploading multiple sites and forgetting which files need to go where? Sure you could delete the whole thing and upload it all, but that way you have downtime. I found a solution recently that works perfectly and is quick as hell.

I have a working copy on my dev site and the live site. live will be trunk, dev will be the branch I am working on or trunk depending on what I want to test on that environment.

It might sound a little nuts, but having SVN working copy on your server means you can easily deploy the new version of the site. Commit your local changes to the repo, then just SSH in and update!

This step-by-step guide will assume SVN binaries are already installed and you have SSH access.

1.) Log in via Putty or Terminal:

2.) Get to your public_web root. This will probably be something like /home/user/public_html/ but could vary.

$ cd /home/user/public_html

3.) Then simply check the repo out.

$ svn co .

Do not forget the full stop as that says to use the current directory and not create a new sub-directory.

4.) Do work.

5.) Update your site:

$ svn update

And there you have it. Each update you make will be deployed to your site when you run the svn update, minimum fuss.