二、HTTP:// [apache]
1、安装包 [已安装subversion]
$ sudo apt-get install libapache2-svn
2、创建版本仓库:
sudo svnadmin create /目录地址
目录地址必须存在,这个就是保存版本仓库的地方,不同的版本仓库创建不同的文件夹即可,比如:
sudo svnadmin create /home/svn/tang
3、然后把这个版本仓库目录授权给apache读写:
sudo chown -R www-data:www-data /home/svn/tang
4、然后来到打开apache配置文件:
sudo vim /etc/apache2/mods-available/dav_svn.conf
加入如下内容:
- # dav_svn.conf - Example Subversion/Apache configuration
- #
- # For details and further options see the Apache user manual and
- # the Subversion book.
- #
- # NOTE: for a setup with multiple vhosts, you will want to do this
- # configuration in /etc/apache2/sites-available/*, not here.
- # <Location URL> ... </Location>
- # URL controls how the repository appears to the outside world.
- # In this example clients access the repository as <a href="http://hostname/svn/">http://hostname/svn/</a>
- # Note, a literal /svn should NOT exist in your document root.
- <Location /svn>
- # Uncomment this to enable the repository
- DAV svn
- # Set this to the path to your repository
- SVNPath /home/svn/tang
- # Alternatively, use SVNParentPath if you have multiple repositories under
- # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
- # You need either SVNPath and SVNParentPath, but not both.
- #SVNParentPath /home/svn/tang
- # Access control is done at 3 levels: (1) Apache authentication, via
- # any of several methods. A "Basic Auth" section is commented out
- # below. (2) Apache <Limit> and <LimitExcept>, also commented out
- # below. (3) mod_authz_svn is a svn-specific authorization module
- # which offers fine-grained read/write access control for paths
- # within a repository. (The first two layers are coarse-grained; you
- # can only enable/disable access to an entire repository.) Note that
- # mod_authz_svn is noticeably slower than the other two layers, so if
- # you don't need the fine-grained control, don't configure it.
- # Basic Authentication is repository-wide. It is not secure unless
- # you are using https. See the 'htpasswd' command to create and
- # manage the password file - and the documentation for the
- # 'auth_basic' and 'authn_file' modules, which you will need for this
- # (enable them with 'a2enmod').
- AuthType Basic
- AuthName "Subversion Repository"
- AuthUserFile /etc/apache2/dav_svn.passwd
- # To enable authorization via mod_authz_svn
- #AuthzSVNAccessFile /etc/apache2/dav_svn.authz
- # The following three lines allow anonymous read, but make
- # committers authenticate themselves. It requires the 'authz_user'
- # module (enable it with 'a2enmod').
- #<LimitExcept GET PROPFIND OPTIONS REPORT>
- Require valid-user
- #</LimitExcept>
- </Location>
location说的是访问地址,比如上述地址,访问的时候就是
http://192.168.1.104/tang
其中有两行被注释掉了,以保证每次都需要用户名密码。
最后一步就是创建访问用户了,建议将用户名密码文件存放在当前版本仓库下conf文件夹下,这样版本仓库多的时候无至于太乱。
因为conf文件夹下已经存在passwd文件了,所以直接添加用户:
sudo htpasswd -c /home/svn/project/conf/passwd tang
然后输入两遍密码,tang 这个用户就创建好了。
打开 /etc/apache2/dav_svn.passwd 这个文件,会开到形如如下形式的文本:
tang:WEd.83H.gealA //后面是加密后的密码。
创建以后,再次需要往别的版本仓库添加这个用户,直接把这一行复制过去就可以了。
重启apache就可以了。
sudo /etc/init.d/apache2 restart
开机自动启动svn服务
在init.d目录建立一个脚本文件svnd.sh
# cd /etc/init.d
# vim svnd.sh
输入svnd.sh内容如下(/kaifa/svn 为svn仓库目录):
#!/bin/bash
#svnserve startup
svnserve -d -r /kaifa/svn
保存退出。
更新,修改权限:
# update-rc.d svnd.sh defaults
# chmod 777 svnd.sh
