最简单的SVN (subversion)的配置
for centos
by 花中神仙
系统:- Centos 5.0
- Subversion 1.4.2
Subversion: http://subversion.tigris.org/
·
Version Control with Subversion: http://svnbook.red-bean.com/
安装包和依赖包:
- Subversion: RPM subversion-1.1.4-2.ent
- Apache module: RPM mod_dav_svn-1.1.4-2.ent
就用yum install
package(包名)安装就行,哈
这个很简单。
[root@lucifer ~]# yum install mod_dav_svn subversion Dependencies Resolved ============================================================================= Package
Arch
Version
Repository
Size ============================================================================= Installing: mod_dav_svn
i386
1.1.4-2.ent
base
50 k subversion
i386
1.1.4-2.ent
base
1.6 M Installing for dependencies: apr
i386
0.9.4-24.5.c4.1
base
88 k apr-util
i386
0.9.4-21
base
51 k guile
i386
5:1.6.4-14
base
746 k httpd
i386
2.0.52-22.ent.centos4
base
887 k httpd-suexec
i386
2.0.52-22.ent.centos4
base
28 k neon
i386
0.24.7-4
base
86 k perl-URI
noarch
1.30-4
base
79 k swig
i386
1.3.21-6
base
1.0 M umb-scheme
i386
3.2-35
base
967 k Transaction Summary ============================================================================= Install
11 Package(s) Update
0 Package(s) Remove
0 Package(s) Total download size: 5.5 M Is this ok [y/N]:
2) 配置: a) Apache: 这里的不用配,默认就行:
[root@lucifer ~] vim /etc/httpd/conf/httpd.conf (按你的需要配,可以不用配) [root@lucifer ~] service httpd start [root@lucifer ~] chkconfig httpd on
http://IP
地址。http://域名
可以访问了。
b) SVN在apache中的配置: [root@lucifer ~] cd /etc/httpd/conf.d/ [root@lucifer ~] vim subversion.conf # Make sure you uncomment the following if they are commented out LoadModule dav_svn_module
modules/mod_dav_svn.so LoadModule authz_svn_module
modules/mod_authz_svn.so # Add the following to allow a basic authentication and point Apache to where the actual # repository resides. <Location /repos>
DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /etc/svn-auth-conf
Require valid-user </Location>
可以直接修改成一样的就行。
http://ip/repos
这样你可以看到了。
下面是建立用户:第一个和第二个命令不一样,是因为第一个要创建新文件。两个命令不要输反了,哈。如果你最后一次输入第一个命令,不好意思,再重新一个一个的输吧,在为这样你的文件里只有一个用户名,就是你最后一次输的那一个,哈~~~。对了这里密码用的是MD5。
[root@lucifer ~] htpasswd -cm /etc/svn-auth-conf yourusername New password: Re-type new password: Adding password for user yourusername [root@lucifer ~] htpasswd -m /etc/svn-auth-conf anotherusername New password: Re-type new password: Adding password for user anotherusername [root@lucifer ~] service httpd restart
c)关于目录的配置:
[root@lucifer ~] cd /var/www/ -- Or wherever you placed your path above [root@lucifer ~] mkdir svn [root@lucifer ~] cd svn [root@lucifer ~] svnadmin create repos [root@lucifer ~] chown -R apache.apache repos [root@lucifer ~] service httpd restart
这样就建立了主目录库。
3)使用SVN: a) 结构: 建立新的工程的时候最好是下面的结构,哈
. |-- project1 |
|-- branches |
|-- tags |
`-- trunk `-- project2
|-- branches
|-- tags
`-- trunk
[root@lucifer ~] cd /tmp [root@lucifer ~] mkdir mytestproj [root@lucifer ~] cd mytestproj [root@lucifer ~] mkdir branches tags trunk [root@lucifer ~] vim branches/test.cfg -- Add whatever you want to these files.
b) import: [root@lucifer ~] svn import /tmp/mytestproj/ file:///var/www/svn/repos/mytestproj -m "Initial repository layout for mytestproj" Adding
/tmp/mytestproj/branches Adding
/tmp/mytestproj/branches/test.cfg Adding
/tmp/mytestproj/tags Adding
/tmp/mytestproj/trunk
c) Checking out: http://yourmachine/repos . 你访问这个目录下面就把那个目前下载下来了。
[me@mylappy ~] cd /tmp [me@mylappy ~] svn co http://IP/repos/mytestproj Authentication realm: <http://yoursvnserver:80> Subversion repos Password for 'youruser': A
mytestproj/branches A
mytestproj/branches/test.cfg A
mytestproj/tags A
mytestproj/trunk Checked out revision 1.
d) Edit and commit: 当你修改后,再上传。这样版本号变了。
[me@mylappy ~] cd mytestproj [me@mylappy ~] vim branches/test.cfg -- Add or delete something and save. [me@mylappy ~] svn commit -m "Added a line to test.cfg." Sending
branches/test.cfg Transmitting file data . Committed revision 2.
e) Adding/deleting items: 增加和删除时。
[me@mylappy ~] svn co http://yoursvnserver/repos/mytestproj A
mytestproj/branches A
mytestproj/branches/test.cfg A
mytestproj/tags A
mytestproj/trunk Checked out revision 2. [me@mylappy ~] cd mytestproj [me@mylappy ~] cp /etc/yum.repos.d/CentOS-Base.repo branches/ [me@mylappy ~] svn add branches/CentOS-Base.repo A
configurations/CentOS-Base.repo [me@mylappy ~] svn commit -m "Added the CentOS Yum repo file." Adding
configurations/CentOS-Base.repo Transmitting file data . Committed revision 3.
f) Reverting back: 当恢复备份时。
[me@mylappy ~] svn log http://ip/repo -- For the entire repository [me@mylappy ~] svn log http://IP/repo/mytestproj -- For the specific project
我这样查看可以看到现在的版本列表。都是那些改动了。
[me@mylappy ~] svn co -r 1 http://IP/repo/mytestproj
![](http://bbs.linuxpk.com/images/attachicons/rar.gif)
这时我们在这里选择了版本号为1的历史版本。