Setting Up a Sandbox Server with SVNWritten by Mark Sanborn: Nov 6, 2008
SVN is one of those things that you love once you know what and how it works. SVN is a version control system used by almost all major open source projects and is an absolute dream to work with. If you have ever worked with a team of developers you probably have had the experience of having your code accidentally written over or deleted.
With SVN you have version control where you can revert changes, kinda like Wikipedia. It also keeps track of which files were actually modified and gives you an option to describe to other developers what changes were made. No more unfortunate mishaps. :)
What is great about SVN is that the code can be checked out to any server at any time with the latest code. I use SVN to make a “sandbox” server. A server that I can play around in without worrying about deleting code or messing something up. When I am happy with my changes I can type one command and the two servers are synced with the newest changes. If for some reason it doesn’t work out I can revert back to the old way in one easy command.
If you are using Dreamhost it is really easy to setup. Here is how:
Setting up SVN on Dreamhost
Go to dreamhost and make a svn.yourdomain.com directory
Make a svn project
Import your code to the SVN repository.
svn import . http://svn.yourdomain.com/myproject
Make a new folder
Check out the code
svn checkout http://svn.yourdomain.com/myproject . <----- don't forget the dot
At this point you swap the original site with the svned one. If you didn’t do something write thus far simply swap them back and start over.
mv yourdomain.com yourdomain.com-original
mv yourdomain.com-svn yourdomain.com
Make the Sandbox
Make a new subdomain called sandbox.yourdomain.com
Check out the SVN code
svn checkout http://svn.yourdomain.com/myproject .
Once again don’t forget the . (dot) at the end.
Lock the testing site
You probably don’t want people checking out your test site and certainly don’t want Google or any other bot to get a hold of it.
Open/create up your .htaccess in sandbox.yourdomain.com and fill it with:
AuthName "My Testing Site"
Then create a .htpasswd file.
Ignore test files
You definitely don’t want to accidentally lock your main site down by transferring .htaccess files or anything else over that doesn’t belong.
Fortunately for use SVN provides the ignore command. You can insert multiple lines from the commandline, just press enter inside the quotes:
$ svn propset svn:ignore ‘config.php [enter]
> database.php’ . [enter]
Note: If a file is already in the SVN it cannot be ignored. You must first delete it out. A good way to do this if your live site already has a .htaccess in SVN is to rename svn delete and then ignore then rename it back.
Although SVN is simple I could probably spend an entire post talking about it. Here are some of the basic commands that you will need to know.
Commit code to the SVN repository:
Update code to match the SVN repository (run this on the live server after you commit from testing):
Need to print shipping labels on your site?
Checkout my product RocketShipIt for simple easy-to-use developer tools for UPS™ FedEx™ USPS™ and more.