重新安装了一下最新版本的SVN,把操作过程记录下来。
1、准备材料
[root@test]# pwd
/usr/local
[root@test]# ll
-rw-r–r– 1 root root 6028951 Sep 6 19:31 httpd-2.2.6.tar.gz
-rw-r–r– 1 root root 3354792 Jan 15 15:11 openssl-0.9.8g.tar.gz
-rw-r–r– 1 root root 6337805 Dec 20 17:29 subversion-1.4.6.tar.gz
-rw-r–r– 1 root root 2899269 Dec 20 17:29 subversion-deps-1.4.6.tar.gz
这些东西可以到Apache、OpenSSH、Subversion的网站上去下载。
2、安装OpenSSH
[root@test]# pwd
/usr/local
[root@test]# tar zxvf openssl-0.9.8g.tar.gz
[root@test]# cd openssl-0.9.8g
[root@test]# ./config shared
[root@test]# make
[root@test]# make test
[root@test]# make install
[root@test]# echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
[root@test]# /sbin/ldconfig
openssl已经安装到/usr/local/ssl下面了
3、安装Apache
[root@test]# pwd
/usr/local
[root@test]# tar zxvf httpd-2.2.6.tar.gz
[root@test]# cd httpd-2.2.6
[root@test]# ./configure –enable-dav –enable-so –prefix=/usr/local/apache –with-ssl=/usr/local/ssl –enable-ssl
[root@test]# make
[root@test]# make install
安装Apache比较容易,安装完之后,验证一下也可以,就是启动一下Apache看看是否安装成功。一般这一步都不会出什么问题。
4、安装SVN
[root@test]# pwd
/usr/local
[root@test]# tar zxvf subversion-1.4.6.tar.gz
[root@test]# tar zxvf subversion-deps-1.4.6.tar.gz
[root@test]# cd subversion-1.4.6
[root@test]# ./configure –with-apxs=/usr/local/apache/bin/apxs
–prefix=/usr/local/subversion –with-apr=/usr/local/apache
–with-apr-util=/usr/local/apache –with-ssl –with-zlib
–without-berkeley-db –enable-maintainer-mode
[root@test]# make
[root@test]# make install
这里面的参数是有一些讲究的:
- –with-apr 和 –with-apr-util 一定要加上,不然会因为版本的问题导致编译失败,deps里面的apr和apr-util是0.9.17版本和0.9.15版本的,而Apache2需要1.x版本的,所以在这里要指定他们的路径。
- –without-berkeley-db 不使用BDB来存储数据,那么就只能使用FSFS了,具体的区别去Google查一下就可以了,而且使用FSFS备份起来非常容易。
接下来,验证一下svn是否安装成功:
[root@test]# pwd
/usr/local/subversion/bin
[root@test]# ./svnserve –version
svnserve, version 1.4.6 (r28521)
compiled Jan 15 2008, 13:41:55
Copyright (C) 2000-2007 CollabNet.
Subversion is open source software, see http://subversion.tigris.or
This product includes software developed by CollabNet (http://www.C
The following repository back-end (FS) modules are available:
* fs_fs : Module for working with a plain file (FSFS) repository.
5、创建SVN库
把所有的数据仓库都放在/var/svn/repositories下面,先创建一个数据仓库test,修改权限以使用Apache来访问,Apache是使用daemon.daemon来启动的。
[root@test]# mkdir /var/svn/repositories
[root@test]# ./svnadmin create /var/svn/repositories/test
[root@test]# chown daemon.daemon -R /var/svn/repositories
6、配置Apache、SSL以启动SVN服务
先生成https服务所需要的 server.key 和 server.crt:
[root@test]# openssl req -new -x509 -days 30
-keyout /usr/local/apache/conf/server.key
-out /usr/local/apache/conf/server.crt
-subj '/CN=www.SimpleLife.cn Certificate'
Generating a 1024 bit RSA private key
…………………….++++++
……………………………………….++++++
writing new private key to '/usr/local/apache/conf/server.key'
Enter PEM pass phrase:******
Verifying - Enter PEM pass phrase:******
注意记住密码,在启动httpd服务时会用到。
然后配置一下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 /var/svn/repositories
AuthzSVNAccessFile /var/svn/authz.conf
AuthType Basic
AuthName "simplelife.cn"
AuthUserFile /var/svn/authfile
Require valid-user
</Location>
Include conf/extra/httpd-ssl.conf
这里面有三个路径:
- SVNParentPath SVN仓库的上一级路径,所有的库都放在这个目录下。
- AuthzSVNAccessFile SVN的访问权限设置
- AuthUserFile 用户认证文件,也就是用户名和密码的配置文件
先创建一个用户:
[root@test]# pwd
/usr/local/apache/bin
[root@test]# ./htpasswd /var/svn/authfile javor
New password: ******
Re-type new password: ******
Adding password for user javor
为这个用户设置SVN权限:
[root@test]# pwd
/var/svn/
[root@test]# more authz.conf
[/]
javor=rw
7、启动服务
先启动https服务:期间要输入创建key时的密码:
[root@test]# pwd
/usr/local/apache/bin
[root@test]# ./httpd -k start -DSSL
Apache/2.2.6 mod_ssl/2.2.6 (Pass Phrase Dialog)
Some of your
private key files are encrypted
for security reasons.
In order to read them you have to provide the pass phrases.
Server www.simplelife.cn:443 (RSA)
Enter pass phrase:******
OK: Pass Phrase Dialog successful.
浏览器访问:https://www.simplelife.cn/svn/test,应该能看到svn库了
[root@test]# pwd
/usr/local/apache/bin
[root@test]# ./apachectl start
浏览器访问:http://www.simplelife.cn/svn/test
8、其他
- 要建多个库,在/var/svn/repositories下创建就可以了,通过更改URL后面的库名就可以访问
- 要备份库,直接将/var/svn/repositories下对应的文件夹打包就可以了,这就是使用fsfs的好处