首先安装Apache2.2.2
执行在Apache官方网站下载的apache_2.2.2-win32-x86-no_ssl.msi程序,安装过程很简单,其中有两点说明一下:
1. 笔者喜欢简洁的目录,凡事常用的软件,都之间安装在磁盘根目录下,例如C:/apache2.2,这样每次修改内容时进入目的文件夹也非常方便。笔者建议文件夹名称中不含有空格。
2. 安装Apache可以选择自定义端口,其中可以选择80或者8080,笔者的80端口被IIS占用了,所以选择8080,当然,您的端口可能已经被IIS、Tomcat之类的服务器占用了,没关系,可以修改APACHE_HOME/conf/httpd.conf进行自定义端口的修改,详细内容参见Apache官方文档。
其次,安装Subversion,笔者使用的版本为svn-win32-1.4.4.zip,解压缩即可直接使用,不需要安装,根据笔者的习惯,当然是放在C:/svn-win32-1.4.4下了。
进行Apache+Subversion的整合,整合步骤如下:(其中SVN_HOME指Subversion的安装目录,本文中为C:/svn-win32-1.4.4,APACHE_HOME指Apache Http服务器的安装位置,本文中为C:/apache2.2)
第一步,打开Apache安装目录下的httpd.conf文件
找到下面的语句:
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
将上面语句前面的#去掉
第二步,在这句后面追加,如下语句:
LoadModule dav_svn_module "SVN_HOME/bin/mod_dav_svn.so"
LoadModule authz_svn_module " SVN_HOME /bin/mod_authz_svn.so"
Note: 也可以把Subversion/bin/下的mod_dav_svn.so和mod_authz_svn.so复制到apache下的modules/,但是这样一来每次升级svn的时候就得复制一次了,因为是用绝对路径,所以要加双引号,否则apache会出错。
第三步,在这个文件的最后,追加如下语句:
<Location /svn>
DAV svn
SVNParentPath d:/svn
</Location>
Note:如果你的磁盘没有d盘符,就修改为c:/svn
第四步,创建仓库
根据apache的配置文件的设置建立目录:d:/svn,然后用svnadmin create d:/svn/test命令创建仓库,命令执行成功之后,会在d:/svn/test下面生成很多的文件和目录。
其中:
conf目录存放配置信息;
dav目录是提供给Apache与mod_dav_svn使用的目录,让它们存储内部数据;
db目录就是所有版本控制的数据文件;
hooks目录放置hook脚本文件的目录;
locks用来放置Subversion文件库锁定数据的目录, 用来追踪存取文件库的客户端;
format文件是一个文本文件,里面只放了一个整数,表示当前文件库配置的版本号;
第五步,运行
重新启动Apache Server
在浏览器中输入网址:
这时候,看到页面显示:
Revision 0: /
Powered by Subversion version 1.3.2 (r19776).
安装成功,接下来将进行权限设置。
三、svn权限设置
svn使用apache的权限管理对档案库及目录进行读写管理
修改上面第三步的内容为:
<Location /svn>
DAV svn
#SVNListParentPath on
SVNParentPath c:/svn
### apache auth begin
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile c:/password/apache_authz
Require valid-user
### apache auth end
### svn auth begin
# our access control policy
#AuthzSVNAccessFile c:/password/svn_authz
# authentication if necessary
#Satisfy Any
### svn auth end
</Location>
用htpasswd工具创建apache_authz 文件,
建立保存用户名和密码的文件
htpasswd -cm D:/Subversion/apache_authz username1
-c 表示创建文件,-m表示对密码用md5加密
然后,会提示输入两次密码,以后再加用户就不需要用-c了,直接用-m即可。
创建两个用户,用户名分别为zhangzhongl和zhangtao,密码与用户名相同。
下面建立控制用户访问权限的文件svn_authz
在D:/Subversion中新建一个记事本文件,输入下面的内容:
[groups]
test-developers = zxm
everyone = @test-developers
[test:/] //这表示,仓库test的根目录下的访问权限
@test-developers = rw
[test:/test] //test仓库下test目录的访问权限
@test-developers = rw // 如果在前面加上@符号,则表示这是个群组权限设置
r 表示读权限
w 表示写权限
(这部分内容笔者没有配置成功,如果添加svn_authz这个文件,就不能成功。)
好,配置完成,重新启动Apache server
在浏览器地址栏中再次输入:http://localhost/svn/test/
这次要输入密码才能进入,赶快试试吧。
本文主要参照网络中的文章,以及SVN中安装向导文件中的apache整合安装部分,原文如下:
A. Setting Up Apache
-----------------
(Following the BOOTSTRAPPING FROM RPM procedures above will install and
build the latest Subversion server for Linux RedHat 7.1, 7.2, and PPC
Linux systems *IF* the apache-devel-2.0.41 or greater package is already
installed when the SUBVERSION RPM is built.)
1. Obtaining and Installing Apache 2
Subversion tries to compile against the latest released version
of Apache httpd 2.X. The easiest thing for you to do is download
a source tarball of the latest release and unpack that.
****************************************************************
** IMPORTANT ISSUE ABOUT APACHE VERSIONS: READ THIS. **
** **
****************************************************************
| |
| First, be sure to read the APR version warning box, back in |
| section I.C.1, which explains that APR 0.9.x and 1.X are |
| binary-incompatible. |
| |
| Apache HTTPD 2.0 uses APR 0.9.x. |
| Apache HTTPD 2.2 uses APR 1.2.x. |
| |
| We recommend using the latest Apache. However, whatever |
| version you choose, you *must* ensure that Subversion |
| and Apache are using the same version of APR. If you don't, |
| things will segfault and break. |
|______________________________________________________________|
If you have questions about the Apache httpd 2.0 build, please consult
the httpd install documentation:
http://httpd.apache.org/docs-2.0/install.html
At the top of the httpd tree:
$ ./buildconf
$ ./configure --enable-dav --enable-so --enable-maintainer-mode
The first arg says to build mod_dav.
The second arg says to enable shared module support which is needed
for a typical compile of mod_dav_svn (see below).
The third arg says to include debugging information. If you
built Subversion with --enable-maintainer-mode, then you should
do the same for Apache; there can be problems if one was
compiled with debugging and the other without.
Note: if you have multiple db versions installed on your system,
Apache might link to a different one than Subversion, causing
failures when accessing the repository through Apache. To prevent
this from happening, you have to tell Apache which db version to
use and where to find db. Add --with-dbm=db4 and
--with-berkeley-db=/usr/local/BerkeleyDB.4.2 to the configure
line. Make sure this is the same db as the one Subversion uses.
This note assumes you have installed Berkeley DB 4.2.52
at its default locations. For more info about the db requirement,
see section I.5.
You may also want to include other modules in your build. Add
--enable-ssl to turn on SSL support, and --enable-deflate to turn on
compression support, for example. Consult the Apache documentation
for more details.
All instructions below assume you configured Apache to install
in its default location, /usr/local/apache2/; substitute
appropriately if you chose some other location.
Compile and install apache:
$ make && make install
B. Making and Installing the Subversion Apache Server Module
---------------------------------------------------------
Go back into your subversion working copy and run ./autogen.sh if
you need to. Then, assuming Apache httpd 2.0 is installed in the
standard location, run:
$ ./configure
Note: do *not* configure subversion with "--disable-shared"!
mod_dav_svn *must* be built as a shared library, and it will
look for other libsvn_*.so libraries on your system.
If you see a warning message that the build of mod_dav_svn is
being skipped, this may be because you have Apache httpd 2.X
installed in a non-standard location. You can use the
"--with-apxs=" option to locate the apxs script:
$ ./configure --with-apxs=/usr/local/apache2/bin/apxs
Note: it *is* possible to build mod_dav_svn as a static library
and link it directly into Apache. Possible, but painful. Stick
with the shared library for now; if you can't, then ask.
$ rm /usr/local/lib/libsvn*
If you have old subversion libraries sitting on your system,
libtool will link them instead of the `fresh' ones in your tree.
Remove them before building subversion.
$ make clean && make && make install
After the make install, the Subversion shared libraries are in
/usr/local/lib/. mod_dav_svn.so should be installed in
/usr/local/apache2/modules/.
Section II.E explains how to build the server on Windows.
C. Configuring Apache for Subversion
---------------------------------
The following section is an abbreviated version of the
information in the Subversion Book
(http://svnbook.red-bean.com). Please read chapter 6 for more
details.
The following assumes you have already created a repository.
For documentation on how to do that, see README.
The following also assumes that you have modified
/usr/local/apache2/conf/httpd.conf to reflect your setup.
At a minimum you should look at the User, Group and ServerName
directives. Full details on setting up apache can be found at:
http://httpd.apache.org/docs-2.0/
First, your httpd.conf needs to load the mod_dav_svn module.
Subversion's 'make install' target should automatically add this
line for you. But if apache gives you an error like "Unknown
DAV provider: svn", then you may want to verify that this line
exists in your httpd.conf:
LoadModule dav_svn_module modules/mod_dav_svn.so
NOTE: if you built mod_dav as a dynamic module as well, make sure
the above line appears after the one that loads mod_dav.so.
Next, add this to the *bottom* of your httpd.conf:
<Location /svn/repos>
DAV svn
SVNPath /absolute/path/to/repository
</Location>
This will give anyone unrestricted access to the repository. If
you want limited access, read or write, you add these lines to
the Location block:
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /my/svn/user/passwd/file
And:
a) For a read/write restricted repository:
Require valid-user
b) For a write restricted repository:
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
c) For separate restricted read and write access:
AuthGroupFile /my/svn/group/file
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require group svn_committers
</LimitExcept>
<Limit GET PROPFIND OPTIONS REPORT>
Require group svn_committers
Require group svn_readers
</Limit>
These are only a few simple examples. For a complete tutorial
on Apache access control, please consider taking a look at the
tutorials found under "Security" on the following page:
http://httpd.apache.org/docs-2.0/misc/tutorials.html
In order for 'svn cp' to work (which is actually implemented as a
DAV COPY command), mod_dav needs to be able to determine the
hostname of the server. A standard way of doing this is to use
Apache's ServerName directive to set the server's hostname. Edit
your /usr/local/apache2/conf/httpd.conf to include:
ServerName svn.myserver.org
If you are using virtual hosting through Apache's NameVirtualHost
directive, you may need to use the ServerAlias directive to specify
additional names that your server is known by.
If you have configured mod_deflate to be in the server, you can enable
compression support for your repository by adding the following line
to your Location block:
SetOutputFilter DEFLATE
NOTE: If you are unfamiliar with an Apache directive, or not exactly
sure about what it does, don't hesitate to look it up in the
documentation: http://httpd.apache.org/docs-2.0/mod/directives.html.
NOTE: Make sure that the user 'nobody' (or whatever UID the
httpd process runs as) has permission to read and write the
Berkeley DB files! This is a very common problem.
D. Running and Testing
-------------------
Fire up apache 2:
$ /usr/local/apache2/bin/apachectl stop
$ /usr/local/apache2/bin/apachectl start
Check /usr/local/apache2/logs/error_log to make sure it started
up okay.
Try doing a network checkout from the repository:
$ svn co http://localhost/svn/repos wc
The most common reason this might fail is permission problems
reading the repository db files. If the checkout fails, make
sure that the httpd process has permission to read and write to
the repository. You can see all of mod_dav_svn's complaints in
the Apache error logfile, /usr/local/apache2/logs/error_log.
To run the regression test suite for networked Subversion, see
the instructions in subversion/tests/cmdline/README.
For advice about tracing problems, see "Debugging the server" in
www/hacking.html.
E. Alternative: 'svnserve' and ra_svn
-----------------------------------
An alternative network layer is libsvn_ra_svn (on the client
side) and the 'svnserve' process on the server. This is a
simple network layer that speaks a custom protocol over plain
TCP (documented in libsvn_ra_svn/protocol):
$ svnserve -d # becomes a background daemon
$ svn checkout svn://localhost/usr/local/svn/repository
You can use the "-r" option to svnserve to set a logical root
for repositories, and the "-R" option to restrict connections to
read-only access. ("Read-only" is a logical term here; svnserve
still needs write access to the database in this mode, but will
not allow commits or revprop changes.)
'svnserve' has built-in CRAM-MD5 authentication (so you can use
non-system accounts), and can also be tunneled over SSH (so you
can use existing system accounts). It's also capable of using
Cyrus SASL if libsasl2 is detected at ./configure time. Please
read chapter 6 in the Subversion Book
(http://svnbook.red-bean.com) for details on these features.
Eclipse的subeclpse插件的安装,下载subeclipse插件的jar文件,如下图所示:
将其拷贝到ECLIPSE_HOME/plugins/目录下,删除ECLIPSE_HOME /configuration/org.eclipse.update文件夹,重新启动Eclipse后,在WindowàPreference窗口最下部分的Team中,即可看到SVN的标记,如下图所示:
可以通过New Project中选择通过SVN创建项目,然后新建Reposity,填写SVN的URL:
http://domain:port/svn/test,进行项目的创建,如下图所示:
如果该reposity存在,并且服务器需要验证用户,则提示输入用户名和密码,输入正确后将显示在reposity已经存在的项目,笔者没有在test中创建项目,所以为空:
可以通过Eclipse创建一个项目,然后上传到SVN中,如下图所示:
(选择将项目共享,或者上传到SVN服务器)
(通过CVS还是SVN进行共享项目)
(选择SVN仓库repository的位置)
(选择项目/文件夹的名称)
(输入提交的注释,可以为空)
(已经显示为是SVN中的内容,文件后面显示时间,创建者等信息)
(对当前的SVN中客户端内容进行修改后会显示变化)
对于客户端工具,还有更方便的工具,那就是TortoiseSVN-1.4.0.7501-win32-svn-1.4.0.msi,这个工具提供了强大的客户端功能,删除,创建,修改repository中的文件夹,提交,更新等操作也很方便。
总之Subversion的功能比CVS更加的强大,但是对于笔者来说,需要使用到的功能并不是很多,所以只是简略的做了以下介绍。