Sunday, December 1, 2013

Chat Project with SVN

SVN is version control system.   

1. Install SVN on Linux 
$ sudo apt-get install subversion

2. Install Apache
$ sudo apt-get install apache

3. Now we want to configure apache to run HTTPs.
Following command will enable ssl Apache2 module with a2enmod (cryptic name for “Apache2
enable module”:
$ sudo a2enmod ssl

4. Now configure the SSL site. Fortunately we already have the configuration file for that, we just
need to enable it with a2ensite (cryptic name for “apache2 enable site”)
$ sudo a2ensite default-ssl

5. As we made several changes I prefer to restart apache with
following command:
$ sudo /etc/init.d/apache2 restart

6. First of all, we need to install the Subversion modules for Apache2.
$ sudo apt-get install libapache2-svn
They will be enabled by default. So you don’t need to run a2enmod.
We only need to configure a repository. Let say our project is called ‘myproject’.

7. First of all, let’s decide where our svn repositories will be created. I like /var/local/svn
$ sudo mkdir /var/local/svn/

8. Then let’s create the repository using following procedure:
$ sudo mkdir /var/local/svn/myproject
$ sudo chown www-data:www-data /var/local/svn/myproject
$ sudo -u www-data svnadmin --config-dir /etc/subversion create /var/local/svn/myproject
Above commands will ensure that the user www-data (which is the apache user) can fully access
the repository for reading and updating it.

9. edit /etc/apache2/mods-available/dav_svn.conf
$ sudo gedit /etc/apache2/mods-available/dav_svn.conf
And add a section like the following one:
<Location /svn/myproject>
DAV svn
SVNPath /var/local/svn/myproject
AuthType Basic
AuthName “My Project Subversion Repository”
AuthUserFile /etc/subversion/myproject.passwd
Require valid-user
In the above file we indicated that, at the location svn our repository should respond. And for
updating the repository we want a valid user. As per above configuration anonymous consultation
is allowed; but you can disable it commenting with a leading ‘#’ the lines <LimitExcept ... and
</LimitExcept> or just removing them as in following example:
<Location /svn/myproject>
DAV svn
SVNPath /var/local/svn/myproject
AuthType Basic
AuthName “My Project Subversion Repository”
AuthUserFile /etc/subversion/myproject.passwd
Require valid-user

10. valid users need a password, and in fact we indicated a password file for our repository
called /etc/subversion/myproject.passwd. So let’s create a password file with a couple of users:
$ sudo htpasswd -c /etc/subversion/myproject.passwd foss
$ sudo htpasswd /etc/subversion/myproject.passwd trupti
The -c option indicates that the password file should be created as new; and it is only necessary for the first user. Be aware of the fact that -c overwrites the existing password file without asking

11. Let’s reload apache configuration to make the changes effective:
$ sudo /etc/init.d/apache2 reload

12. And let’s test with the browser that our svn repository is now accessible through HTTP and HTTPs
at following urls:
Now we can download our project using svn under my home/Subversion
root@trupti-HP-630-Notebook-PC:~/subversion# svn co https://localhost/svn/myproject
Checked out revision 0.
The first time it will prompt for accepting the SSL certificate, answer to accept it permanently (p).
Then it will optionally ask you for the password, type it.
Since its a new project that i am starting so there is no file in my repositories. The word Check out
revision 0 says how many time the code is committed.
Now i am creating a new file in my local working copy
root@trupti-HP-630-Notebook-PC:~/subversion/myproject#vi sample.php
Hi this is sample testing
Now i had saved the file
svn add filename” will add the files into SVN repository.
root@trupti-HP-630-Notebook-PC:~/subversionmyproject# svn add sample.php

13. Commit the added file to Repository
Until you commit, the added file will not be available in the repository.
root@trupti-HP-630-Notebook-PC:~/subversion/myproject# svn commit -m "new file added
sample.php" sample.php
Transmitting file data .
Committed revision 1.
Now we have added the file sample.php to our repository. Now we will delete our local copy and
freshly we can download the project from the repository and make whatever changes we want.

This is how we set up the SVN Repository and Work with it.

* Now we shall use svn on a public code repository .
* Create a demo project with a text file chat.txt
* Add content in the file example "trupti:hi"
* Tell your friend to run the command (top one) for checkout in source tab
* It will check out the project in his machine.
* Make some changes to that file example "ayesha:hows u?"
* Then do an svn commit
* When it asks for username, add the gmail id and for password go to profile->settings in the link.
Normal repo is just local to us.
Only difference to local thing and this is that our central repo is now on google code.

No comments:

Post a Comment

Mesmerizing Fortnight

This time its Sangli,Satara & Kolhapur. We hate to spend our daytime in journey so we prefer night journey. Unfortunately trains f...