Total Hit Counter

Saturday, October 6, 2012

SVN server howto



Step1 : Created a fedora virutal machine clone.
Links :
1) http://sysdigg.blogspot.com/2008/02/install-subversion-on-fedora-8-linux.html
2) http://www.botsko.net/blog/2007/05/17/installing-subversion-on-fedora-core/
3) http://www.ferdychristant.com/blog/articles/DOMM-6NFJ6J
4)http://www.botsko.net/blog/2007/05/17/installing-subversion-on-fedora-core/
         I’ve been using subversion a lot recently – from using repositories with client development companies to installing it for clients – it seems to be the SVN month.
Here’s how I installed subversion on a machine with Fedora Core 4. For anyone learning or using Subversion, I highly recommend that you read the book.
You may already have subversion installed, if not, just run this:

# yum install subversion
# yum install mod_dav_svn
Then you’ll need to setup at least one repository.
# mkdir -p /svn/repos
We need to give these folders the proper permissions
# chown -R apache.apache /svn
Then we need to tell subversion to make our first repository.
# svnadmin create /svn/repos/myproject

########## Leave below configuration just go through apache configuration given below to these steps
First, I need to setup a config file for svnserve.
# vi /svn/repos/conf/svnserve.conf
Then, look for variations of the following code and edit it as necessary. By default any anonymous user can access the code so to disable that you must include anon-access = none, just commenting the value out will not prevent anonymous access.
anon-access = none
password-db = passwdfile
realm = My SVN Repository
auth-access = write
The password-db is just a path to a file containing usernames and passwords. You’ll create this file especially for SVN. I create each file inside of the repository conf directory. So, save your changes and then we’ll create said user file.
# vi passwdfile
Enter in something like:
[users]
username = password
Anyway, you’ll need to start the svn server.
# svnserve -d –listen-port=3690
One side note – svnserve just runs and doesn’t have a way to stop besides killing the process. If you make changes to the svnserve.conf or user file you’ll need to restart svnserve.
# killall svnserve
Then, go ahead and test (best to do so on a different machine).
# svn co –username=myusername svn://mydomain/svn/repos/myproject
The system should then ask you for your password. Go ahead and run some tests.



Now, let’s setup Apache.

Create a new apache include file that will hold our configurations (You may already have this is subversion was already installed).
# vi /etc/httpd/conf.d/subversion.conf
Now, this file will need to contain something like this to serve the repository through apache:

<Directory /home/xyz/svn/repo1>
AllowOverride All
Options MultiViews -Indexes Includes FollowSymlinks
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
# WebDAV access
<Location /svn/repo1>
DAV svn
SVNPath /home/xyz/svn/repo1
AuthType Basic
AuthName “SVN”
AuthUserFile /home/xyz/htpasswd
Require valid-user
# Allow read-only access to anyone, otherwise require
# authentication
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
Now, this essentially tells apache to load the mods needed for svn. We need to create some files so that this config will work properly. The first is our htpasswd file which I named “/svn/users/svnpass”.
# htpasswd -cb /svn/users/svnpass username password
Next we need to create the svnauth file.
# vi /svn/permissions/svnauthz.conf
Inside we’ll place a list of users who have access to files:
[/]
username = rw
The “rw” states that this user has read/write access to the root repository /.
Restart your web server and you should be done.
service httpd reloador you can use:
/usr/sbin/apachectl restart
 – this option outputs better error messages in case you’ve made some syntax mistakes.
Go to your repository and you should see subversion displaying the repo info.
http://yoursite.com/svn/repos/








7 comments:

Unknown said...

How to create auto svn update script on a linux server???/

Shankar said...

Step1 : execute following command.
crontab -e

Step2 : Please copy and paste below line in to that opened file
*/5 * * * * /usr/bin/svn up /dir/to/do/svn/up

Unknown said...

is it not necessary to give svn username and password to update......

Shankar said...

It is necessary but if you will save it for that directory then it will not ask in cron.

and still if you are not able to update it try this:
*/5 * * * * /usr/bin/svn up /dir/to/do/svn/up --username=uttam --password=password

Jitesh Rathod said...

Hi Shankar,
How to authenticate with AD users.

thanks,

Jitesh Rathod

Shankar said...
This comment has been removed by the author.
Shankar said...

I never tried with Microsoft AD but using LDAP you can authenticate
Add below lines in apache-svn configuration file.

AuthzLDAPAuthoritative off
AuthBasicProvider file ldap
require valid-user
AuthName "LDAP-SVN-AUTH"
AuthType Basic
AuthLDAPURL "ldap://xxx.xxx.xxx.xxx/ou=MYOU,o=MYLDAP?cn?sub?(objectClass=person)"
Require ldap-group cn=LDAP-GROUP,ou=MYOU,o=MYLDAP