<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jiramot.info &#187; subversion</title>
	<atom:link href="http://www.jiramot.info/tag/subversion/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jiramot.info</link>
	<description>Developer&#039;s Life</description>
	<lastBuildDate>Mon, 06 Feb 2012 08:49:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Setting up a Subversion Server on Ubuntu Gutsy Gibbon server</title>
		<link>http://www.jiramot.info/setting-up-a-subversion-server-on-ubuntu-gutsy-gibbon-server</link>
		<comments>http://www.jiramot.info/setting-up-a-subversion-server-on-ubuntu-gutsy-gibbon-server#comments</comments>
		<pubDate>Sun, 31 Jan 2010 09:11:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=496</guid>
		<description><![CDATA[Setting up a Subversion Server on Ubuntu Gutsy Gibbon server <p> All the required packages are available in the Ubuntu repositories.</p> Installing Subversion <p>Use apt-get:</p> sudo apt-get update sudo apt-get install subversion Creating a Repository <p>Let&#8217;s say you want your repository to be in /var/svn/repos, type in these commands:</p> cd /var sudo mkdir svn [...]]]></description>
			<content:encoded><![CDATA[<h2>Setting up a Subversion Server on Ubuntu Gutsy Gibbon server</h2>
<p><!-- start main content --> <!-- google_ad_section_start -->All the required packages are available in the Ubuntu repositories.</p>
<h3>Installing Subversion</h3>
<p>Use <tt>apt-get</tt>:</p>
<pre>sudo apt-get update
sudo apt-get install subversion
</pre>
<h3>Creating a Repository</h3>
<p>Let&#8217;s say you want your repository to be in <tt>/var/svn/repos</tt>, type in these commands:</p>
<pre>cd /var
sudo mkdir svn
sudo svnadmin create /var/svn/repos
</pre>
<p>In order to control who has access to the repository we will now add a user who will own the repository files. Adding a user also adds a group with the same name.</p>
<pre>sudo adduser svn
</pre>
<p>Now make it impossible for anyone to log in as this user by editing <tt>/etc/passwd</tt> to set the <tt>svn</tt> user shell to <tt>/bin/false</tt>. Do this using the <tt>vipw</tt> command.  Find the line which starts <tt>svn</tt> (it should be the last line in the file) and change <tt>/bin/bash</tt> to <tt>/bin/false</tt>.</p>
<p>Now change the ownership of the repository files.</p>
<pre>sudo chown -R svn.svn svn
</pre>
<p>In order for someone to be permitted to use the repository they must be added to the <tt>svn</tt> group. My user name is <tt>martin</tt> so I am going to add myself to the <tt>svn</tt> group.</p>
<pre>sudo vigr
</pre>
<p>Go to the end of the file and add your user name to the end of the line which starts <tt>svn</tt>.  The end of the file should look similar to this:</p>
<pre>admin:x:110:martin
svn:x:1001:martin
</pre>
<p>Now set up an <tt>ssh</tt> server, clients will connect to this machine using <tt>ssh</tt>:</p>
<pre>sudo apt-get install openssh-server
</pre>
<p>The repository can now be accessed using the <tt>svn+ssh</tt> protocol. Test this as follows:</p>
<pre>svn co svn+ssh://<em>username</em>@<em>machinename</em>/var/svn/repos
</pre>
<p>You will be prompted about the RSA fingerprint of the server and asked for your password. You should end up with a directory called <tt>repos</tt> which is a working copy of your new repository.</p>
<p>As things stand you will be asked for your password every time you connect to the machine which is rather tedious. You can also authenticate with <tt>ssh</tt> by using a public/private key pair. If you are using a Windows client then install PuTTY and use PuTTYgen to create a key. Don&#8217;t forget to save the public and private key files. There is a text box at the top of the PuTTYgen window labeled &#8220;Public key for pasting into OpenSSH authorized_keys file&#8221;, you need to put the line of text in that box into a file called <tt>.ssh/authorized_keys2</tt> in your home directory on the server. Set the permissions on the files like this:</p>
<pre>chmod 0700 .ssh
chmod 0600 .ssh/authorized_keys2
</pre>
<p>On the Windows machine fire up pageant (another program which comes with PuTTY) and load your private key. You should now be able to connect to the server without being asked for a password. I prefer to disable password based access to the server by editing <tt>/etc/ssh/sshd_config</tt> and adding the line <tt>PasswordAuthentication no</tt>.</p>
<p>On a Linux client use <tt>ssh-keygen</tt> to create the key pair.</p>
<h3>Apache</h3>
<p>Subversion also supports the WebDAV protocol, to set this up Apache is needed. I am assuming that you installed Ubuntu as a LAMP server.</p>
<pre>sudo apt-get install libapache2-svn
</pre>
<p>The following isn&#8217;t recommended for a real implementation as we are going to add to the default web files. It would be far better to create a new virtual host, but that is a subject itself.</p>
<p>Ubuntu has a file for each active virtual host in <tt>/etc/apache2/sites-enabled</tt>, after installing Ubuntu server there will be a file called <tt>000-default</tt> in the <tt>sites-enabled</tt> directory and this is the file we are going to edit.</p>
<pre>cd /etc/apache2/sites-enabled
sudo vi 000-default
</pre>
<p>In the  directive add:</p>
<pre>    &lt;Location /svn/repos&gt;
      DAV svn
      SVNPath /var/svn/repos
    &lt;/Location&gt;
</pre>
<p>Then execute this command:</p>
<pre>sudo /etc/init.d/apache2 force-reload
</pre>
<p>You should now be able to see the repository at the URL <tt>http://<em>machinename</em>/svn/repos</tt>.</p>
<h3>Securing Web Access</h3>
<p>Add this to the location directive:</p>
<pre>      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/passwords
      Require valid-user
</pre>
<p>Now add a user name and password to the Apache password file:</p>
<pre>sudo htpasswd -cb /etc/apache2/passwords martin dgjan08
</pre>
<p>And another forced reload:</p>
<pre>sudo /etc/init.d/apache2 force-reload
</pre>
<p>Now if you visit the repository URL you will have to enter a valid user name and password.</p>
<h3>Trac</h3>
<p>Trac is a ticketing system and Wiki which integrates very well with Subversion. Start by installing Trac:</p>
<pre>sudo apt-get install trac python-setuptools libapache2-mod-python enscript
</pre>
<p>Now create a Trac database:</p>
<pre>sudo mkdir /var/www/trac
sudo trac-admin /var/www/trac/repos initenv</pre>
<p>Then answer its questions, take the defaults, our Subversion repository is in <tt>/var/svn/repos</tt>.</p>
<p>Now to get Apache to run Trac.</p>
<pre>cd /var/www
sudo chown -R www-data.svn trac
</pre>
<p>Head back to <tt>/etc/apache2/sites-enabled</tt> and edit <tt>000-default</tt> again, adding this:</p>
<pre>    &lt;Location /trac/[[:alnum]]+/login"&gt;
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/passwords
      Require valid-user
    &lt;/Location&gt;

    &lt;Location /trac&gt;
      SetHandler mod_python
      PythonInterpreter main_interpreter
      PythonHandler trac.web.modpython_frontend
      PythonOption TracEnvParentDir /var/www/trac
      PythonOption TracUriRoot /trac
    &lt;/Location&gt;
</pre>
<p>And then run this again:</p>
<pre>sudo /etc/init.d/apache2 force-reload
</pre>
<h3>Building Trac from source</h3>
<p>If you want the most recent version of Trac (0.10.4) then you will have to build and install it. Do the following:</p>
<pre>sudo apt-get remove trac
wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
tar zxf trac-0.10.4.tar.gz
cd trac-0.10.4/
sudo mkdir /usr/local/trac
sudo python setup.py install --prefix=/usr
</pre>
<p>The rest of the instructions are the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/setting-up-a-subversion-server-on-ubuntu-gutsy-gibbon-server/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

