Sunday, 16 December 2012

Setting up SVN on AWS EC2 instance

Steps to setup the SVN repository on the cloud instance (http://www.ange-agostini.com/blog/it/5-minutes-to-set-up-a-subversion-server-in-the-cloud.html):
Install subversion, apache and mod_dav_svn:
# sudo yum install mod_dav_svn subversion
Edit the Apache configuration file for subversion:
# sudo vi /etc/httpd/conf.d/subversion.conf
Replace subversion.conf content by:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn
   # Limit write permission to list of valid users.
   AuthType Basic
   AuthName "Authorization Realm"
   AuthUserFile /var/www/svn-auth/passwd
   AuthzSVNAccessFile  /var/www/svn-auth/access
   Require valid-user
</Location>

Create the directory which will contain the subversion repository:
# sudo mkdir /var/www/svn
Create the directory which will contain the permissions files.
 # sudo mkdir /var/www/svn-auth
Create the permission file:
# sudo vi /var/www/svn-auth/access
[/]
<theUser> = rw
Note: Replace <theUser> by the login you want to use to access your repository.
<theUser> will have read write access to all repositories.
It is possible to setup authorization by group or user for each repository.
Create the password file:
# sudo htpasswd -cb /var/www/svn-auth/passwd <theUser> <thePassword>
Note: Replace <theUser> by the login you want to use to access your repository. Replace <thePassword> by the password you want.
Create a repository (here project1):
# cd /var/www/svn
# sudo svnadmin create project1
Change files authorization:
# sudo chown -R apache.apache /var/www/svn /var/wwws/vn-auth
# chmod 600 /var/wwws/vn-auth/access /var/www/svn-auth/passwd
Start apache web server:
# sudo service httpd start
Note: to restart server use # sudo service httpd restart

Test subversion

Now subversion and apache should work.
Open a web browser and point to the URL : http://<Public DNS of your EC2 instance>/repos/project1
You should be prompted for your credential (Enter <theUser> <thePassword>) before accessing the repository

Subversion client

We are now going to interact with our repository from a windows PC.
If you don’t have a subversion client installed on your PC then you can install one from http://www.sliksvn.com/en/download .
You can test your subversion client from your PC by listing files on your repository:
svn ls http://<Public DNS of your EC2 instance>/repos/project1
The first time we often want to import some files to the repository:
svn import -m "Initial import." <path of the reposity where are the files on your PC> http://<Public DNS of your EC2 instance>/repos/project1


---------------------------------------------------------------------------------------------------------------------------------
ANOTHER WAY:

Steps given at https://forums.aws.amazon.com/thread.jspa?messageID=209468:

I signed up for an EC2 free tier tonight intending to use it as a Subversion server. The whole process took a couple of hours to setup, but can be compressed down to just a few minutes. If anybody else is looking to do the same, here is what I did:

1) Create the Linux-flavored micro instance.
2) Give it a Security Group that opens port 3690 to the sources of your choice. The following example allows SVN access from all Internet sources:
  • | tcp | 3690 | 3690 | 0.0.0.0/0
  • | udp | 3690 | 3690 | 0.0.0.0/0
3) SSH into the micro instance and run the command "sudo yum install subversion".
4) Create the directory to be used for subversion, for example "/home/ec2-user/svn".
5) Enter "svnadmin create /home/ec2-user/svn" (or whichever path you specified).
6) Edit two files: svnserve.conf and passwd both found in the "conf" directory of your newly created repository source.
In svnserve.conf, unremark the lines for "anon-access" (but change from "read" to "none") and "auth-access". Additionally, unremark the "password-db = passwd" line, but don't change it, and unremark the "realm =" line, providing a realm name of your choice.
In the passwd file, simply add a line entry with the user name(s) and password(s) to be used for access.
7) Finally, run "svnserve -d -r /home/ec2-user/svn" (or again, whichever path you specified) to kick off the instance.

Your Subversion server should now be available at the URL: svn://<yourinstancehostorip>/

Keep in mind the security for this quick and dirty setup is very minimal, and the daemon has not been configured for automatic startup at this point.

Reading:

http://jonathanhui.com/install-configure-subversion-ec2-amazon-linux

27 comments:

  1. sudo chown -R apache.apache /var/www/svn /var/wwws/vn-auth

    Should be:

    sudo chown -R apache.apache /var/www/svn /var/www/svn-auth

    ReplyDelete
  2. chmod 600 /var/wwws/vn-auth/access /var/www/svn-auth/passwd

    Should be:

    sudo chmod 600 /var/wwws/vn-auth/access /var/www/svn-auth/passwd

    ReplyDelete
  3. Holy crap this website is terrible on mobile.

    ReplyDelete
  4. I followed the instructions through "# sudo service https start" and then tested using "http:///repos/project1" (substituted DNS name of EC2 instance and repos name. The result of the test was not as expected/desired. Instead, I got 404 error.

    Can you please tell me what I need to look for to fix it?

    ReplyDelete
  5. Referenced note from http://hsilomedus.me/index.php/apache-virtual-hosts-wordpress-subversion/ to set up virtual host information in subversion.conf and it worked

    ReplyDelete
  6. i followed the instructions to the letter but can't authenticate to the repos in chrome i get the connection is not private and in ie it just gives a warning about basic connection

    ReplyDelete
  7. I feel really happy to have seen your webpage and look forward to so
    many more entertaining times reading here. Thanks once more for all
    the details.


    AWS Training in Bangalore


    AWS Training in Bangalore


    ReplyDelete
  8. I am obliged to you for sharing this piece of information here and updating us with your resourceful guidance. Hope this might benefit many learners. Keep sharing this gainful articles and continue updating for us.
    motorola service center in chennai

    ReplyDelete
  9. Really nice post.provided a helpful information.I hope that you will post more updates like this, AWS Training

    ReplyDelete
  10. This is most informative and also this post most user friendly and super navigation to all posts. Thank you so much for giving this information to me.aws training in bangalore


    ReplyDelete
  11. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    aws training in chennai | aws training in annanagar | aws training in omr | aws training in porur | aws training in tambaram | aws training in velachery

    ReplyDelete
  12. very interesting to read.thanks for your article.Angular training in Chennai

    ReplyDelete