你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu搭建SVN服务器+Apache http访问

[日期:2012-06-03] 来源:Linux社区  作者:panpanloveruth [字体:大 中 小]

二、HTTP:// [apache]

1、安装包 [已安装subversion]

$ sudo apt-get install libapache2-svn

2、创建版本仓库:
sudo svnadmin create /目录地址
目录地址必须存在,这个就是保存版本仓库的地方,不同的版本仓库创建不同的文件夹即可,比如:

sudo svnadmin create /home/svn/tang

3、然后把这个版本仓库目录授权给apache读写:

sudo chown -R www-data:www-data  /home/svn/tang

4、然后来到打开apache配置文件:

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

加入如下内容:

  1. # dav_svn.conf - Example Subversion/Apache configuration   
  2. #   
  3. # For details and further options see the Apache user manual and   
  4. # the Subversion book.   
  5. #   
  6. # NOTE: for a setup with multiple vhosts, you will want to do this   
  7. # configuration in /etc/apache2/sites-available/*, not here.
  8. # <Location URL> ... </Location>   
  9. # URL controls how the repository appears to the outside world.   
  10. # In this example clients access the repository as <a href="http://hostname/svn/">http://hostname/svn/</a>   
  11. # Note, a literal /svn should NOT exist in your document root.   
  12. <Location /svn>
  13.   # Uncomment this to enable the repository   
  14.   DAV svn
  15.   # Set this to the path to your repository   
  16.   SVNPath /home/svn/tang  
  17.   # Alternatively, use SVNParentPath if you have multiple repositories under   
  18.   # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).   
  19.   # You need either SVNPath and SVNParentPath, but not both.   
  20.   #SVNParentPath /home/svn/tang   
  21.   # Access control is done at 3 levels: (1) Apache authentication, via   
  22.   # any of several methods.  A "Basic Auth" section is commented out   
  23.   # below.  (2) Apache <Limit> and <LimitExcept>, also commented out   
  24.   # below.  (3) mod_authz_svn is a svn-specific authorization module   
  25.   # which offers fine-grained read/write access control for paths   
  26.   # within a repository.  (The first two layers are coarse-grained; you   
  27.   # can only enable/disable access to an entire repository.)  Note that   
  28.   # mod_authz_svn is noticeably slower than the other two layers, so if   
  29.   # you don't need the fine-grained control, don't configure it.
  30.   # Basic Authentication is repository-wide.  It is not secure unless   
  31.   # you are using https.  See the 'htpasswd' command to create and   
  32.   # manage the password file - and the documentation for the   
  33.   # 'auth_basic' and 'authn_file' modules, which you will need for this   
  34.   # (enable them with 'a2enmod').   
  35.   AuthType Basic  
  36.   AuthName "Subversion Repository"  
  37.   AuthUserFile /etc/apache2/dav_svn.passwd  
  38.   # To enable authorization via mod_authz_svn   
  39.   #AuthzSVNAccessFile /etc/apache2/dav_svn.authz
  40.   # The following three lines allow anonymous read, but make   
  41.   # committers authenticate themselves.  It requires the 'authz_user'   
  42.   # module (enable it with 'a2enmod').   
  43.   #<LimitExcept GET PROPFIND OPTIONS REPORT>   
  44.     Require valid-user  
  45.   #</LimitExcept>
  46. </Location>

location说的是访问地址,比如上述地址,访问的时候就是

http://192.168.1.104/tang

其中有两行被注释掉了,以保证每次都需要用户名密码。
最后一步就是创建访问用户了,建议将用户名密码文件存放在当前版本仓库下conf文件夹下,这样版本仓库多的时候无至于太乱。
因为conf文件夹下已经存在passwd文件了,所以直接添加用户:

sudo htpasswd -c /home/svn/project/conf/passwd tang

然后输入两遍密码,tang 这个用户就创建好了。

打开 /etc/apache2/dav_svn.passwd   这个文件,会开到形如如下形式的文本:

tang:WEd.83H.gealA  //后面是加密后的密码。

创建以后,再次需要往别的版本仓库添加这个用户,直接把这一行复制过去就可以了。
重启apache就可以了。

sudo /etc/init.d/apache2 restart

开机自动启动svn服务

在init.d目录建立一个脚本文件svnd.sh
# cd /etc/init.d
# vim svnd.sh
输入svnd.sh内容如下(/kaifa/svn 为svn仓库目录):

#!/bin/bash
#svnserve startup
svnserve -d -r /kaifa/svn

保存退出。
更新,修改权限:
# update-rc.d svnd.sh defaults
# chmod 777 svnd.sh

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款