Deploying sites with SVN

Posted: Oct 02, 2008  Category: 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 enviroment.

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:

ssh user@yoursite.com

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 http://svn.whatever.com/repo/trunk .

DONT forget the ”.” at the end, otherwise you will get a folder in your root called trunk. The ”.” means this folder.

4.) When you look at your web root you will probably now see Internal Server Error 500 and start freaking out. Have no fear, chown is here!

The files you checked out master-less, like a Ronin wandering with no direction. The following command will let them know who’s boss and set their owner/group.

sudo chown -R <username>:<username> ../public_html

What next?
To update your working copy, you can repeat steps 1 and 2 to log back in, then simple type:

svn update

It’s very damn satisfying to watch the entire new site deploy in under 30 seconds, and you can rest assured that you didn’t forget a file or delete the wrong thing.

I will explain some more SVN commands later on as I have recently got a little bit ninja with the Terminal on my Mac. Until then, good luck fellow command line warriors.

Comments

They said... There are no comments
You say...?