公司需要一个svn,我最近研究了一下svn,下面是我的笔记,分享给大家,如果有不对的地方,请指点!
我搭建的是基于Apache Http Server的svn,我的系统发行版本是redhat 5.4.
- 1、安装apache与svn,还有svn需要的模块mod_dav_svn
- yum install httpd httpd-devel subversion mod_dav_svn
- 2、查看svn的mod_dav_svn模块是否安装
- [root@nginx-backup ~]# cd /etc/httpd/modules/
- [root@nginx-backup modules]# ll |grep svn
- -rwxr-xr-x 1 root root 12704 2011-06-09 mod_authz_svn.so
- -rwxr-xr-x 1 root root 146928 2011-06-09 mod_dav_svn.so
- 3、查看svn是否安装成功
- [root@nginx-backup modules]# svn --version
- svn, version 1.6.11 (r934486)
- compiled Jun 8 2011, 16:22:13
-
- Copyright (C) 2000-2009 CollabNet.
- Subversion is open source software, see http://subversion.tigris.org/
- This product includes software developed by CollabNet (http://www.Collab.Net/).
-
- The following repository access (RA) modules are available:
-
- * ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- - handles ''http'' scheme
- - handles ''https'' scheme
- * ra_svn : Module for accessing a repository using the svn network protocol.
- - with Cyrus SASL authentication
- - handles ''svn'' scheme
- * ra_local : Module for accessing a repository on local disk.
- - handles ''file'' scheme
- 如果出现这些内容就代表你的svn安装成功
- 4、创建仓库,以及仓库目录的设置
- [root@nginx-backup modules]# mkdir -p /svndata
- [root@nginx-backup modules]# cd /svndata/
- [root@nginx-backup svndata]# svnadmin create ctitc ##创建仓库,仓库名字为ctitc
- [root@nginx-backup svndata]# chown -R apache:apache ctitc ##更改仓库ctitc的用户为apache,这个apache与apache里的httpd.conf里的用户应该一致
- [root@nginx-backup svndata]#vim /etc/httpd/conf.d/subversion.conf ##在面添加一下内容
- <Location /svn>
- DAV svn
- #SVNParentPath /svndata/ctitc/
- #
- # # Limit write permission to list of valid users.
- # <LimitExcept GET PROPFIND OPTIONS REPORT>
- # # Require SSL connection for password protection.
- # # SSLRequireSSL
- #
- SVNListParentPath on
- #SVNParentPath "/svndata/ctitc/test" ##svn打开时的目录,如果你是多个仓库用SVNParentPath,只有1个的话使用SVNPath
- SVNPath "/svndata/ctitc"
- AuthType Basic
- AuthName "Subversion repository"
- AuthUserFile "/svndata/ctitc/conf/authfile"
- Require valid-user
- SVNAutoversioning on
- ModMimeUsePathInfo on
- # </LimitExcept>
- </Location>
- 5、添加用户
- [root@nginx-backup svndata]# htpasswd -c /svndata/ctitc/conf/authfile test ##建立访问的用户test
- 如果想要添加多个用户可以使用
- [root@nginx-backup svndata]# htpasswd /svndata/ctitc/conf/authfile test
- 6、配置权限
- [root@nginx-backup svndata]# vim /svndata/ctitc/conf/authz
- [groups]
- admin = test ##用户组为admin,里面的用户为test
- [admin:/]
- @admin = rw ##admin组具有读写权限
- [/]
- * = r #其他用户具有读权限
- [ctitc:/] ##ctitc仓库根目录下的访问权限
- test = rw ##用户test具有读写权限
- 7、svn的import导入
- [root@nginx-backup svndata]# svn import /svndata/ctitc/ file:///svndata/ctitc -m "Initial repository"
- 8、配置svn服务端
- [root@nginx-backup svndata]# vim /svndata/ctitc/conf/svnserve.conf
- 内容修改为:
- [general]
- anon-access = none
- auth-access = write
- password-db = /svndata/ctitc/conf/passwd
- authz-db = /svndata/ctitc/conf/authz
- realm = ctitc
- 注意,把这几项的#去掉的时候,一定要这些空格都删除,否则会出现错误.
- 9、修改passwd
- [root@nginx-backup svndata]# vim /svndata/ctitc/conf/passwd
-
- [users]
- # harry = harryssecret
- # sally = sallyssecret
- test= test ##我设置的用户与密码均为test
- 现在svn的服务都配置完成了,需要重启启动apache与svnserve
- [root@nginx-backup svndata]# service httpd restart
- [root@nginx-backup svndata]# svnserve -d -r /svndata/ctitc/
- 然后查看apache与svnserve是否启动
- [root@nginx-backup svndata]# ps -ef|grep httpd
- root 4902 1 0 Dec27 ? 00:00:00 /usr/sbin/httpd
- apache 4904 4902 0 Dec27 ? 00:00:10 /usr/sbin/httpd
- apache 4905 4902 0 Dec27 ? 00:00:17 /usr/sbin/httpd
- apache 4906 4902 0 Dec27 ? 00:00:08 /usr/sbin/httpd
- apache 4907 4902 0 Dec27 ? 00:01:28 /usr/sbin/httpd
- apache 4908 4902 0 Dec27 ? 00:00:15 /usr/sbin/httpd
- apache 4909 4902 0 Dec27 ? 00:00:19 /usr/sbin/httpd
- apache 4910 4902 0 Dec27 ? 00:00:10 /usr/sbin/httpd
- apache 4911 4902 0 Dec27 ? 00:00:04 /usr/sbin/httpd
- apache 5142 4902 0 Dec27 ? 00:00:15 /usr/sbin/httpd
- apache 21541 4902 0 12:02 ? 00:00:02 /usr/sbin/httpd
- root 24116 23659 0 14:42 pts/2 00:00:00 grep httpd
- [root@nginx-backup svndata]# ps -ef|grep svnserve
- root 4915 1 0 Dec27 ? 00:00:00 svnserve -d -r /svndata/ctitc/
- root 24118 23659 0 14:42 pts/2 00:00:00 grep svnserve
|