1、yum install subversion # 安裝svn組件
安裝成功之後,可以看到如下相關的命令被產生:
[flykobe@localhost svnclient]$ svn svn svnadmin svndumpfilter svnlook svnserve svnsync svnversion
2、產生svn倉庫
svnadmin create /var/svnrepos
[flykobe@localhost svnrepos]$ ls -R .: conf dav db format hooks locks README.txt ./conf: authz passwd svnserve.conf ./dav: ./db: current format fs-type revprops revs transactions uuid write-lock ./db/revprops: 0 ./db/revs: 0 ./db/transactions: ./hooks: post-commit.tmpl post-revprop-change.tmpl pre-commit.tmpl pre-revprop-change.tmpl start-commit.tmpl post-lock.tmpl post-unlock.tmpl pre-lock.tmpl pre-unlock.tmpl ./locks: db.lock db-logs.lock
修改conf下的檔案:
[general] ### These options control access to the repository for unauthenticated ### and authenticated users. Valid values are "write", "read", ### and "none". The sample settings below are the defaults. anon-access = read auth-access = write ### The password-db option controls the location of the password ### database file. Unless you specify a path starting with a /, ### the file's location is relative to the conf directory. ### Uncomment the line below to use the default password file. password-db = passwd ### The authz-db option controls the location of the authorization ### rules for path-based access control. Unless you specify a path ### starting with a /, the file's location is relative to the conf ### directory. If you don't specify an authz-db, no path-based access ### control is done. ### Uncomment the line below to use the default authorization file. authz-db = authz ### This option specifies the authentication realm of the repository. ### If two repositories have the same authentication realm, they should ### have the same password database, and vice versa. The default realm ### is repository's uuid. realm = My First Repository
並利用htpasswd產生加密的帳號:
[flykobe@localhost svnrepos]$ htpasswd -cm conf/passwd flykobe # c是create
3、這時就可以訪問svn了:
[flykobe@localhost svnrepos]$ svn info file:///var/svnrepos/ 路徑:svnrepos 地址(URL):file:///var/svnrepos Repository Root: file:///var/svnrepos 檔案庫 UUID:f561f977-8526-4757-94ed-60f16aaa3677 修訂版:0 節點種類:目錄 最後修改的修訂版:0 最後修改的時間: 2009-12-29 17:17:02 +0800 (二, 29 12月 2009)
4、將svn與apache關聯起來
yum install mod_dav_svn # 安裝svn的apache擴充,會在apache的module下產生mod_svn_dav.so
修改apache配置:
201 <Location /repos> 202 DAV svn 203 SVNPath /var/svnrepos/ 204 AuthType Basic 205 AuthName "Subversion repository" 206 AuthUserFile /var/svnrepos/conf/passwd 207 Require valid-user 208 </Location>
重啟apache,之後可以利用http訪問svn了:
svn list http://127.0.0.1/repos