爱她吗 发表于 2015-7-30 14:46:43

[SCM]源码管理

  转自:
  

http://www.iyunv.com/andgame/archive/2010/10/17/1853733.html
http://www.iyunv.com/selfly/archive/2011/01/14/1935715.html
Linux 安装SVN + Apache + 权限控制
   

  一:相关版本
subversion在安装的时候,要求相关软件的版本一致,而不是说软件版本最新就最好.下面是我安装的相关版本.
httpd-2.2.3.tar.gz
subversion-deps-1.4.0.tar.gz
subversion-1.4.0.tar.gz
  二:安装准备
# mkdir /subversion
# cp httpd-2.2.3.tar.gz /subversion/
# cp subversion-deps-1.4.0.tar.gz /subversion/
# cp subversion-1.4.0.tar.gz /subversion/
# cd /subversion/
# tar zxvf httpd-2.2.3.tar.gz
# tar zxvf subversion-deps-1.4.0.tar.gz
# tar zxvf subversion-1.4.0.tar.gz
  到这一步,如果是32位的linux系统,可以直接安装httpd了,如果地64位的linux,需要进行以下操作,进行重新编译:
1、删除安装目录下的configure文件,在我的环境中是httpd-2.2.6/configure
2、删除“httpd-2.26/srclib/apr-util/configure”
3、通过以下命令重建编译文件(以下命令在http-2.26/目录下运行)。
#./buildconf
通过以上重建编译文件,现在可以拥有64位的apr-util了
  三:httpd的安装.
# cd /subversion/httpd-2.2.3
# ./configure --enable-dav --enable-so --prefix=/usr/local/apache2/ --enable-maintainer-mode
  (注意以上命令,参数不能随意减少,否则有可能出现一些未知的错误
如果是上面经过重建编译文件的64位Linux,使用如下命令:
#./configure --enable-dav --enable-so --prefix=/usr/local/apache2/ --enable-maintainer-mode --with-expat=builtin

  # make
# make install
# cd /usr/local/apache2/bin/
#./apachectl start   (该命令可能会出现类似 Could not reliably determine theserver's fully qualified domain name, using 192.168.0.71 forServerName的错误,不用管它,服务实际上已经启动了 停止和重启也一样)
这个时候,打开浏览器,输入http://localhost/,如果浏览器出现It Works,则说明httpd安装成功了.
  四:subversion的安装
# cd /subversion/subversion-1.4.0
#./configure --with-apxs=/usr/local/apache2/bin/apxs--with-apr=/usr/local/apache2/ --with-apr-util=/usr/local/apache2/--prefix=/usr/local/subversion --with-ssl --with-zlib--enable-maintianer-mode
# make && make install
  (
如果出现错误:make: *** Error 1
解决方法 在neon/src/Makefie 的 CFLAGS中增加 -fPIC选项 一定要加到最前面,例如 CFLAGS = -fPIC -g -O2
重新make

  五:建立和导入版本库
# cd /usr/local/subversion/bin/
# mkdir /repository
# ./svnadmin create --fs-type fsfs /repository/test
# ls /repository/test/   
//如果ls /repository/test/ 出现了下面的内容,就说明subversion安装成功了.
conf   dav   db   format   hooks   locks   README.txt
  导入版本库
# ./svn import /root/src/ file:///repository/test/ -m "initial import"
//命令成功执行,会有如下的提示信息,.
新增         /root/src/main.cpp
提交后的修订版为 1。
  六:修改目录权限
# cd /repository/test/
# chmod -R 777 *
  七:修改Apache的配置文件
1):打开apache2/conf/httpd.conf文件
2):修改httpd.conf文件,在文件的最后添加下面几行

DAV svn
SVNParentPath /usr/local/subversion/repository

3):保存退出
  上面指定的是,SVN不需要权限,即任何匿名用户都可以访问、修改、提交
在实际使用当中,需要有权限控制才行,因此,配置文件需要如下详细配置:
  进入apache2/bin目录,建立用户组和用户文件当然也可以是在其它文件夹,个人习惯把它放在这里方便操作
  建立用户组文件:
# touch authz
  在authz文件中写入如下内容,下面代码说明用户组admin有lyd,zzq,mc,yhl四个用户,admin组对[/]表示根目录具有读写权限 r代表读 w代表写:
  
admin = lyd,zzq,mc,yhl
[/]
@admin = rw
  创建用户,这里的用户需要在上面的用户组里面,才能有相应的权限:
htpasswd -cm pwd.txt lyd   第一次创建,加上 -cm 参数,需要创建用户文件pwd.txt,当然你也可以用别名字或后缀名
  htpasswdpwd.txt zzq   第二次创建,因为第一次已经创建了用户文件,所以只需要在用户文件中直接添加用户即可
  修改apache2/conf/httpd.conf文件,在最后添加下面代码,指定SVN的版本库位置及刚才创建的,权限需要使用的文件
  
DAV svn
SVNParentPath /usr/local/subversion/repository/
AuthzSVNAccessFile /usr/local/apache2/bin/authz
AuthType Basic
AuthName "Subversion"
AuthUserFile /usr/local/apache2/bin/pwd.txt
Require valid-user

  八:重启apache服务.
# cd /usr/local/apache2/bin/
# ./apachectl stop
# ./apachectl start
或者直接 restart
  起动SVN
/usr/local/subversion/bin/svnserve -d -r /repository
  

Windows 安装SVN + Apache + 权限控制
1. 下载Apache服务器和Subversion二进制压缩包(Apache版本为2.2.16 Subversion版本为1.6.13)
  Apache服务器下载地址:http://httpd.apache.org/download.cgi
  SVN服务器下载地址:http://sourceforge.net/projects/win32svn/ (SVN服务器需要下载包含mod_dav_svn.so   和mod_authz_svn.so库文件的版本,Apache需要用到这两个库文件)
  Subversion服务器端列表:http://subversion.apache.org/packages.html
  
  2. 安装Apache服务器并解压缩Subversion二进制文件;修改Apache服务器Conf文件夹下的httpd.conf
  #LoadModule dav_module modules/mod_dav.so
  #LoadModule dav_fs_module modules/mod_dav_fs.so
  把以上两行去掉注释,并添加添加以下代码,加载Subversion中的两个库文件
  LoadModule dav_svn_module "C:\SVN\svn-win32-1.6.13\bin\mod_dav_svn.so"
  LoadModule authz_svn_module "C:\SVN\svn-win32-1.6.13\bin\mod_authz_svn.so"
  也可以把mod_dav_svn.so,mod_authz_svn.so两个库文件复制到Apache的modules目录下这样引用
  LoadModule dav_svn_module modules/mod_dav_svn.so
  LoadModule authz_svn_module modules/mod_authz_svn.so
  
  同时在文件末尾加上以下配置
  
   DAV svn
   SVNParentPath C:/repos #SVNParentPath用于在此文件夹下有多项目的情况,如果只有一个项目可以用SVNPath
   AuthType Basic
   AuthName "Subversion Server"
   AuthUserFile "C:\repos\conf\htpasswd"#htpasswd文件中存放的是使用Apache自带的htpasswd生成的用户名与密码的加密文件。
  AuthzSVNAccessFile "C:\repos\conf\authz" #authz访问授权文件,遵循版本库中conf/authz规则编写   
  Require valid-user
  
  
  3. 用htpasswd命令创建用户
  C:\apache\bin>htpasswd -cm C:\repos\conf\htpasswd admin
  New password: *
  Re-type new password: *
  Adding password for user admin
  C:\apache\bin>htpasswd -m C:\repos\conf\htpasswd user1
  New password: *
  Re-type new password: *
  Adding password for user user1
  ...
  
  4. 创建版本库
  这里在repos文件夹下面创建了三个版本库
  C:\SVN\svn-win32-1.6.13\bin>svnadmin create C:\repos\repos1
  C:\SVN\svn-win32-1.6.13\bin>svnadmin create C:\repos\repos2
  C:\SVN\svn-win32-1.6.13\bin>svnadmin create C:\repos\repos3
  三个版本库共用用户、权限配置文件,所以每个版本库Conf文件夹下的配置文件都没用到
  
  5. 配置authz权限文件
  
  admin = admin,user1
  user = user3,user2
  [/]
  *=
  admin = rw
  
  @admin = rw
  
  @admin = rw
  
  @admin = rw
  重启Apache服务器,可以用TSVN或Web方式进行访问了
  
  6. 修改httpd.conf配置以便能访问版本库列表
  RedirectMatch ^(/repos)$ $1/ 
  
   DAV svn
   SVNParentPath C:/repos
   SVNListParentPath on
  AuthType Basic
   AuthName "Subversion Server"
   AuthUserFile "C:\repos\conf\htpasswd"
  AuthzSVNAccessFile "C:\repos\conf\authz"
   Require valid-user
  
  现在通过http://127.0.0.1/repos可以访问所有版本库列表了
  
  7. 修改httpd.conf配置以便能通过根目录(http://127.0.0.1/)访问版本库 
  
   DAV svn
   SVNParentPath C:/repos
   SVNListParentPath on
  
  
  
   #注意此区块不包含DAV svn SVNParentPath ..等配置
   AuthType Basic
   AuthName "Subversion Server"
   AuthUserFile "C:\repos\conf\htpasswd"
  AuthzSVNAccessFile "C:\repos\conf\authz"
   Require valid-user
  
  
  完!

  
页: [1]
查看完整版本: [SCM]源码管理