CentOS5.3×86_64编译安装配置subversion服务器

January 8, 2010 – 11:21 pm

测试环境:centos5.3 x86_64

1.安装apache

从http://httpd.apache.org下载源代码编译安装apache。
apache2.2以上版本安装思路是首先安装好apr和apr-util(这两个包在apache的源代码目录中,装好了也方便以后再有源代码编译安装时调用),然后再安装apache,如果原来机器上编译安装过apache,必须保证生成makefile时加入了–enable-dav –enable-so –enable-maintainer-mode参数,否则需要重新安装。

  1. tar zxvf httpd-2.2.14.tar.gz
  2. cd httpd-2.2.14
  3. cd srclib/apr
  4. ./configure --prefix=/usr/local/apr
  5. make
  6. make install
  7. cd ..
  8. cd apr-util
  9. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  10. make
  11. make install
  12. cd ../..
  13. ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --sysconfdir=/etc --enable-ssl --enable-modules --enable-rewrite --enable-dav --enable-so --enable-maintainer-mode
  14. make
  15. make install

启动apache:/usr/local/apache2/bin/apachectl start

2.安装subversion

从http://subversion.tigris.org/下载源代码编译安装,下载subversion-1.6.6.tar和subversion-deps-1.6.6.tar两个文件,然后解压缩后自动存到一个目录下

  1. tar xvf subversion-1.6.6.tar
  2. tar xvf subversion-deps-1.6.6.tar
  3. cd subversion-1.6.6
  4. ./configure --prefix=/usr/local/subversion --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --with-zlib=/usr/local/zlib --enable-maintainer-mode

执行完成后会提示:

  1. You don't seem to have Berkeley DB version 4.0.14 or newer
  2. installed and linked to APR-UTIL.  We have created Makefiles which
  3. will build without the Berkeley DB back-end; your repositories will
  4. use FSFS as the default back-end.  You can find the latest version of
  5. Berkeley DB here:
  6.   http://www.oracle.com/technology/software/products/berkeley-db/index.html

经过在网上搜索资料,我们不使用berkeley DB,用FSFS更与时俱进。所以我们继续make,make后会出现/usr/bin/ld: cannot find -lexpat错误提示,解决方法:yum install expat expat-devel,然后继续make和make install
完成后检查一下

  1. /usr/local/subversion/bin/svnserve --version

结果为

  1. svnserve, version 1.6.6 (r40053)
  2.    compiled Jan  6 2010, 16:57:10
  3.  
  4. Copyright (C) 2000-2009 CollabNet.
  5. Subversion is open source software, see http://subversion.tigris.org/
  6. This product includes software developed by CollabNet (http://www.Collab.Net/).
  7.  
  8. The following repository back-end (FS) modules are available:
  9.  
  10. * fs_fs : Module for working with a plain file (FSFS) repository

3.配置svn服务器

首先添加svn用户和用户组:useradd svnroot
并给svnroot添加密码:passwd svnroot
我们切换到svnroot用户,以此用户身份创建我们第一个版本库

  1. su svnroot
  2. /usr/local/subversion/bin/svnadmin create /home/svnroot/mysvn/test

进去看看是不是多了很多文件

  1. cd /home/svnroot/mysvn/test
  2. ls -al

现在我们切换回root帐户,增加配置文件并修改apache配置文件。
首先我们来生成访问svn服务器的用户名和密码配置文件,调用apahce的htpasswd来完成。

  1. /usr/local/apache2/bin/htpasswd -c /home/svnroot/mysvn/userlist hluan

后面继续输入密码即可。
我们继续生成用户访问svn服务器的权限配置文件

  1. cd /home/svnroot/mysvn
  2. vi auth.conf

加入:

  1. #用户组,组名对应后面的用户名,用户名之间用逗号隔开
  2. [groups]
  3. svnusers = hluan
  4. #对目录的访问权限,以下代码表示,对test目录下svnusers组所有成员均有读写权限
  5. [test:/]
  6. @svnusers = rw
  7. #对根目录下所有用户均有读权限
  8. [/]
  9. * = r

最后编辑apache配置文件,打开/etc/httpd.conf
修改apache启动用户为:

  1. User svnroot
  2. Group svnroot

检查是否有

  1. LoadModule dav_svn_module     modules/mod_dav_svn.so
  2. LoadModule authz_svn_module   modules/mod_authz_svn.so

这两行代码
在文件后面加入:

  1. <Location /mysvn>
  2.   DAV svn
  3.   #svn服务器版本库根目录
  4.   SVNParentPath /home/svnroot/mysvn
  5.   #用户访问版本库权限配置
  6.   AuthzSVNAccessFile /home/svnroot/mysvn/auth.conf
  7.   #连接类型
  8.   AuthType Basic
  9.   #提示对话框标题
  10.   AuthName "welcome to hluan's svn server"
  11.   #用户表
  12.   AuthUserFile /home/svnroot/mysvn/userlist
  13.   #使apache读取userlist中的用户
  14.   Require valid-user
  15. </Location>

配置完毕,重新启动apache,可以进行测试了。

4.测试svn服务器

打开网页浏览器,在地址栏输入:http://192.168.70.74/mysvn/test/(192.168.70.74为svn服务器ip),提示输入用户名和密码访问,输入完成后确认成功提示为:test - Revision 0: /。
我们使用svn客户端实验一下,在终端输入:svn checkout http://192.168.70.74/mysvn/test,即可继续使用svn服务器。

Post a Comment