Como criar um servidor SVN

1 – Instalando os pacotes necessários:

1 # apt-get update && apt-get install subversion subversion-tools libapache2-svn

Assim que os pacotes forem baixados e instalados o módulo para integração libapache2-svn será iniciado e bastará apenas reiniciar o Apache para entrar em funcionamento.

2 – Criando o diretório onde iremos criar os repositórios subversion:

1 # mkdir -p /usr/local/svn

3 – Criando o repositório propriamente dito e aplicando as permissões necessárias:

1 # svnadmin create --fs-type fsfs /usr/local/svn/repositorio
1 # chown -R www-data:subversion /usr/local/svn/repositorio
1 # chmod -R 770 /usr/local/svn/repositorio

4 – Configurando o repositório:

1 # nano /etc/apache2/mods-available/dav_svn.conf

Este é o arquivo original:

# dav_svn.conf – Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.

# In this example clients access the repository as http://hostname/svn/

  # Uncomment this to enable the repository
  #DAV svn

  # Set this to the path to your repository
  #SVNPath /var/lib/svn
  # Alternatively, use SVNParentPath if you have multiple repositories under
  # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, …).
  # You need either SVNPath and SVNParentPath, but not both.
  #SVNParentPath /var/lib/svn

  # Access control is done at 3 levels: (1) Apache authentication, via
  # any of several methods.  A “Basic Auth” section is commented out
  # below.  (2) Apache <Limit> and <LimitExcept>, also commented out
  # below.  (3) mod_authz_svn is a svn-specific authorization module
  # which offers fine-grained read/write access control for paths
  # within a repository.  (The first two layers are coarse-grained; you
  # can only enable/disable access to an entire repository.)  Note that
  # mod_authz_svn is noticeably slower than the other two layers, so if
  # you don’t need the fine-grained control, don’t configure it.

  # Basic Authentication is repository-wide.  It is not secure unless
  # you are using https.  See the ‘htpasswd’ command to create and
  # manage the password file – and the documentation for the
  # ‘auth_basic’ and ‘authn_file’ modules, which you will need for this
  # (enable them with ‘a2enmod’).
  #AuthType Basic
  #AuthName “Subversion Repository”
  #AuthUserFile /etc/apache2/dav_svn.passwd

  # To enable authorization via mod_authz_svn
  #AuthzSVNAccessFile /etc/apache2/dav_svn.authz

  # The following three lines allow anonymous read, but make
  # committers authenticate themselves.  It requires the ‘authz_user’
  # module (enable it with ‘a2enmod’).
  #<LimitExcept GET PROPFIND OPTIONS REPORT>
    #Require valid-user
  #</LimitExcept>

 

Realizando a configuração necessária fica assim:

<Location /svn/repositorio>
        DAV svn
        SVNPath /usr/local/svn/repositorio
        AuthType Basic
        AuthName “Acessando repositorio Subversion”
        AuthUserFile /etc/apache2/auth
        #<LimitExcept GET PROPFIND OPTIONS REPORT>
        Require valid-user
        #</LimitExcept>
</Location>

5 – Crie o arquivo de senhas e os usuários que acessarão o repositório:

1 # htpasswd -c /etc/apache2/auth pinguim

New password:
Re-type new password:
Adding password for user pinguim

Para criar novos usuários você deve tirar do comando htpasswd a opção “-c” pois ela criaria um novo arquivo, o que não é o desejado.

Reinicie o Apache:

1 # service apache2 restart

Restarting web server: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
… waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

Neste momento já temos o SVN integrado ao Apache2, agora vamos realizar o acesso para verificar o funcionamento. Isso é muito simples, basta abrir o browser e digitar http://<ip-do-seu-servidor>/svn/repositorio

Fonte: softwarelivre-ac.org

Leave a Reply

Your email address will not be published. Required fields are marked *