ubuntu下svn+apache2安装配置

ubuntu下svn+apache2安装配置

1.程序安装(采用apt-get install安装)

    sudo apt-get install subversion   

sudoapt-getinstalllibapache2-svn

    sudo apt-get install  Apache2

2.创建仓库父目录

     sudo mkdir /home/svn

3.创建仓库

     所有的创建都放在刚刚创建的仓库父目录下

    创建一个示例仓库:tools

    sudo svnadmin create /home/svn/tools

4.处理仓库目录权限(linux中用户对目录、文件的访问必须拥有相关权限)

    a.添加subversion组:

          sudo addgroup subversion

     b.给相关用户赋予文件访问权限:

         chown -R www-data:subversion svn 修改文件夹权限

         chmod -R g rws svn  修改同组权限

5.修改apache配置文件

      a.从创建的tools仓库复制权限,密码文件做为全局共用权限,密码文件

            sudo cp /home/svn/tools/conf/authz /home/svn           

            sudo cp /home/svn/tools/conf/passwd /home/svn

      b.修改dav_svn.conf配置文件

            sudo gedit /etc/apache2/mods-available/dav_svn.conf

            修改文件中<Location /svn></Location>之间的部分为

            <Location /svn>

<Location /svn>#指定仓库别名,例:http://your's ip/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 /home/svn    #指定仓库父目录,如果只有一个仓库,可用SVNPath指定

  # 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 /home/svn/passwd   #指定用户目录

  # To enable authorization via mod_authz_svn
  #AuthzSVNAccessFile /etc/apache2/dav_svn.authz  #指定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> 

</Location>
 

   c.往/home/svn/passwd里添加用户

        sudo htpasswd -c /etc/subversion/passwd admin

        根据提示输入用户密码admin,搞定

6.重启apache

    sudo /etc/init.d/apache2 restart

7.测试

     测试url为:http://your's ip/svn/tools

     用户:admin

     密码:admin

这是我自己的安装经过,请各位大侠指教!

相关推荐