sexta-feira, 3 de junho de 2016

Install SVN 1.8 on CentOS

1. Introduction


This post shows how to install SVN 1.8 into CentOS 6.5.


2. Pre-conditions

2.1. Install Apache HTTP Server

# echo "Check if httpd (Apache Server) is installed and running ..."
# service httpd status
httpd (pid  1665) is running...
#
# echo "Install httpd (apache server) if needed ..."
# yum install httpd
# service httpd restart
# chkconfig httpd on


2.2. Setup Yum Repository for SVN Subversion

# vim /etc/yum.repos.d/wandisco-svn.repo
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/$releasever/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0

2.3.  Install Subversion Package

Before installing latest package remove existing subversion
# yum remove subversion*
# yum clean all
# yum install subversion
# svn --version
svn, version 1.8.16 (r1740329)
   compiled Apr 26 2016, 13:16:01 on x86_64-unknown-linux-gnu
Copyright (C) 2016 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
                                                                     
The following repository access (RA) modules are available:
                                                                     
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.7
  - handles 'http' scheme
  - handles 'https' scheme


2.4.  Install Subversion with Apache - Mod_Dav_SVN

# yum install subversion mod_dav_svn
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror.globo.com
 * epel: mirror.globo.com
 * extras: mirror.globo.com
 * updates: mirror.globo.com
Setting up Install Process
Package subversion-1.8.16-1.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mod_dav_svn.x86_64 0:1.8.16-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package             Arch           Version           Repository           Size
================================================================================
Installing:
 mod_dav_svn         x86_64         1.8.16-1          WandiscoSVN          77 k
