您的位置:首页 > 运维架构 > Apache

Debian下SVN服务器安装

2008-12-05 10:12 387 查看

Debian下SVN服务器安装

Subversion是新一代的开源版本控制系统,用以取代CVS。在安装配置SVN时,遇到了一些问题,在网上搜集资料得到解决。由于资料比较杂乱,所以特此重新整理了一下。

第一步安装测试subversion

1.安装#apt-getupdate
#apt-getinstallsubversionsubversion-tools

2.创建存储库
#mkdir/home/svn
#svnadmincreate–-fs-typefsfs/home/svn/test

3.设置权限
#chown–Rwww-data:www-data/home/svn/*
#chmod–R770/home/svn/*

4.从本地导入源代码:
#mkdir–p/var/svn/test
#touch/var/svn/test.txt
#cd/var/svn
#svnimport./testhttp://hi.baidu.com/home/svn/test-m“Initialimport.”
如果出错,可能是路径的问题。

5.察看代码库内容:
#svnlisthttp://hi.baidu.com/home/svn/test

如果以上没有报错,说明subversion已经正确安装。

第二步通过http方式访问subversion

为了远程访问SVN,通常使用apache服务器。
1.安装组件
#apt-getinstallapache2libapache2-svn

2.测试apache2http://服务器地址
3.修改配置文件/etc/apache2/mods-enable/dav_svn.conf
#vim/etc/apache2/mods-enabled/dav_svn.conf
#dav_svn.conf-ExampleSubversion/Apacheconfiguration
#
#FordetailsandfurtheroptionsseetheApacheusermanualand
#theSubversionbook.
#<LocationURL>...</Location>
#URLcontrolshowtherepositoryappearstotheoutsideworld.
#Inthisexampleclientsaccesstherepositoryas
<Location'target='_blank'>http://hostname/svn/
<Location/svn>                                #设置访问路径
#Uncommentthistoenabletherepository,
DAVsvn                                    #启用
#Setthistothepathtoyourrepository
  #SVNPath/data/subversion                    #设置储存库路径,仅支持单个储存库,该路径要可被Apache进程访问。
SVNParentPath/home/svn              #如果subversion下有多个储存库,则用SVNParentPath
#Thefollowingallowsforbasichttpauthentication.Basicauthentication
#shouldnotbeconsideredsecureforanyparticularlyrigorousdefinitionof
#secure.
#tocreateapasswdfile                    #按下面的步骤创建Apache用户验证文件
##rm-f/etc/apache2/dav_svn.passwd
##htpasswd2-c/etc/apache2/dav_svn.passwddwhedon
#Newpassword:
#Re-typenewpassword:
#Addingpasswordforuserdwhedon
##
#Uncommentthefollowing3linestoenableBasicAuthentication
  
AuthTypeBasic                              #启用Apache基础验证
  AuthName"SubversionRepository"            #设置验证框标题
  AuthUserFile/etc/apache2/dav_svn.passwd   #指定验证用户文件名
#UncommentthefollowinglinetoenableAuthzAuthentication
AuthzSVNAccessFile/etc/apache2/dav_svn.authz#启用目录级别授权,dav_svn.authz是授权配置文档
#Thefollowingthreelinesallowanonymousread,butmake
#committersauthenticatethemselves.
#<LimitExceptGETPROPFINDOPTIONSREPORT>   #允许匿名访问,不允许Commit,不能与AuthzSVNAccessFile同时使用
   Requirevalid-user                        
  #</LimitExcept>
</Location>


4.创建/etc/apache2/dav_svn.authz
[test:/]
*=
Zhangsan=rw
Lisi=r
5.设置用户口令:
#htpasswd–c–m/etc/apache2/dav_svn.passwdzhangsan
#htpasswd–c–m/etc/apache2/dav_svn.passwdlisi

6.测试:http://服务器地址/svn/test

第三步添加SSL支持

为了提供比较安全的远程访问,需要开启apache2的SSL支持。
1.      运行命令a2enmodssl。打开apache2的SSL支持。
2.      编辑/etc/apache2/ports.conf文件。在此文件中,缺省只有Listen80,也就是apache只接受80端口的普通http访问。我们再添加一项"Listen443",443是https的端口。
3.      编辑/etc/apache2/sites-available/default文件,把“NameVirtualHost*"改为"NameVirtualHost*:80","<VirtualHost*>"改为"<VirtualHost*:80>"。
4.      运行命令apache2-ssl-certificate,根据提示回答问题,生成SSL的证书,自动被放置在/etc/apache2/ssl/。
5.      在/etc/apache2/sites-available/下建立一个新的文件,名字可以叫做ssl.这个文件可以拷贝/etc/apache2/sites-availbale/default获得。但是要修改VirtualHost和NameVirtualHost的端口为443。在这个文件中加入以下两行:"SSLEngineOn"和"SSLCertificateFile/etc/apache2/ssl/apache.pem"。
6.      使用a2ensitessl来使我们的ssl虚拟主机生效。
7.      /etc/init.d/apache2force-reload重新启动apache2的系统服务。
8.      使用其他机器的浏览器来登陆本服务器,注意要使用https协议来测试我们的apache服务器是否接受https连接。
9.      使用a2enmoddav_svn来加载subversion模块。
10.   subversion模块的配置文件在/etc/apache2/mods-available/dav_svn.conf中。为了限制非SSL用户登陆,我们可以使用如下一句"SSLRequireSSL"来限制。为了禁止匿名用户登陆,加上"Requirevalid-user"一句。
在创建证书时,发现系统没有apache2-ssl-certificate命令,查找资料发现这是系统的漏洞。解决方法如下:
Ubuntufeisty中的apache2安装包有BUG,安装后缺少apache2-ssl-certificate命令,这样如果我们要启用apache的ssl服务,就生成不了站点证书。
不过,现在已经有人做了这个工作了,我们可以通过自己编译apache2源码来安装,安装方法如下:
首先下载并解压这个修复包:wget
tar'target='_blank'>http://librarian.launchpad.net/6917265/files.tar
[code]tarxvffiles.tar

然后安装Apache2deb源代码及相关编译依赖包,然后编译安装apache2:sudoapt-getbuild-depapache2
sudoapt-getsource-dapache2
dpkg-source-xapache2_2.2.3-3.2build1.dsc
cdapache2-2.2.3
fakerootdebian/rulesbinary(如果没有安装fakeroot,请先安装)
sudodpkg-i../*.deb(您也可以选择性的安装您需要的Apache2deb包)

这样安装的apache2包含完整的工具,下面我们来配置Apache2ssl支持:
先生成站点证书:sudoapache2-ssl-certificate-days365
接着启用Apache2的ssl模块:sudoa2enmodssl
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息