准备工作:

安装好apache Web 服务器

安装svn

先下载:

subversion-1.6.1.tar.gz subversion-deps-1.6.1.tar.gz

解压:

tar -zxvf subversion-1.6.1.tar.gz

tar -zxvf subversion-deps-1.6.1.tar.gz

./configure --prefix=/usr/local/svn/

make && make install


添加svn命令到环境变量

echo "export PATH=$PATH:/usr/local/svn/bin/" >> /etc/profile

source /etc/profile



1.建立svn版本库目录

mkdir -pv /home/svnroot/data

chown -Rv apache /home/svnroot/data

chmod -Rv 755 /home/svnroot/data


2.建立svn版本库

/usr/local/subversion/bin/svnadmin create --fs-type fsfs /home/svnroot/data/project1


3.建立访问控制文件

/usr/local/apache/bin/htpasswd -c /home/svnroot/data/passwd  user1  #第一次加用户名添加-c参数

/usr/local/apache/bin/htpasswd  /home/svnroot/data/passwd  user2


4.建立本地项目控制文件

cd /home/svnroot/data

vi authz

[groups]        

admin=user1

develop=user2,user3

[project1:/]

@admin = rw

@develop = r


cat /usr/local/apache2/conf/httpd.conf | grep svn


显示

LoadModule dav_svn_module     modules/mod_dav_svn.so

LoadModule authz_svn_module   modules/mod_authz_svn.so

就表明安装成功。


vi /usr/local/apache/conf/httpd.conf


添加

<Location /svn>

   DAV svn

   SVNParentPath /home/svnroot/data

   AuthType Basic

   AuthName "Subversion"

   AuthUserFile /home/svnroot/data/passwd

   AuthzSVNAccessFile /home/svnroot/data/authz

   Require valid-user

</Location>


5.启动apache

/usr/local/apache2/bin/apachectl start


如果启动的时候出现:

httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf:

     Cannot load /usr/local/apache2/modules/mod_dav_svn.so into server:

     /usr/local/apache2/modules/mod_dav_svn.so:

     undefined symbol: dav_register_provider


解决办法:

重新对apache做./configure 增加参数

./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd --with-include-apr --with-pcre --enable-maintainer-mode --enable-dav --enable-modes-shared=most --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support

make && make install


再次启动apache如果出现警告:

httpd: apr_sockaddr_info_get() failed for linux(在BSD上是apr_sockaddr_info_get() failed for freebsdla)

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

解决办法:

修改apache配置文件httpd.conf 添加ServerName为本机用户名


再次启动/usr/local/apache2/bin/apachectl start

成功!


访问测试:http://ip/svn/project1


完成。。。。