一、背景介紹
svn服務器是一款上傳代碼的工具(貌似這么說不怎么嚴謹,但是在日常工作中基本上是這么用的),今天一個小伙伴折騰了一天也沒有搭建好這個svn服務器。各種問題,其實搭建SVN服務器最重要的就是三個配置文件(svnserver.conf、 passwd 、authz)。出了問題的話十有八九是這三個配置文件的問題。最后,我自己搭建了一個,測試成功。于是把這個過程記錄下來,以備使用。當然還有一個問題,那就是客戶端的svn工具版本太低造成的,會用提示的。運維最好是在拿另外一臺服務器當客戶端來測試,確保自己的svnserver沒有問題,然后就可以愉快的去懟開發了。
二、安裝過程
[root@localhost ~]# yum -y install subversion [root@localhost ~]# svnadmin create /home/svn/repos #svn倉庫的位置 [root@localhost ~]# cd /home/svn/repos/ [root@localhost repos]# ls conf db format hooks locks README.txt [root@localhost repos]# cd conf/ [root@localhost conf]# vim svnserve.conf
將以下內容的注釋去掉,然后這些配置要頂頭,不能與左側有空格,不然會報錯
[general] anon-access = none #匿名訪問權限,默認read,none為不允許訪問 auth-access = write #認證用戶權限 password-db = passwd #用戶信息存放文件,默認在版本庫/conf下面,也可以絕對路徑指定文件位置 authz-db = authz [root@localhost conf]# vim passwd [users] xiaoming = 123 zhangsan = 123 lisi = 123 [root@localhost conf]# vim authz [groups] #定義組的用戶 manager = xiaoming core_dev = zhangsan,lisi [repos:/] #以根目錄起始的repos版本庫manager組為讀寫權限 @manager = rw [repos:/media] #core_dev對repos版本庫下media目錄為讀寫權限 @core_dev = rw
到此位置所有配置已完成
[root@localhost conf]# svnserve -d -r /home/svn #啟動svnserver [root@localhost conf]# netstat -antp |grep svnserve #查看端口號3690 tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 17412/svnserve [root@localhost ~]# iptables -F #關閉防火墻
三、測試
接下來到另外一臺服務器上去做測試,此時這臺服務器是客戶端的角色
[root@localhoast svntest]# svn checkout svn://172.16.72.4/repos /svn --username xiaoming --password 123 ----------------------------------------------------------------------- ATTENTION! Your password for authentication realm: <svn://172.16.72.4:3690> ef513f9d-89b5-4751-94fa-bfadb578deb4 can only be stored to disk unencrypted! You are advised to configure your system so that Subversion can store passwords encrypted, if possible. See the documentation for details. You can avoid future appearances of this warning by setting the value of the 'store-plaintext-passwords' option to either 'yes' or 'no' in '/root/.subversion/servers'. ----------------------------------------------------------------------- Store password unencrypted (yes/no)? yes Checked out revision 0. #成功
svn現在的使用率一直在下降,被git所取代,就像apache被nginx取代一樣。但這也是一款很常用的程序,至少開發每天都在用。
原創文章,作者:hanlln1,如若轉載,請注明出處:http://www.www58058.com/63299