學(xué)習(xí)筆記:在Debian下如何進(jìn)行Subversion配置
學(xué)習(xí)Subversion時,你可能會遇到Subversion配置問題,這里將介紹Subversion配置問題的解決方法,在這里拿出來和大家分享一下。就像大多數(shù)軟件的安裝和配置一樣,Subversion配置和使用在Debian下也是非常方便?,F(xiàn)以使用Apache2+mod_svn的方式加以說明。
假定條件:我們將所有的項目都放在/var/lib/svn目錄下,要創(chuàng)建foo這個項目。項目的使用人員有張三(zhangs)和李四(lis)。張三(zhangs)是領(lǐng)導(dǎo),只負(fù)責(zé)審查(只讀),不用修改;李四(lis)是苦工,什么都要干(讀寫)。
1.首先當(dāng)然是安裝Apache2和Subversion。
apt-getinstalllibapache2-svnapache2-mpm-preforksubversion
這兒選用apache2-mpm-prefork的理由是,當(dāng)前在Debian中只有這個版本可以使用PHP4。
2.創(chuàng)建一個項目
svnadmincreate/var/lib/svn/foo
因為我們要由Apache2來提供服務(wù),所以將目錄權(quán)限改成是Apache2運行時用戶www-data:
chownwww-data.www-data/var/lib/svn/foo-R。
通過上面對Subversion配置的介紹你一定對Subversion有了更深刻的理解吧,下面繼續(xù)第三步。
3.配置Apache2
編輯/etc/apache2/mods-available/dav_svn.conf,使之如下:
#dav_svn.conf-ExampleSubversion/Apacheconfiguration
#
#FordetailsandfurtheroptionsseetheApacheusermanual.
#
#URLcontrolshowtherepositoryappearstotheoutsideworld.
#Inthisexampleclientsaccesstherepositoryashttp://hostname/svn/repos
#uncommentthistoenabletherepository
DAVsvn
#setthistothepathtoyourrepository
SVNParentPath/var/lib/svn
SVNIndexXSLT"/svnindex.xsl"
#Thefollowingallowsforbasichttpauthentication.Basicauthentication
#shouldnotbeconsideredsecureforanyparticularlyrigorousdefinitionof
#secure.
#tocreateapasswdfile
##rm-f/etc/apache2/dav_svn.passwd
##htpasswd2-c/etc/apache2/dav_svn.passwddwhedon
#Newpassword:
#Re-typenewpassword:
#Addingpasswordforuserdwhedon
##
#Uncommentthefollowing3linestoenableBasicAuthentication
AuthTypeBasic
AuthName"SubversionRepository"
#AuthLDAPEnabledon
#AuthLDAPURLldap://localhost/ou=Users,dc=sczfcpa,dc=com?uid?one
AuthUserFile/etc/apache2/dav_svn.passwd
#UncommentthefollowinglinetoenableAuthzAuthentication
AuthzSVNAccessFile/etc/apache2/dav_svn.authz
#Uncommentthefollowingthreelinesallowanonymousread,butmake
#committersauthenticatethemselves
#
Requirevalid-user
#
修改訪問權(quán)限的Subversion配置文件/etc/apache2/dav_svn.authz(/etc/apache2/mods-available/dav_svn.conf指定的),使之如下:
[foo:/]
*=
zhangs=r
lis=rw
然后再添加用戶到/etc/apache2/dav_svn.passwd:
htpasswd2-c/etc/apache2/dav_svn.passwdzhangs
(輸入密碼)
htpasswd2-c/etc/apache2/dav_svn.passwdlis
(輸入密碼)
Apache2的監(jiān)聽端口在/etc/apache2/ports.conf里面設(shè)置,我設(shè)置的81,這樣可以不影響現(xiàn)有的Apache1.3。
現(xiàn)在可以試試用http://localhost:81/svn/foo來訪問了。
【編輯推薦】