05 July 2011

Amazon do a free low power/memory/everything server called a Micro Instance. This is perfect for a bunch of websites that don't get used much or even as an SVN server. Did I mention it was free?

Setting up SVN looks tricky at the outset, but it really isn't. Assuming you've already got an AWS account...:

1. At the AWS management console "Launch Instance", go to "community AMI's" and select Alestic's latest 32-bit Ubuntu build (you can find a list at alestic.com - click on the region you want (ie US-East 1), and then copy the AMI-1234567 and paste it into the search box on the "community AMI" AWS page. There should be a star next to it to indicate that it will be free micro instance. Click select to use that AMI.

2. Make sure the instance type is micro. If you can't select a micro instance then you need to use a different AMI (or a different region). Then follow the options and set up the server as you would normally. I won't cover that here (there are plenty of tutorials out there for setting up an instance), though do get yourself an elastic IP and assign it to the new instance.

3. Now your instance is running you need to open up TCP port 3690 for the SVN service to hear from the outside. Find the security group that your instance is using, select it, click on the "inbound" tab, and add a new rule: TCP, 3690, 0.0.0.0/0 and then click "add rule" and then "apply rule changes".

4. SSH into your instance and run the command "sudo apt-get install subversion" to install svn

5. Create the directory to be used for subversion, for example "mkdir ~/svn". Your projects will go inside this folder. The newer instances may require you sudo the commands if they don't work - if you do use sudo you'll need to change the permissions or ownership on the svn folder and subfolders.

6. Create the project: "sudo svnadmin create ~/svn/myproject", again you may need to set the permissions here "sudo chmod -R g+rws ~/svn"

7. Under the new project directory (in the conf subfolder), edit svnserve.conf, remove the # before "anon-access" and change it to "none", then remove the # before "auth-access" and "password-db" lines. Remove the # before the "realm=" and give it a custom name.

8. Edit passwd, add a line entry with the user name(s) and password(s) to be used for access.

9. The SVN server will work locally, but we need it to respond to remote instructions, so set up the service by calling "svnserve -d -r ~/svn" Now in your SVN client of choice commandline (why?), TortoiseSVN (windows) or RabbitSVN (linux) you can access via the SVN protocol: svn://[elastic ip address]/[project name] using the username and password you set in the passwd file in step 8.

If your instance is rebooted you'll need to SSH back in and repeat step 9. In order to have it start automagically at boot up follow MichaƂ Wojciechowski's instructions under "Svnserve Initialization Script" which worked for me!


blog comments powered by Disqus