Thursday, June 9, 2011

SVNServer set up on CentOS

courtesy of
http://wiki.centos.org/HowTos/Subversion
http://lincgeek.org/blog/?p=347

1.

[root@lucifer ~]yum install mod_dav_svn subversion

2.
[root@lucifer ~]vim /etc/httpd/conf/httpd.conf

change Server Name as its IP (not sure if it is necessary)

3.
[root@lucifer ~]service httpd start

[root@lucifer ~]chkconfig httpd on

4.
[root@lucifer ~]vim /etc/httpd/conf.d/subversion.conf

make it look like the following

# Make sure you uncomment the following if they are commented out
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

# Add the following to allow a basic authentication and point Apache to where the actual
# repository resides.
<Location /repos>
        DAV svn
        SVNPath /var/www/svn/repos
        AuthType Basic
        AuthName "Subversion repos"
        AuthUserFile /etc/svn-auth-conf
        Require valid-user
</Location>

NOTE: if you

see 403 "Forbidden You don't have permission to access  ...." 


check if you are using SVNParentPath instead of SVNPath

5.
Add the 1st User
[root@lucifer ~] htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type new password:
Adding password for user yourusername

Add additional user
[root@lucifer ~] htpasswd -m /etc/svn-auth-conf anotherusername
New password:
Re-type new password:
Adding password for user anotherusername

6.
Create the repo
[root@lucifer ~] cd /var/www/ -- Or wherever you placed your path above
[root@lucifer ~] mkdir svn
[root@lucifer ~] cd svn
[root@lucifer ~] svnadmin create repos
[root@lucifer ~] chown -R apache.apache /var/www/svn/*
[root@lucifer ~] chmod 770 -R /var/www/svn/*
[root@lucifer ~] service httpd restart

7.
Test it out
http://[yourmachine]/repos

8.
Add items to the repos with comments
[root@lucifer ~] svn import /tmp/mytestproj/ file:///var/www/svn/repos/mytestproj -m "Initial repository layout for mytestproj"
Adding         /tmp/mytestproj/main
Adding         /tmp/mytestproj/main/mainfile1.cfg
Adding         /tmp/mytestproj/configurations
Adding         /tmp/mytestproj/configurations/testconf1.cfg
Adding         /tmp/mytestproj/options
Adding         /tmp/mytestproj/options/testopts1.cfg

9.
Edit and Commit

[me@mylappy ~] cd mytestproj
[me@mylappy ~] vim configurations/testconf1.cfg -- Add or delete something and save.
[me@mylappy ~] svn commit -m "Added a line to testconf1.cfg."
Sending        configurations/testconf1.cfg
Transmitting file data .
Committed revision 2.

10.
Add to existing folder in the repo

Now this is all fine and dandy, but how do you add more files to an already existing repo directory? Easy, with the add argument. Go ahead and checkout your latest and greatest, copy a file over to a directory, add, then commit the changes.

11.
[me@mylappy ~] svn co http://yoursvnserver/repos/mytestproj
A    mytestproj/main
A    mytestproj/main/mainfile1.cfg
A    mytestproj/configurations
A    mytestproj/configurations/testconf1.cfg
A    mytestproj/options
A    mytestproj/options/testopts1.cfg
Checked out revision 2.

[me@mylappy ~] cd mytestproj
[me@mylappy ~] cp /etc/yum.repos.d/CentOS-Base.repo configurations/
[me@mylappy ~] svn add configurations/CentOS-Base.repo
A         configurations/CentOS-Base.repo

[me@mylappy ~] svn commit -m "Added the CentOS Yum repo file."
Adding         configurations/CentOS-Base.repo
Transmitting file data .
Committed revision 3.

Delete

[me@mylappy ~] svn delete configurations/CentOS-Base.repo
[me@mylappy ~] svn commit -m "Delete the CentOS Yum repo file."

No comments:

Post a Comment