设为首页 收藏本站
查看: 907|回复: 0

[经验分享] debian5.0安装SVN服务器

[复制链接]

尚未签到

发表于 2018-5-15 13:04:55 | 显示全部楼层 |阅读模式


http://blog.chinaunix.net/u2/73230/showart_1149879.html

Subversion是新一代的开源版本控制系统,用以取代CVS。有关Subversion最详尽的资料就是官方的Subversion Book了。它是由开源社区编写的自由图书,已通过O'Reilly Media出版。下面简单介绍一下Subversion在Debian下的安装和配置过程。

1.安装
debian:/# aptitude install subversion subversion-tools apache2 libapache2-svn
2.创建一个新的空的版本库:
debian:/# mkdir -p /home/svn/lxq
debian:/# svnadmin create /home/svn/lxq #版本名称lxq
在/home/svn/lxq 此路径上创建一个新的空的版本库,如果提供的路径不存在,它会为你创建。数据储存方式默认采用Berkeley DB。

3.修改apache的svn设定文档:/etc/apache2/mods-available/dav_svn.conf
配置文件位于/etc/apache2/mods-enabled/目录下,配置文件共有两个,分别是dav_svn.conf和dav_svn.load.
dav_svn.load文件负责装载必要的模块,内容如下:
# Depends: dav
LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so
LoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.so

在装载mod_dav_svn.so前,必须先装载mod_dav.so模块。它由dav.load文件控制,内容如下:
[size=+0]LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so
dav_svn.conf是mod_dav_svn.so模块的配置文件,内容如下:
# 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.
# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn>                                 #设置访问路径
  # Uncomment this to enable the repository,
   DAV svn                                      #启用
  # Set this to the path to your repository
   SVNPath /home/svn  #设置版本存储库路径,仅支持单个储存库,该路径要可被Apache进程访问。
  # 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 /data/subversion   #如果subversion下有多个储存库,则用SVNParentPath
  # Access control is done at 3 levels: (1) Apache authentication, via
  # any of several methods.  A &quot;Basic Auth&quot; 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                               #启用Apache基础验证
   AuthName &quot;Subversion Repository&quot;             #设置验证框标题
   AuthUserFile /etc/apache2/dav_svn.passwd     #指定验证用户文件名
  # To enable authorization via mod_authz_svn
  # AuthzSVNAccessFile /etc/apache2/dav_svn.authz  #启用目录级别授权,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>  #允许匿名访问,不允许Commit,不能
                                               与AuthzSVNAccessFile同时使用
    Require valid-user                        
  </LimitExcept>
</Location>

4.更改该目录的拥有者为网页读取
修改/目录访问权限使它可被Apache进程访问,我的Apache是用www-data启动的,所以设置方法如下:
debian:/# chown -R www-data.www-data /home/svn/lxq
5.设定使用人的权限:修改/etc/apache2/dav_svn.authz
   通过Apache的用户验证功能可以区别匿名用户和验证用户,从而赋予匿名用户读权限和验证用户读/写的权限。这些权限只能在全局范围内设置,不能设置具体的某个目录是否能被某个用户操作。要实现目录级别的授权,就要使用mod_authz_svn.so模块提供的AuthzSVNAccessFile指令。它会指定一个授权文档,该授权文档设置具体的目录权限。根据上面的配置,授权文档名叫dav_svn.authz,它的内容如下:

[groups]              #定义组
admin=lxq001,lxq007
tests=test1,test2
[lxq:/]              #定义lxq版本库根目录的访问权限
@admin=rw            #admin组有读写权限
tests=r              #test用户只有读权限
[lxq:/test]           #定义oa版本库下test目录的访问权限
*=                   #禁止所有用户访问,星号代表所有用户,权限为空代表没有任何权限
lxq=rw              #打开lxq001用户的读写权限


6.增加apache连接进来的使用者帐号
/etc/apache2/dev_svn.passwd
debian:/# htpasswd -c /etc/apache2/dav_svn.passwd lixueq
New password:
Re-type new password:
Adding password for user lixueq

debian:/# htpasswd -c /etc/apache2/dev_svn.passwd test1


7.重启apache2

在/etc/apache2/sites-available/default中添加:

<Location /svn>
    DAV svn
    SVNListParentPath on
    SVNParentPath /home/svn
    AuthType Basic
    AuthName &quot;Subversion Repository&quot;
    AuthUserFile /etc/apache2/dav_svn.passwd
    <LimitExcept GET PROPFIND OPTIONS REPORT>
        Require valid-user
    </LimitExcept>
</Location>




=========================================================





<Location /svn>
    DAV svn
   # SVNListParentPath on
    SVNParentPath /home/svn
   #SVNPath /home/svn
     AuthType Basic
    AuthName &quot;Subversion Repository&quot;
    AuthUserFile /etc/apache2/dav_svn.passwd
        Require valid-user
    AuthzSVNAccessFile  /etc/apache2/dav_svn.authz
</Location>
</VirtualHost>













然后重启apache2


debian:/# nano /etc/init.d/apache2 restart

8.导入你的源码:
debian:/# svn import /var/www/web1
file:///home/svn/lxq

9.显示储存库内容:
debian:/# svn list file:///home/svn/lxq
index.php
a.php

显示web1目录内容,成功导入。




使用svn://访问,需开启此服务:


debian:/# svnserve -d -r /home/svn/lxq/




上面我使用了file:///形式的URL来访问Subversion库,这表示在本地通过文件系统访问。但我们的Subversion库可能需要通过网络被其它用户访问,这就需要用到其它的协议,下表是Subversion支持的各种访问协议:

Table 访问协议


协议
访问方法



file:///通过本地磁盘访问。
http://与Apache组合,通过WebDAV协议访问。
https://同上,但支持SSL协议加密连接。
svn://通过svnserve服务自定义的协议访问。
svn+ssh://同上,但通过SSH协议加密连接。















TAG Debian Linux

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-460588-1-1.html 上篇帖子: 标题: Debian5.0硬盘安装后 软件安装 和升级 下篇帖子: debian5中安装dhcp服务器的简明过程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表