Svn – Setting up SVN on a hosted server

svn

I was just wondering is someone would kindly help me with my installation of subversion on a hosted (dedicated) linux webserver that I'm struggling with.

I have a dedicated Linux server that I rent and the team have installed subversion for me (/usr/bin) and that is all. I have been told that I can use PuTTY to connect to the server which I have been able to do.

Now I have 15 plus websites hosted on the server and WHM is installed to manage these; therefore I would like to create a repository for each and put the source code into each. Then I would use TortoiseSVN to create repositories on my local machine and then it would be good to apply those commit to the live server.

I have read through elements of the SVN book; however, I'm really struggling and would appreciate some help in a) setting up a repository correctly and creating all the necessary permissions and security and then b) how do I get the changes from my local machine to the live server – again help would be greatly appreciated in what I assume is creating a hook script to transfer files to the live server?

Thanks

P.S. It would really help me if someone could provide simple steps for the above and the code required as I've been at this for some weeks now and cannot seem to get it underway.

Best Answer

On your server:

1) Ensure subversion is installed -- yum/apt-get/etc should make it quite easy.

2) Create a directory to hold a repository: mkdir /some/repository/path

3) Use svnadmin to create the repository layout: svnadmin create /some/repository/path

4) Import your sources:

$ cd /path/to/your/code
$ svn import -m "initial import" . file:///some/repository/path/trunk

NOTE: this imports the code into the repo, but does NOT create a working copy! So, next:

5) Move your original files out of the way, and check out a working copy:

$ cd ..
$ mv /path/to/your/code /path/to/your/code-presvn
$ svn co file:///some/repository/path/trunk code

5.5) You probably want to ensure that people can't browse your .svn directories via the web server. For apache, something like the following in httpd.conf should do it:

<Directory ~ "\.svn">
    Order allow,deny
    Deny from all
</Directory>

6) Test your site, ensure permissions are correct, etc. Checking out a fresh copy may have created issues. It's probably a good idea to document (or even better, script) any changes that will need to be done to properly configure a newly checked-out copy.

7) To get a local copy for development, use a repository URL like svn+ssh://username@yourhostname.com/some/repository/path/trunk I'm not familiar with tortoisesvn, but if you were using the standard command-line tools, you'd check out your project like:

$ svn co svn+ssh://username@yourhostname.com/some/repository/path/trunk

You then can make changes to your local working copy, and commit thing (svn commit -m "description of changes"). When you want to move those changes to your production system, ssh into the box, cd /path/to/your/site, svn -u status (to preview the changes), svn update to bring everything up to date.

Hopefully this is helpful.

I also can't suggest enough that your read more of the subversion documentation to understand what's going on under the hood. Also, make sure you know what you're doing before trying this stuff on anything important. You can create test repositories, with bogus data, and do some experiments until you're confident that you know what you're doing.