{"id":48,"date":"2013-03-22T18:34:24","date_gmt":"2013-03-22T17:34:24","guid":{"rendered":"http:\/\/www.gadgetdude.co.uk\/blog\/?p=48"},"modified":"2013-03-22T18:34:24","modified_gmt":"2013-03-22T17:34:24","slug":"configuring-a-subversion-repository-using-apache","status":"publish","type":"post","link":"https:\/\/www.gadgetdude.co.uk\/blog\/?p=48","title":{"rendered":"Configuring a Subversion Repository using Apache"},"content":{"rendered":"<div style=text-align:left;><a class=\"wpptopdfenh\" target=\"_blank\" rel=\"noindex,nofollow\" href=\"https:\/\/www.gadgetdude.co.uk\/blog\/?p=48&#038;format=pdf\" title=\"Download PDF\"><img alt=\"Download PDF\" src=\"https:\/\/www.gadgetdude.co.uk\/blog\/wp-content\/plugins\/wp-post-to-pdf-enhanced\/asset\/images\/pdf.png\"><\/a><\/div><p>As I write a lot of scripts for different tasks I find it useful to keep a hold of them all for future reference.<br \/>\nOne of the easiest ways of keeping this information no matter where I am is to create my own home subversion repository. This means that no matter where I am, as long as I have http access to my home server I can get to my files.<\/p>\n<p>How do you do this, well the first thing is to create your repository. Suppose I want to create a Repository at \/usr\/local\/subversion\/repository using fsfs database so execute the command:<\/p>\n<pre style=\"padding-left: 30px;\">mkdir -v \/usr\/local\/subversion\/<\/pre>\n<pre style=\"padding-left: 30px;\">\/usr\/bin\/svnadmin create --fs-type fsfs \/usr\/local\/subversion\/repository<\/pre>\n<p>That should create a subversion repository under \/usr\/local\/subversion\/repository.<\/p>\n<pre style=\"padding-left: 30px;\">ls \/usr\/local\/subversion\/repository<\/pre>\n<pre style=\"padding-left: 30px;\">conf\/ dav\/ db\/ format hooks\/ locks\/ README.txt<\/pre>\n<p>You should be able to see those files under the repository directory.<\/p>\n<h3>Setting up httpd.conf to serve the created repository:<\/h3>\n<p>Add the following lines to httpd.conf or the appropriate apache configuration file.<\/p>\n<pre>&lt;Location \/subversion&gt;\r\n\r\n\u00a0 DAV svn\r\n\r\n\u00a0 SVNPath \/usr\/local\/subversion\/repository\/\r\n\r\n&lt;\/Location&gt;<\/pre>\n<p>Make sure that the module mod_dav is loaded in the apache configuration file and is also present under modules directory.<\/p>\n<p>&nbsp;<\/p>\n<h3>Setting up authentication:<\/h3>\n<p>For the authentication we need to make changes to the apache configuration yet another time.<\/p>\n<p>Basic authentication requires that we just add the following lines to the httpd.conf where we added the svn repository earlier.<\/p>\n<pre>AuthType Basic\r\n\r\nAuthName \"{Name of the authentication popup tab}\"\r\n\r\nAuthUserFile {Location of the password file}\r\n\r\nRequire valid-user<\/pre>\n<p>So it should look like this.<\/p>\n<pre>&lt;Location \/subversion&gt;\r\n\r\n\u00a0 DAV svn\r\n\r\n\u00a0 SVNPath \/usr\/local\/subversion\/repository\/\r\n\r\n\u00a0 AuthType Basic\r\n\r\n\u00a0 AuthName \"Subversion repository\"\r\n\r\n\u00a0 AuthUserFile \/usr\/local\/subversion\/repository\/conf\/svn-auth-file\r\n\r\n\u00a0 Require valid-user\r\n\r\n&lt;\/Location&gt;<\/pre>\n<p>It is necessary that we add users to the password file before anyone can access it, which is described in the next step.<\/p>\n<p>&nbsp;<\/p>\n<h3>Adding SVN users:<\/h3>\n<p>Since we are using svn with an apache server, and an apache basic authentication method.<\/p>\n<p>We need to create a password file with the htpasswd binary provided with a standard apache installation.<\/p>\n<p class=\"command\">htpasswd -cmd \/usr\/local\/subversion\/repository\/conf\/svn-auth-file {user-name}<\/p>\n<p><span class=\"system\">-c<\/span> option creates a new htpasswd file.<\/p>\n<p><span class=\"system\">-m<\/span> encrypts the password with an MD5 algorithm.<\/p>\n<p><span class=\"system\">-d<\/span> encrypts the password with a CRYPT algorithm.<\/p>\n<p>Where <span class=\"system\">{user-name}<\/span> stands for an actual user name that will be used for authentication.<\/p>\n<p>Warning: We should not use the <span class=\"system\">-c<\/span> option once we have added the first user. Using so will create and replace all existing user within the file.<\/p>\n<p class=\"command\">htpasswd -md \/usr\/local\/subversion\/repository\/conf\/svn-auth-file {user-name}<\/p>\n<p>&nbsp;<\/p>\n<h3>Setting up the initial repository layout:<\/h3>\n<p>A repository mostly contains 3 standard folders.<\/p>\n<p class=\"system\">branches<\/p>\n<p class=\"system\">tags<\/p>\n<p class=\"system\">trunk<\/p>\n<p>For creating those standard folders in a repository, create a temporary folder anywhere you want, \/tmp would be a good idea, with the following subdirectories.<\/p>\n<p class=\"command\">mkdir -pv \/tmp\/subversion-layout\/{branches,tags}<\/p>\n<p>After we have made all the layout folders, move all the contents of your project to the trunk folder.<\/p>\n<p class=\"command\">mv -v \/usr\/local\/apache2\/htdocs \/tmp\/subversion-layout\/trunk<\/p>\n<p>Then make an initial import of the temporary created directory.<\/p>\n<p class=\"command\">\/usr\/local\/subversion\/bin\/svn import \/tmp\/subversion-layout\/ http:\/\/127.0.0.1\/subversion\/<\/p>\n<p>This will setup you up with a default repository layout, and make a first revision.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I write a lot of scripts for different tasks I find it useful to keep a hold of them all for future reference. One of the easiest ways of keeping this information no matter where I am is to create my own home subversion repository. This means that no matter where I am, as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/48"}],"collection":[{"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=48"}],"version-history":[{"count":3,"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gadgetdude.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}