Setting up SVN on linux
This is a simple step-by-step setup for a svn server which can be accessed via the internet by multiple people. Basic!
- Create a svn repository for your particular project, for example the directory /svn/myproject. Make sure you own the directory: sudo chown YOU:YOU /svn/myproject
- Now initiate the SVN system: svnadmin create /svn/myproject This creates a repository in the svn directory.
- Now we want to import the files into the SVN directory. cd into the directory you want to use
SVN on and do
svn import DIR_YOU_WANT_TO_IMPORT file:///svn/myproject.Note that you HAVE TO import directories, SVN only works on directory structures, not on individual files. It will prompt you to enter some kind of log message so you remember why and what you imported. - To locally edit a file, you get a local copy of what's in the repository by doing
svn checkout DIR_CONTAINING_YOUR_FILE. Once you're done with editing, and want to commit the changes to the SVN, runsvn commit DIR_YOU_EDITED - If you later on want to add a file, get a copy of the directory as above, put the file into the directory and do svn add FILENAME. Similarly, if you want to remove a file, remove it from your local copy and run svn remove FILENAME.
- Now we'd like to access our files from a remote machine. The easiest
way to do this is to start a svnserve server. To run
it in the background on your computer you type
svnserve -dwhere the -d option will make it run in the background as a deamon. If you want to be slightly safer, runsvnserver -d -r /svnto restrict svn access to the /svn tree. Finally, you can specify a specific port by runningsvnserve -d -r /svn --listen-port 8001 - To check out something from a remote machine, you make a directory,
say tmp, into which you want to checkout the files, cd into it and run
svn checkout snv://YOUR_URL:8001/myproject - Now we want to make sure not everybody has access to the repository.
We need to edite two files inside the repository. Go to
/svn/myproject/conf, and edit the file svnserve.conf so that it contains:
[general]Now edit the file passwd (to which we've just reffered in the variable password-db) to say:
anon-access = read
auth-access = write
password-db = passwd
realm = myproject
[users] bobby = bobbyspasswordwhere bobby is you or whoever needs access. :-) - So now we're ready. We can
now edit the file we checked out above, and then do
svn commit EDITEDFILENote that we might then be asked for a password for the wrong user. Just hit enter, and you'll be prompted for the user name before giving the password corresponding to that user. - Finally, if you need to migrate your svn server from one machine to
another, you first do the following on the original machine:
svnadmin dump /svn/myproject > tmpand move the tmp file to the new machine. There, you first set up a new svn directory, like above:mkdir /svn/myproject
svnadmin create /svn/myproject
svnadmin load /svn/myproject < tmp