`
chenzugang
  • 浏览: 10824 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

Installing Subversion on Fedora8

阅读更多
参考文档:Installing Subversion on Fedora Core

原以为通过参考文档可以搭建起来SVN服务器,没想到还是有些不同。

1、安装subversion、mod_dav_svn,subversion在fedora8中已经安装了,mod_dav_svn是svn的apache模块。
# yum install subversion
# yum install mod_dav_svn


2、创建代码仓库、访问用户、访问许可文件夹
# mkdir /svn
# mkdir /svn/repos
# mkdir /svn/users
# mkdir /svn/permissions


3、更改上述文件夹的访问权限,以便apache可以操作
# chown -R apache.apache /svn


4、利用subversion命令为具体的项目创建代码仓库。如项目为mydemo
# svnadmin create /svn/repos/mydemo


5、为访问subversion创建配置文件,主要用于关闭匿名访问、指定密码文件和访问域等项目。
vi /svn/repos/conf/svnserve.conf

以下代码为svnserve.conf的内容
non-access = none
password-db = pwdfile
realm = chenzugang.name
auth-access = write


6、创建用户、密码对配置文件。文件名为上一步所指定的password-db项。
vi pwdfile

pwdfile的内容格式如下:
[users]
username = password


7、至此,subversion已经配置完毕,可以启动服务了。
# svnserve -d --listen-port=3690

具体的启动参数可以查看文档。停止subversion服务的命令只有杀死进程一条路(参考文献如是说)如下
killall svnserve


8、如果您没手停止subversion服务,另找一台机器,通过svn命令行以您在pwdfile中建立的用户访问一下您的svn服务,检查是否正常。命令如下
svn co --username=myusername  svn://mydomain/svn/repos/mydemo
其中,mydomian为您svn服务器的IP或域名,如果正常,结果为:
取出版本 0。
之所以为0,是因为都是空的。

9、下面开始配置apache,使得web方式能访问代码库,就是这部分,和参考文档不同,搞的我花了一些时间,而且google之,没有一个管事,后来仔细分析了apache的配置习惯,才猜出来的。
编辑文档subversion.conf。
vi /etc/httpd/conf.d/subversion.conf

这个文档已经存在,因为您安装了mod_dav_svn,他会生成一个默认文档。我机器上默认文档大致如下,之所以是大致,是几经修改,已记不得原始的文档了:


LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn".  Each repository
# must be readable and writable by the 'apache' user.  Note that if
# SELinux is enabled, the repositories must be labelled with a context
# which httpd can write to; this will happen by default for
# directories created in /var/www.  Use "restorecon -R /var/www/svn"
# to label the repositories if upgrading from a previous release.
#

#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
#   # cd /var/www/svn
#   # svnadmin create stuff
#   # chown -R apache.apache stuff
#
#

#<Location /repos>
#  DAV svn
#  SVNParentPath /svn

#
#   # Limit write permission to list of valid users.
#   <LimitExcept GET PROPFIND OPTIONS REPORT>
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
#      AuthType Basic
#      AuthName "xxxxxx"
#      AuthUserFile /svn/users/svnpass
#      Require valid-user
#   </LimitExcept>
</Location>

因该修改为如下:


LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn".  Each repository
# must be readable and writable by the 'apache' user.  Note that if
# SELinux is enabled, the repositories must be labelled with a context
# which httpd can write to; this will happen by default for
# directories created in /var/www.  Use "restorecon -R /var/www/svn"
# to label the repositories if upgrading from a previous release.
#

#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
#   # cd /var/www/svn
#   # svnadmin create stuff
#   # chown -R apache.apache stuff
#

<Location /svn>
   DAV svn
   SVNListParentPath on
   SVNParentPath /svn/repos
#   SVNPath /svn/repos
#
#   # Limit write permission to list of valid users.
#   <LimitExcept GET PROPFIND OPTIONS REPORT>
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
      AuthType Basic
      AuthName "chenzugang.name"
      AuthUserFile /svn/users/svnpass
      Require valid-user
#   </LimitExcept>
</Location>



其中一个关键的参数为
AuthUserFile /svn/users/svnpass
这个是web访问认证的用户身份信息文件。需要创建。创建方法如下,使用htpasswd命令。这个文件中的用户密码是否要与/svn/repos/conf/pwdfile里的用户密码对应,我目前还不清楚,下次再补上
htpasswd -cb /svn/users/svnpass username password


还需要创建一个svn访问读写权限的配置文件。svnauthz.conf
vi /svn/permissions/svnauthz.conf

该文件类容如下:
[/]
username1 = r
username2 = rw

r代表read,w当然就是write啰。

至此,一些于apache相关的配置文件已经完成。
修改SELINUX权限(注:在SELINUX中,安全性得到了加强。若不进行这样的修改,客户端访问时就会报错“Could not open the requested SVN filesystem.”),修改的命令如下:
# chcon -R -h -u system_u -t httpd_sys_content_t /svn/repos

剩下的就是让apache重新装载一下配置文件。命令如下:
service httpd reload

打开浏览器,输入项目代码库地址
http://localhost/svn/mydemo

反正我的是搞定了。你的搞定了没有?
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics