Wednesday 9 November 2011

How to install subversion on Linux and make it working.


To install svn in linux and make it fully working , I found it really tough and it has taken my lots of time.While installing this you will miss a small thing and you got stuck.But this is not at all tough like open source it’s really very easy.



Why I have choosed this topic to write is that, those who are using it first time will need some time to get full of subversion.
Now the latest version of svn is 1.4.6.
To install svn first you need svn tar file. Which can be downloaded easily from here or you can run these commands (depending on your required version).
wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz
wget http://subversion.tigris.org/downloads/subversion_deps-1.4.6.tar.gz (It contains the library required by svn)

This you can download any where, Here I am creating a folder svn inside /usr/local directory.(/usr/local/softwares/svn/).(So it will be easy for me to specify paths and you to understand).
To start the installation process first untar this two file.
tar -xvzf subversion-1.4.6.tar.gz
tar -xvzf subversion_deps-1.4.6.tar.gz
(After untar you won’t find any particular folder named subversion_deps-1.4.6. Don’t worry for that it is keeping all the libraries files inside subversion-1.4.6)
Now have to configure it, but before that we have to check whether our system is having all the dependies or not, like APR(Apache Portable Runtime) and APR utility.
If it’s not there then we can get it from here,
apr-1.2.12.tar.gz
apr-util-1.2.12.tar.gz

once downloaded you can start configuring it.
tar -xvzf apr-1.2.12.tar.gz
cd apr-1.2.12
./buildconf
./configure
make

The apr util directory requires apr directory, so we need to specify path for that.
tar -xvzf apr-util-1.2.12.tar.gz
cd apr-util-1.2.12
./buildconf –with-apr=/path to apr directory (/usr/local/sofwares/svn/apr-1.2.12)
./configure –with-apr=/path to apr directory (/usr/local/sofwares/svn/apr-1.2.12)
make

The other directories we have to check before installation are,
autoconf 2.50 or newer (autoconf –version)
libtool 1.4 or newer (this you can find inside subversion-1.4.6 folder)
Neon Library 0.25.x or 0.26.x (inside subversion-1.4.6 folder)
Berkely DataBase (If it’s not there you have to install it.)
Download the file, db-4.6.21.tar.gz .
Apache web server greater then 2.0.49 (httpd -version)
zlib (inside subversion-1.4.6 folder)
After checking all this, we can start installation process,
cd subversion-1.4.6
./autogen.sh
./configure –with-berkelay-db=/usr/local/softwares/svn/db-4.6.21 (path of berkelay data base)
make
make install

Once we have finished that we need to map svn with apache.
Before that we have to check whether mod_dav_svn and mod_authz_svn modules are present or not,if not then install it.
yum install mod_dav_svn
and add this in /etc/httpd/conf/httpd.conf file
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Make sure you will add these lines after LoadModule dav_module modules/mod_dav.so.
Now create one repository with svnadmin command.Run this command inside your subversion folder.
svnadmin create repos
after that you can check with,
ls repos
conf dav db format hooks locks README.txt

This full path you have to specify in SVNPath.
Then at the end of the httpd.conf file you have to add
#for svn path
<Location /svn/repos>
DAV svn
SVNPath /usr/local/softwares/svn/subversion-1.4.6/repos
</Location>

now restart ur apache.
For security purpose to give authentication to the user we have to create authentication file with the command,
htpasswd -cm /etc/svn-auth-file user_name (test)
New password : test123
Re-Type passwd : test123

And to specify which access you want to give the user, create svn-access-file inside /etc.
Inside this file add code as,
[/]
* = rw

This will give authentication to every user specified in Require user inside location.
You can specify this inside httpd.conf file as,
<Location /svn/repos>
DAV svn
SVNPath /usr/local/softwares/svn/subversion-1.4.6/repos
AuthzSVNAccessFile /etc/svn-access-file
AuthType Basic
AuthName “Subversion repository”
AuthUserFile /etc/svn-auth-file
Require user user_name
</Location>

Now you are ready to import files in the repository, with the following command.
svn import -m “Initial import.” path(from where you want to import file) file:///usr/local/softwares/svn/subversion-1.4.6/repos/(repository path)
after running this command don’t worry it is not goin to display any thing inside repos folder. To check that you can run it in the browser.
http://localhost(you have to give your domain name)/svn/repos
Now you are ready to checkout the files with any svn client. For linux user smartsvn is best.
After doin this you can start ur smartsvn client and can follow these steps,
check out project from repository -> manage -> add -> enter svn url
enter ur url here http://localhost/svn/repos
enter ->ok
server name and repository path it will take automatically. click next, choose user radio button and give user name and password.
follow the steps to fetch the files.
To install smartsvn, first get the smartsvn tar file.
untar the file, with the command
tar -xvzf smartsvn-version.gz
for smartsvn first check the correct version of java is available or not, with
java -version command.If it is coming like this then you can proceed.
java version “1.5.0_14″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode)
Sometimes java will be installed but not the JRE. In that case simply re-install java.
Can install the latest version of java with rpm bin file.
jdk-1_5_0_14-linux-i586-rpm.bin
./jdk-1_5_0_14-linux-i586-rpm.bin

go through the license and say yes.
It will installed in /usr/java/
Now have to make chnages in .bash_profile file.
cd /root
vi .bash_profile

give JAVA_HOME path.
JAVA_HOME = /usr/java/jdk1.5.0_14
Then compile it with the command,
source .bash_profile
then again check with java version.
Now you are ready to utilise the full feature of subversion.

No comments:

Post a Comment