http协议的svn服务器搭建(apache+subversion)
1、1> 首先下载apache安装包,然后解压编译安装httpd # tar xvzf httpd-2.2.6.tar.gz # cd httpd-2.2.6 # ./configure --enable-dav --enable-so --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --prefix=/usr/local/apache2 # make # make install (或者合并为一步#make && make install)2> 编辑配置文件httpd.conf # vi /usr/local/apache2/conf/httpd.conf 修改内容: ServerName www.example.com:80 为 ServerName localhost:80或者Apache服务器的IP3> 安装完成并修改后,启动apache进程:/usr/local/apache2/bin/apachectl start(或者在/usr/local/apache2/bin/下,用./httpd –k start),然后打开浏览器http://localhost/,如果有测试页"It works!"出现,则证明已经安装成功。
2、下载subversion字斤谯噌最新版本1> 解压subversion安装包,进入到目录,执行以下编译./configure --w足毂忍珩ith-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 --enable-maintainer-mode2> 创建svn基本操作 创建管理svn的用户svnroot #useradd svnroot #su svnroot 创建库文件所在的目录 (要svnroot用户进行下面的操作) # mkdir /home/svnroot/repository 进入subversion的bin目录 # cd /usr/local/subversion/bin 创建"test"仓库 # ./svnadmin create /home/svnroot/repository/test 进入到数据仓库"test"目录 # cd /home/svnroot/repository/test 看看是不是多了些文件,如果是则说明Subversion安装成功了 # ls –l 不让其他人有该目录的权限 # chmod 700 /home/svnroot/repository **注意,直接这么chmod会导致svn客户端无法访问,需要修改apache配置文件httpd.conf文件: User daemon //将daemon改为svnroot,让apache进程以svnroot的身份运行 Group daemon 把上述内容改成: User svnroot Group svnroot 如果apache以daemon方式运行则所有用户对资源库只有r的权限 如果不新建管理svn的用用户svnroot,而让apache以root身份运行,则系统会报错3 > 下面的操作是可选的 修改svn仓库的所有者 # chown -R svnroot: svnroot /home/svnroot/repository 修改该目录权限只能svnroot拥有 # chmod 700 /home/svnroot/repository4> 修改Apache配置文件 # cd /usr/local/apadche2/bin # ./apachect1 stop //停止Apache进程 vi /usr/local/apache2/conf/httpd.conf 在最下面添加 ,如果你的里面没有这两个模块的话 LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so Location指示的目的是告诉Apache在特定的URL以及子URL下需要特殊的处理,如果是为Subversion准备的, 你希望可以通过告诉Apache特定URL是指向版本化的资源,从而把支持转交给DAV层,你可以告诉 Apache将所有路径部分(URL中服务器名称和端口之后的部分)以/svn/开头的URL交由DAV服务提供者处理<Location /svn> DAV svn SVNParentPath /home/svnroot/repository/ # our access control policy权限配置文件 AuthzSVNAccessFile /home/svnroot/repository/authz.conf # only authenticated users may access the repository Require valid-user # how to authenticate a user AuthType Basic AuthName "Subversion repository created by tongyi" #用户配置文件 AuthUserFile /home/svnroot/repository/authfile</Location> #htpasswd [–c] /home/svnroot/repository/authfile test//用户名 #test//密码 //其中authfile是通过"htpasswd [–c] /home/svnroot/repository/authfile username password"来创建 //"Require valid-user"告诉apache在authfile中所有的用户都可以访问。如果没有它,则只能第一个用户可以访问新建库 #vi /home/svnroot/repository/authz.conf //先创建一个文件,具体配置后面在说明 //启动apache服务 # /usr/local/apache2/bin/apachectl start //打开浏览器访问 http://localhost/svn/test/,如果有东西显示就说明成功。5> 权限管理(即authz.conf的配置) 1)增加用户 # htpasswd [-c] /home/svnroot/repository/authfile user1 第一次设置用户时使用-c表示新建一个用户文件。回车后输入用户密码,完成对用户的增加,此时是要用root的权限来添加的,添加完后在authfile中看到用户和加密的密码。 # htpasswd /home/svnroot/repository/authfile 用户名(加入新的用户) 如:"htpasswd /home/svnroot/repository/authfile user2" 2)权限分配 # vi /home/svnroot/repository/authz.conf //编辑添加下面内容 #群组设置 [groups] Tester = test,user1 //这个表示某群组里的成员 #anonymous = guest [test:/] //这表示,仓库test的根目录下的访问权限 @Tester = rw //test仓库Tseter组中用户具有读和写权限 * = r //test仓库中所有用户具有读的权限 注意:在编辑authz.conf文件时,所有行都必须要顶头写,不能有缩行出现,否则会报错:"Access denied: 'user1' "。 拷贝配置,别忘了把注释去掉,redhat可不认你里面//后面的东西哦