Monday, October 22, 2007

HOWTO - http(Apache) + Subversion on FC7

This is a howto on getting subversion (multiple repositories) + http on FC7.

We will be logged in as root for quite a few tasks - make sure that you have read relevant documentation/tutorials before trying this HOWTO.

Keep an eye on 2 important things:
  • id of logged in user
  • pwd - present working directory
Both of these will be apparent in the prompt - I have used the standard prompt on
any Linux system - [user@machine 'pwd']

1. Install svn and mod_dav_svn via yum

2. Log in as root and create your directory structure for holding the repo:
[root@rknowsys2 var]# mkdir -p /var/subversion/repos


3. The repository has to be owned by apache to enable apache to read and write to this directory:
[root@rknowsys2 var]# chown -R apache:apache /var/subversion


4. Create your repo -
[root@rknowsys2 var]# svnadmin create /var/subversion/repos/

5. Import you source files into the repo - My source files are in directory "/root/kc/for-svn/iRunway" ------
[root@rknowsys2 var]# svn import /root/kc/for-svn/iRunway file:///var/subversion/repos/iRunway -m "initial import"
You will see stuff like this........
Adding /root/kc/for-svn/iRunway/trunk/public/application-help.html
Adding /root/kc/for-svn/iRunway/trunk/public/favicon.ico
..................
..............
...................................
Committed revision 1.

6. Now ensure that /var/subversion is owned by apache - Since I ran the 'svn create' and 'svn import' as root, I am not sure who owns the repo - The below command is to remove these doubts:
[root@rknowsys2 for-svn]# chown -R apache:apache /var/subversion

7. Now lets configure apache to work with subversion
refer this link: http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html
Edit the conf file and add the content at the end of the file:
[root@rknowsys2 junk]# vi /etc/httpd/conf/httpd.conf
# kc start configuring apache for subversion 07-aug-07
# Instructions from:
# http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html
# The above page is also saved to /root/admin-functions/subversion-stuff
# already loaded - kc LoadModule dav_svn_module modules/mod_dav_svn.so

DAV svn
SVNPath /var/subversion/repos/
#ServerName svn-rknowsys.no-ip.info
#ServerName 192.168.0.13 server name given in orig location above!!!!

# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/svn-auth-file

# only authenticated users may access the repository
Require valid-user

CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION
# kc end subversion stuff 07-aug-07

8. Now create subversion users:
[root@rknowsys2 junk] htpasswd -cm /etc/svn-auth-file kcr
New password: *****
Re-type new password: *****
Adding password for user kcr

9. Restart the httpd server
[root@rknowsys2 for-svn]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

10. Start using the repo
[root@rknowsys2 junk]# svn list http://192.168.0.13/repos/iRunway
Authentication realm: Subversion repository
Password for 'root':
Authentication realm: Subversion repository
Username: kcr
Password for 'kcr':
branches/
tags/
trunk/
[root@rknowsys2 junk]#

11. And now start creating subversion users using the htpasswd command shown above. - You are ready to roll it out to users.


12. Making multiple subversion repositories:
Let us do this in directory:/var/subversion/repos1
[root@rknowsys2 ~]# sudo -u apache mkdir -p /var/subversion/repos1
[root@rknowsys2 ~]# svnadmin create /var/subversion/repos1/ideaexchage
[root@rknowsys2 ~]# svnadmin create /var/subversion/repos1/tourism
[root@rknowsys2 ~]# svn import /root/kc/for-svn/ideaXchange/ file:///var/subversion/repos1/ideaexchage/ -m "Initial import"
Adding ........
..........................................................
Committed revision 1.
[root@rknowsys2 ~]# svn import /root/kc/for-svn/tourism/ file:///var/subversion/repos1/tourism/ -m "Initial import"
Committed revision 1.

13. Now need to modify apache conf file:
Put this in the apache dir:
# kc start configuring apache for multiple repos in subversion 22-aug-07
# Instructions from:
# http://svn.haxx.se/users/archive-2004-09/1190.shtml
# http://cheminfo.informatics.indiana.edu/~rguha/misc/svnapache.html
# The above page is also saved to /root/admin-functions/subversion-stuff
# already loaded - kc LoadModule dav_svn_module modules/mod_dav_svn.so

DAV svn
SVNParentPath /var/subversion/repos1/

# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/svn-auth-file

# only authenticated users may access the repository
Require valid-user

# kc end subversion stuff 22-aug-07

14. Restart the apache server
[root@rknowsys2 ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

15. Verify that the new repos are accessible
[root@rknowsys2 ~]# svn list http://192.168.0.12/repos1/tourism
Authentication realm: Subversion repository
Password for 'root':
Authentication realm: Subversion repository
Username: kcr
Password for 'kcr':
branches/
tags/
trunk/
[root@rknowsys2 ~]#

WORKING FINE...........
The problem was I typed 'repo1' instead of 'repos1'

No comments: