下载:http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=260&expandFolder=74
http://subversion.tigris.org/downloads/subversion-1.5.2.tar.bz2
如果需要处理http://方案,请下载deps包,解压后,会自动解压到subversion目录
最新版本为:1.5.2
- tar -jxvf subversion-1.5.2.tar.bz2
- cd subversion-1.5.2
- sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2 --with-ssl --with-zlib=/usr/local/zlib --enable-maintainer-mode
- sudo make && sudo make install
注:第二次我编译1.5.3的版本时,出现下列错误configure: error: could not find library containing RSA_new
重新加了参数如下,原因是当初编译ssl的时候都是指定目录安装的,所以以后要编译什么东西都要指定目录了,不然会在默认的安装地方找不到。固以后大家安装一些基本点的库时,最好按照默认目录来安装,免得找不到。不过指定了目录,也会让自己更清楚安装的目录路径,孰好孰坏呢?
- sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2 --with-ssl --with-zlib=/usr/local/zlib --with-openssl=/usr/local/ssl --with-libs=/usr/local/ssl --enable-maintainer-mode/
- sudo make && sudo make install
- svn --version
- 可使用以下的版本库访问模块:
- * ra_neon : 通过 WebDAV 协议使用 neon 访问版本库的模块。
- - 处理“http”方案
- - 处理“https”方案
- * ra_svn : 使用 svn 网络协议访问版本库的模块。
- - 处理“svn”方案
- * ra_local : 访问本地磁盘的版本库模块。
- - 处理“file”方案
- * ra_serf : 通过 WebDAV 协议使用 serf 访问版本库的模块。
- - 处理“http”方案
- - 处理“https”方案
- sudo groupadd svn
- sudo useradd svnroot -g svn
- sudo passwd svnroot
注意上面如果想要在home下出现svnroot的目录,请在useradd svnroot 后加上-m参数.如果启用svnroot账户时不能自动补全等,把sh的标准改为bash,代码如下
- sudo vi /etc/passwd
- svnroot:x:1002:1002::/home/svnroot:/bin/sh===>/bin/bash
configure后显示
- You don't seem to have Berkeley DB version 4.0.14 or newer
- installed and linked to APR-UTIL. We have created Makefiles which
- will build without the Berkeley DB back-end; your repositories will
- use FSFS as the default back-end. You can find the latest version of
- Berkeley DB here:
- http://www.oracle.com/technology/software/products/berkeley-db/index.html
- /us r/bin/ld: cannot find -lexpat
- collect2: ld returned 1 exit status
- make: *** [subversion/svn/svn] Error 1
编译完后一般会自动在apache配置文件httpd.conf中添加
- LoadModule dav_svn_module modules/mod_dav_svn.so
- LoadModule authz_svn_module modules/mod_authz_svn.so
- #下面添加
- <Location /svn>
- DAV svn
- SVNParentPath /home/svnroot/repository/ //svn父目录
- AuthzSVNAccessFile /home/svnroot/repository/authz.conf //权限配置文件
- AuthType Basic //连接类型设置
- AuthName "Subversion.zoneyump" //连接框提示
- AuthUserFile /home/svnroot/repository/authfile //用户配置文件
- Require valid-user //采用何种认证
- </Location>
到这里,我们就明白了得重新编译apache,在原有的基础上加上如下参数
- --enable-dav --enable-dav-fs --enable-dav-lock
- make && sudo make install
- httpd: Syntax error on line 54 of /home/apache/conf/httpd.conf: Cannot load /home/apache/modules/mod_dav_svn.so into server: /home/apache/modules/mod_dav_svn.so: undefined symbol: dav_register_provider
创建库文件所在的目录 (svnroot用户进行下面的操作)
- mkdir /home/svnroot/repository
- /usr/local/subversion/bin/svnadmin create /home/svnroot/repository/test
- /usr/local/subversion/bin/svnadmin --version
- chmod 700 /home/svnroot/repository
6. 权限管理
1)增加用户
# htpasswd -c /home/svnroot/repository/authfile 用户名
//第一次设置用户时使用-c表示新建一个用户文件。回车后输入用户密码,完成对用户的增加
# htpasswd /home/svnroot/repository/authfile 用户名(加入新的用户,就不用-c了) 2)权限分配
注意这里执行htpasswd时可能会出错如下:
- The program 'htpasswd' can be found in the following packages:
- * mini-httpd
- * apache2-utils
- Ask your administrator to install one of them
- bash: htpasswd: command not found
原因是编译apache时未加载htpasswd模块,不好意思,又得重新编译apache了,这里由于是一步一步实验,有点乱,本文结束时会重新修改.查看configure如下:
- --enable-static-htpasswd
- Build a statically linked version of htpasswd
# vi /home/svnroot/repository/authz.conf
[groups]
admin=useradmin
devteamcs = useradmin,user1,user2//这里定义了一个用户组
[/]//对所有的项目,所有的用户都有读权限,admin用户有读写权限
@admin = rw
* = r
[test:/]//对test项目,
@devteamcs = rw
// 在 /usr/local/apache2/conf/httpd.conf 文件中配置,找到文件中的这两行:
User daemon
Group daemon
// 将daemon改为svnroot,组也做相应更改,让apache进程以svnroot的身份运行
//改完后是这个样子
User svnroot
Group svn
ddddd
导入库:
- sudo ./svn import -m 'new import' /home/htdocs/test/ http://localhost/svn/test/ --username 用户名 --password 密码
- 认证领域: <http://localhost:80> Subversion.zoneyump
用户名: svnroot
“svnroot”的密码:
mark here
参考:http://svnbook.red-bean.com/en/1.0/re12.html
http://svnbook.red-bean.com/en/1.0/index.html