Archive

Archive for October, 2011

Installing Subversion in Debian

October 16, 2011 Leave a comment

This article was taken from : http://www.reviewingit.com/index.php/content/view/62/2/

So happens there comes a time when you need to track whos been adding what to your documents, and how to revert back to last Mondays copy of a document. What you need is a software to manage the versions and track the changes done by whomever. What you need is a tool called subversion. I’ve been hunting around for some good document to go through the install step by step but could not find one short of reading an entire book on the subject. So I decided to write a small document on what I did to install my copy of subversion on Debian etch, just using apt… read on…

First you need the following

A. A clean debian 4.0 etch system
B. Tortisesvn :- a subversion client for Windows (Xp or Vista) Get it here
1. First we need to Install ssh server
# apt-get update
# apt-get upgrade
# apt-get install ssh

2. Next we install Apache2
# apt-get install apache2
# apt-get install libapache2-mod-php5

3. Install subversion packages
# apt-get update
# apt-get install subversion
# apt-get install libapache2-svn
4. Create Repository
# mkdir /var/svn/
# svnadmin create –fs-type fsfs /var/svn/myproject

5. Generate Test data in repository
# mkdir ~/TEMP/
# echo “Testing” > ~/TEMP/test.txt
# svn import -m “Testing via ssh+svn” ~/TEMP/ svn+ssh://127.0.0.1/var/svn/myproject/trunk
# svn co svn+ssh://127.0.0.1/var/svn/myproject/trunk testcheckout

6. See if files in repository
# svnlook tree /var/svn/myproject/

7. Changeowner of repository folder to apache user
# chown -R www-data:www-data /var/svn/*
# chmod -R 770 /var/svn/*

8. Make sure svn is running in apache
# a2enmod dav
# a2enmod dav_svn
9. Create user accounts for SVN users, you will be prompted for their passwords
# htpasswd -c /etc/apache2/svn.passwd usera

# htpasswd /etc/apache2/dav_svn.passwd userb
# htpasswd /etc/apache2/dav_svn.passwd userc

10. Input this code into /etc/apache2/mods-available/dav_svn.conf
<Location /myproject_site>
DAV svn
SVNPath /var/svn/myproject
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
#SSLRequireSSL <– note this is commented out
</Location>
11. Reload the apache config then, Test the connection using a browser to http://<repository address>/myproject_site
# /etc/init.d/apache2 force-reload
12. If it works time to add SSL to Apache
#apt-get install openssl ssl-cert

13. Generate a certificate
# openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem

>>ensure you fill up all the details
for the certificate<<

14. Change the permissions on the certificate
# chmod 600 /etc/apache2/apache.pem

15. Modify the /etc/apache2/ports.conf add the following string
Listen 443

16. modify /etc/apache2/sites-available/default
change the default NameVirtualHost * to NameVirtualHost *:80
Add NameVirtualHost *:443
Change <VirtualHost *> to <VirtualHost *:80>

17.Add right at the end of the file

<VirtualHost *:443>
ServerAdmin webmaster@localhost
SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem
</VirtualHost>

18. Uncomment SSL required in /etc/apache2/mods-available/dav_svn.conf
<Location /svn_zen>
DAV svn
SVNPath /var/svn-repos/project_zen
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL       <—HERE
</Location>

 

19.Reload the Apache config
# /etc/init.d/apache2 force-reload
20. Ensure mod ssl is loaded
# a2enmod ssl
21. Ensure repository permissions are correct

# chown -R www-data:www-data /var/svn/*
# chmod -R 770 /var/svn/*
22. Test in browser, enter the userid you created and password
https://<address of webserver>/myproject_site
23. Now that all is working with SSL Lets add some granular permissions
, usera and userb has readwrite userc only has read permissions to the repository.
# nano /etc/apache2/svn_ACL

put this in

[groups]
readwritegrp = usera, userb
readgrp = userc

[/]
@readwritegrp = rw
@readgrp = r

[/myproject_site/trunk]
@readwritegrp = rw
@readgrp = r

24. Lets tell subversion to use the permissions, Add this in to /etc/apache2/mods-available/dav_svn.conf
<Location /myproject_site>
DAV svn
SVNPath /var/svn/myproject
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
SSLRequireSSL
AuthzSVNAccessFile /etc/apache2/svn_ACL    <—HERE
</Location>

25. Reload Apache and Have Fun with your SVN repository!!!
# /etc/init.d/apache2 force-reload
26. Fire up your Tortise SVN I use it in Vista it adds a right click menu which you can use to check in and check out documents. But first up use the repository browser to goto https://<your server address>/myproject_site to make sure all is going well
enter your userid and password created earlier. If all goes well you can start playing around with you TortiseSVN to check out and check in docs. Also you can diff and see the history of
updates. Its Great!!

Categories: Linux, Programming