Transaction Summary
================================================================================
Install       1 Package(s)
Total download size: 77 k
Installed size: 216 k
Is this ok [y/N]: y
Downloading Packages:
mod_dav_svn-1.8.16-1.x86_64.rpm                          |  77 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mod_dav_svn-1.8.16-1.x86_64                                  1/1
Stopping httpd: [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[  OK  ]
  Verifying  : mod_dav_svn-1.8.16-1.x86_64                                  1/1
Installed:
  mod_dav_svn.x86_64 0:1.8.16-1
Complete!


2.5. Configure Subversion with Apache - MOD_DAV_SVN

# 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     |
|                                                            |
| Alias /svn /var/svn                                        |
|                                                            |
| <Location /svn>                                            |
|   DAV svn                                                  |
|   SVNPath  /var/svn/myrepo/                                |
|   AuthType Basic                                           |
|   AuthName "SVN Repo"                                      |
|   AuthUserFile /etc/svn-users                              |
|   Require valid-user                                       |
| </Location>                                                |
+------------------------------------------------------------+


2.6. Create First SVN Repository

# cd /var
# mkdir /var/svn
# cd /var/svn
# svnadmin create myrepo

# echo "don't forget to give permission to apache"
don't forget to give permission to apache

# chown apache:apache -R /var/svn


2.7. Create SVN Users ( /etc/svn-users )

# touch /etc/svn-users
# htpasswd -m /etc/svn-users admin
# htpasswd -m /etc/svn-users user1
# htpasswd -m /etc/svn-users user2


2.8. Create SVN Authorizations ( /etc/svn-users )

vim /etc/svn-authz
#
# Define groups
#
[groups]
admins = admin
users = user1, user2
devteams = user1, user2

#
# Default access rule for ALL repositories: 
# - Everyone can read, admins can write, hacker is excluded.
#
[/]
* = r
@admins = rw
hacker =

# echo "restart httpd service"
restart httpd service
# service httpd stop; service httpd start
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

2.9. Create your first project on SVN repository

# svn mkdir http://localhost/svn/_templateSvnProject -m "Creating default _templateSvnProject"
Committed revision 1.
#
# echo "You don't need to execute following commands! It's only for demo purpose"
You don't need to execute following commands! It's only for demo purpose
#
svn mkdir http://localhost/svn/testing-remove -m "Creating project only for testing remove project"
Committed revision 2.
#
svn delete http://localhost/svn/testing-remove -m "Deleting a created project only for testing"
Committed revision 3.

2.9. Create your project structure using best practices

# cd ~
# mkdir my-svn-working-copy
# mkdir my-svn-working-copy/_templateSvnProject
# mkdir my-svn-working-copy/_templateSvnProject/branches
# mkdir my-svn-working-copy/_templateSvnProject/tags
# mkdir my-svn-working-copy/_templateSvnProject/trunk
# echo "Project Template using SVN best practices" > my-svn-working-copy/_templateSvnProject/trunk/README.txt
# ls -R my-svn-working-copy/
my-svn-working-copy/:                            
_templateSvnProject                              
                                                 
my-svn-working-copy/_templateSvnProject:         
branches  tags  trunk                            
                                                 
my-svn-working-copy/_templateSvnProject/branches:
                                                 
my-svn-working-copy/_templateSvnProject/tags:    
                                                 
my-svn-working-copy/_templateSvnProject/trunk:   
README.txt                                       


2.10. Import your project structure and contents to repository

# echo "Go to working directory"
Go to working directory
cd ~/my-svn-working-copy
echo "Go to project directory"
Go to project directory
cd _templateSvnProject
# pwd
/root/my-svn-working-copy/_templateSvnProject
ls
branches tags trunk
#
svn import -m "First Check-in" --username  admin  --password  admin  http://localhost/svn/_templateSvnProject
Adding         branches        
Adding         tags            
Adding         trunk           
Adding         trunk/README.txt
                               
Committed revision 4.          


2.11. Access repository in your browser

  • Access  http://127.0.0.1/svn/myrepo/
+--------------------------------------------+
| URL:  http://127.0.0.1/svn/myrepo/    |GO| |
+--------------------------------------------+
|                                            |
|      +----------------------------+        |
|      | Autenticacao obrigatória   |        |
|      |        +------------+      |        |
|      |  Nome: | admin      |      |        |
|      |        +------------+      |        |
|      | Senha  | admin      |      |        |
|      |        +------------+      |        |
|      +----------------------------+        |
|                                            |
+--------------------------------------------+

  • Subversion shows repository
+--------------------------------------------------------------+
| svn - Revision 4: /                                          |
|                                                              |
|  _templateSvnProject/                                        |
|                                                              |
|                                                              |
| Powered by Apache Subversion version 1.8.16 (r1740329).      |
+--------------------------------------------------------------+


  • Click on link "_templateSvnProject"
+--------------------------------------------------------------+
svn - Revision 4: /_templateSvnProject                       |
|                                                              |
|  ..                                                          |
|  branches/                                                   |
|  tags/                                                       |
|  trunk/                                                      |
|                                                              |
|                                                              |
| Powered by Apache Subversion version 1.8.16 (r1740329).      |
+--------------------------------------------------------------+


  • And after on link "trunk"
+--------------------------------------------------------------+
svn - Revision 4: /_templateSvnProject/trunk                 |
|                                                              |
|  ..                                                          |
|  README.txt                                                  |
|                                                              |
|                                                              |
| Powered by Apache Subversion version 1.8.16 (r1740329).      |
+--------------------------------------------------------------+


2.12. Check out your project from repository

Now you must have faith. You will remove all your local files and check project out from repository in your SVN local copy

echo "Go to working directory"
Go to working directory
cd ~/my-svn-working-copy
# ls
drwxr-xr-x 5 root root 4096 Sep 12 15:13 _templateSvnProject
# rm -rf ./_templateSvnProject
# ls -la
drwxr-xr-x 2 root root 4096 Sep 12 15:26 .
dr-xr-x---. 7 root root 4096 Sep 12 15:13 ..
# echo "Oh my God! Be calm. You believe in repository, don't you?"
echo "Oh my God! Be calm. You believe in repository, don't you?"
# svn checkout --username admin --password admin http://localhost/svn/_templateSvnProject
A _templateSvnProject/trunk
A _templateSvnProject/branches
A _templateSvnProject/tags
A _templateSvnProject/trunk/README.txt
Checked out revision 4.
cd ~/my-svn-working-copy
# ls -lR
.:                                                          
total 4                                                     
drwxr-xr-x 6 root root 4096 Sep 12 15:31 _templateSvnProject
./_templateSvnProject:                                      
total 12                                                    
drwxr-xr-x 2 root root 4096 Sep 12 15:31 branches           
drwxr-xr-x 2 root root 4096 Sep 12 15:31 tags               
drwxr-xr-x 2 root root 4096 Sep 12 15:31 trunk              
./_templateSvnProject/branches:                             
total 0                                                     
./_templateSvnProject/tags:                                 
total 0                                                     
./_templateSvnProject/trunk:                                
total 4                                                     
-rw-r--r-- 1 root root 42 Sep 12 15:31 README.txt           




2.13. Import your project using TortoiseSVN

  • #1 - Create your project best practice structure

  • #2 - Create a _READ-ME.txt file under 'trunk'

  • #3 - Positioned into your project structure, Right Click on Windows Explorer and choose menu option TortoiseSVN Import

  • #4 - Define repository URL

  • #5 - Authenticate with 'admin'

  • #6 - Check import finished message

  • #7 - Check browsing HTTP

3. References



Nenhum comentário:

Postar um comentário