安装参考文档http://wiki.centos.org/HowTos/Subversion?highlight=%28subversion%29
一、环境
系统:centos6.4x64最小化安装
IP:192.168.3.73
二、安装
配置epel源
[[email protected] ~]# rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm Retrieving http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm warning: /var/tmp/rpm-tmp.soEIXi: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] [[email protected] ~]# sed -i ‘[email protected]#[email protected]@‘ /etc/yum.repos.d/epel.repo [[email protected] ~]# sed -i ‘[email protected]@#[email protected]‘ /etc/yum.repos.d/epel.repo
同步时间
[[email protected] ~]# yum install ntpdate -y [[email protected] ~]# ntpdate asia.pool.ntp.org 26 May 10:54:54 ntpdate[1490]: step time server 202.73.36.32 offset 142.398912 sec [[email protected] ~]# hwclock -w [[email protected] ~]# echo "*/10 * * * * /usr/sbin/ntpdate asia.pool.ntp.org &>/dev/null" >>/var/spool/cron/root
安装相关软件包
[[email protected] ~]# yum install httpd httpd-devel mod_dav_svn subversion mod_ssl -y #查看安装后的结果 [[email protected] ~]# ls /etc/httpd/modules/ |grep svn mod_authz_svn.so mod_dav_svn.so [[email protected] ~]# svn --version |grep version svn, version 1.6.11 (r934486)
到此svn的安装已完成
三、配置svn服务器
创建一个用来存储svn文件
[[email protected] ~]# mkdir -p /data/svn #新建一个版本库 [[email protected] /]# svnadmin create /data/svn [[email protected] data]# cd /data/svn/ [[[email protected] svn]# ls /svn/ conf db format hooks locks README.txt [[email protected] svn]# chown -R apache.apache /data/svn
配置subversion.conf
[[email protected] svn]# egrep -v "^#|^$" /etc/httpd/conf.d/subversion.conf LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location /svn-test> DAV svn SVNPath /data/svn SVNListParentPath on AuthType Basic AuthName "svn server" AuthUserFile /data/passwdfile AuthzSVNAccessFile /data/accessfile Require valid-user </Location>
添加用户名和密码
[[email protected] ~]# htpasswd -c /data/passwdfile weyee #这里的-c选项是清楚所有 New password: Re-type new password: #密码weyee2014 Adding password for user weyee [[email protected] ~]# htpasswd /data/passwdfile ceshi #添加另外的svn用户,密码weyee2014 New password: Re-type new password: Adding password for user test [[email protected] ~]# cat /svn/passwdfile weyee:uKp4.Z6yOTdac test:ZDfPcwIOd1Gp2 #启动httpd服务 [[email protected] ~]# /etc/init.d/httpd start Starting httpd: httpd: apr_sockaddr_info_get() failed for svn httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName [ OK ] [[email protected] ~]# netstat -anpt |grep httpd tcp 0 0 :::80 :::* LISTEN 23162/httpd tcp 0 0 :::443 :::* LISTEN 23162/httpd
四、创建权限控制文件
[[email protected] svn]# pwd /data/svn [[email protected] svn]# ll total 28 drwxr-xr-x 2 apache apache 4096 May 26 13:46 conf drwxr-sr-x 6 apache apache 4096 May 26 13:46 db -r--r--r-- 1 apache apache 2 May 26 13:46 format drwxr-xr-x 2 apache apache 4096 May 26 13:46 hooks drwxr-xr-x 2 apache apache 4096 May 26 13:46 locks -rw-r--r-- 1 root root 40 May 26 13:50 passwdfile -rw-r--r-- 1 apache apache 229 May 26 13:46 README.txt [[email protected] svn]# cat accessfile [/] *=rw [groups] dev=weyee test=ceshi [svn-test:/] @test=r @dev=rw [repos:/test] @test=rw *=
启动svn服务器
[[email protected] svn]# svnserve -d -r /data [[email protected] svn]# netstat -anpt |grep svn tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 23337/svnserve [[email protected] svn]# ps aux|grep svn |grep -v grep root 23337 0.0 0.0 156908 748 ? Ss 11:37 0:00 svnserve -d -r /data
测试结果,使用weyee用户
创建一个文件6.txt,并上传
我们将weyee用户对svn-test的写权限去掉
[[email protected] data]# cat accessfile [/] *=r [groups] dev=weyee test=ceshi [svn-test:/] @test=r @dev=r
重新创建一个7.txt,并提交
恢复写权限,继续提交
[[email protected] data]# cat accessfile [/] *=r [groups] dev=weyee test=ceshi [svn-test:/] @test=r @dev=rw
怎么创建其他的代码库呢?
[email protected] ~]# cd /tmp [[email protected] tmp]# mkdir mytestproj [[email protected] tmp]# cd mytestproj [[email protected] mytestproj]# mkdir configurations options main [[email protected] mytestproj]# vim configurations/testconf1.cfg [[email protected] mytestproj]# vim options/testopts1.cfg [[email protected] mytestproj]# vim main/mainfile1.cfg [[email protected] mytestproj]# svn import /tmp/mytestproj/ file:///data/svn/mytestproj -m "initial repos in mytestproj" Adding /tmp/mytestproj/main Adding /tmp/mytestproj/main/mainfile1.cfg Adding /tmp/mytestproj/configurations Adding /tmp/mytestproj/configurations/testconf1.cfg Adding /tmp/mytestproj/options Adding /tmp/mytestproj/options/testopts1.cfg Committed revision 9. #检出刚才创建的代码库 [[email protected] ~]# svn co http://192.168.3.73/svn-test/mytestproj Authentication realm: <http://192.168.3.73:80> svn server Password for ‘root‘: Authentication realm: <http://192.168.3.73:80> svn server Username: weyee Password for ‘weyee‘: ----------------------------------------------------------------------- ATTENTION! Your password for authentication realm: <http://192.168.3.73:80> svn server can only be stored to disk unencrypted! You are advised to configure your system so that Subversion can store passwords encrypted, if possible. See the documentation for details. You can avoid future appearances of this warning by setting the value of the ‘store-plaintext-passwords‘ option to either ‘yes‘ or ‘no‘ in ‘/root/.subversion/servers‘. ----------------------------------------------------------------------- Store password unencrypted (yes/no)? yes A mytestproj/main A mytestproj/main/mainfile1.cfg A mytestproj/configurations A mytestproj/configurations/testconf1.cfg A mytestproj/options A mytestproj/options/testopts1.cfg Checked out revision 9.
权限控制
[[email protected] data]# pwd /data [[email protected] data]# cat accessfile [/] *=r [groups] dev=weyee test=ceshi [svn-test:/] @test=r @dev=r [svn-test:/mytestproj] @dev=r @test=rw
从权限上看,应该是weyee对mytestproj只有读取权限,ceshi有读写权限
测试,新建一个qq.txt使用weyee账号提交
现在我们更换用户提交使用ceshi
到此基于httpd的svn基本是完成了
更多的请参考http://kaibinyuan.blog.51cto.com/7304008/1609488
时间: 2024-10-26 03:17:29