Find us on facebook

Showing posts with label SVN. Show all posts
Showing posts with label SVN. Show all posts

Jul 3, 2015

Setup SVN server on ubuntu 14.04

Start the installation .
Step 1 : Update the repositories.
sudo apt-get update

Step 2 : Install SVN and apache webserver (To access SVN through http ) .
sudo apt-get install subversion apache2 libapache2-svn apache2-utils

Step 3 » Create a directory and create a new repository in that directory ( testrepo is the repository name ).
sudo mkdir -p /svn/repos/
sudo svnadmin create /svn/repos/testrepo

Step 4 » Change ownership for the repository.
sudo chown -R www-data:www-data /svn/repos/testrepo

Step 5 » Create a file testrepo.conf in /etc/apache2/sites-available/ and add the below lines for creating apache virtual host.
<Location /svn>
  DAV svn
  SVNParentPath /svn/repos/
  AuthType Basic
  AuthName "Test Repo"
  AuthUserFile /etc/svnpasswd
  Require valid-user
</Location>
SVNParentPath /svn/repos/ : Parent Directory without repository name.
AuthUserFile /etc/svnpasswd : File need to be created ( Step 8) for user details.

Step 6 »Enable the Site ( testrepo in the below command should match the file name created in the previous step )
sudo a2ensite testrepo

Step 7 » Restart or reload apache service.
sudo service apache2 reload

Step 8 » Create user for accessing repository and add the user details to /etc/svnpasswd file.
Use this command to create first user.
sudo htpasswd -cm /etc/svnpasswd user1

Use the same command without c option to create additional users.
sudo htpasswd -m /etc/svnpasswd user2

Step 9 » Access http://yourip/svn/testrepo in your browser ( Eg http://10.0.1.15/svn/testrepo ) and you can see the page like below after successful authentication.

Install Subversion Using Yum CentOS 6.x

yum install mod_dav_svn subversion

sudo vim /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn

   # Limit write permission to list of valid users.
   #<LimitExcept GET PROPFIND OPTIONS REPORT>
      # Require SSL connection for password protection.
      # SSLRequireSSL

      AuthType Basic
      AuthName "Subversion repositories"
      AuthUserFile /etc/svn-auth-users
      Require valid-user
   #</LimitExcept>
</Location>

apachectl configtest
sudo service httpd restart

================================
sudo yum install mod_auth_mysql
sudo vi /etc/httpd/conf.d/subversion.conf
    AuthType Basic
    AuthName "svn repository"
    Require valid-user
    AuthMySQLEnable on
    AuthMySQLPwEncryption sha1
    AuthMySQLHost localhost
    AuthMySQLUser username(of redmine)
    AuthMySQLPassword password
    AuthMySQLDB redmine
    AuthMySQLNameField login
    AuthMySQLPasswordField hashed_password
    AuthMySQLUserTable "users"
apachectl configtest
sudo service httpd restart
===============================
Next we have to actually create the password file that you specified in the previous step. Initially you'll use the -cm arguments. This creates the file and also encrypts the password with MD5. If you need to add users make sure you simply use the -m flag, and not the -c after the initial creation.

## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password:
Re-type new password:
Adding password for user testuser

## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password:
Re-type new password:
Adding password for user testuser2

mkdir /var/www/svn
cd /var/www/svn

sudo chown -R apache:apache /var/www/svn

svnadmin create testrepo
sudo chown -R apache.apache testrepo

## If you have SELinux enabled (you can check it with "sestatus" command) ##
## then change SELinux security context with chcon command ##

chcon -R -t httpd_sys_content_t /var/www/svn/testrepo

## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo

## Fedora 21/20/19/18 and CentOS/Red Hat (RHEL) 7 ##
systemctl restart httpd.service

## CentOS/Red Hat (RHEL) 6.6/5.11 ##
service httpd restart
## OR ##
/etc/init.d/httpd restart

Goto http://localhost/svn/testrepo address and you should see popup to enter username and password:

Then Configure repository
To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:

## Disable anonymous access ##
anon-access = none

## Enable access control ##
authz-db = authz

Create trunk, branches and tags structure under testrepo
Create “template” directories with following command:
mkdir -p /tmp/svn-structure-template/{trunk,branches,tags}

Then import template to project repository using “svn import” command:
Shell

svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Adding         /tmp/svn-structure-template/trunk
Adding         /tmp/svn-structure-template/branches
Adding         /tmp/svn-structure-template/tags

Committed revision 1.

Import online project to SVN folder
svn import /var/www/vhosts/xxx.cf/httpdocs/yyy http://xx.xxx.xxx.xx/svn/testrepo2 -m "first import"

Go to domain/httpdocs and use following command to get first repo to this folder
svn co http://88.208.221.72/svn/testrepo2

After each commit, to update online site,
Go to domain/httpdocs and use following command
svn co http://88.208.221.72/svn/testrepo2