Linux下學習部署svn版本控制服務

1、 官網http://subversion.apache.org,

SVN是Subversion的簡稱,是一個開放源代碼的版本控制系統,相較於RCS、CVS,它採用了分支管理系統,是apache組織下的一個項目,它的設計目標就是取代CVS。互聯網上很多版本控制服務已從CVS遷移到Subversion。說得簡單一點SVN就是用於多個人共同開發同一個項目,共用資源的目的,這次實驗目的實現部署並實現推送下載。

2、 安裝軟體

[root@vipuser200 ~]# yum -y install subversion httpd mod_dav_svn

創建文件和項目

[root@vipuser200 ~]# mkdir /svn

Advertisements

[root@vipuser200 ~]# cd /svn/

[root@vipuser200 svn]# svnadmin create /svn/www.vipuser.club

[root@vipuser200 svn]# svnadmin create /svn/www.vipuser1.club

查看目錄下信息

[root@vipuser200 svn]# ls

www.vipuser1.club www.vipuser.club

[root@vipuser200 svn]# cd www.vipuser.club/

[root@vipuser200 www.vipuser.club]# ls

conf db format hooks locks README.txt

Advertisements

進入配置文件修改配置文件

[root@vipuser200 www.vipuser.club]# cd conf/

[root@vipuser200 conf]# ls

authz passwd svnserve.conf

[root@vipuser200 conf]# vim svnserve.conf #將下面幾行啟用

[general]

anon-access = read

auth-access = write

password-db = passwd

authz-db = authz

realm = My First Repository

添加用戶信息

[root@vipuser200 conf]# vim passwd

[users]

# harry = harryssecret

# sally = sallyssecret

zlf01 = 123456

zlf02 = 123456

zlf03 = 123456

修改認證信息添加下面信息

[root@vipuser200 conf]# vim authz

Check = zlf01,zlf02 #Check組

[/] #當前版本根目錄

zlf03 = rw #用戶可讀可寫

@Check = r #Check組可以讀

* = #其他人沒許可權

啟動版本庫

查看幫助

[root@vipuser200 conf]# svnserve --help

方法一:

[root@vipuser200 conf]# svnserve -d -r /svn/

方法二:修改下面一行

[root@vipuser200 conf]# vim /etc/init.d/svnserve

args="--daemon --pid-file=${pidfile} $OPTIONS -d -r /svn"

[root@vipuser200 conf]# ps -aux | grep svn

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

root 1370 0.0 0.0 152860 744 ? Ss 09:57 0:00 svnserve -d -r /svn/

root 1480 0.0 0.0 103244 836 pts/0 S+ 10:18 0:00 grep svn

[root@vipuser200 conf]# kill -9 1370

[root@vipuser200 conf]# service svnserve restart

Stopping svnserve: [FAILED]

Starting svnserve: [ OK ]

3、 本地導入服務端

[root@vipuser200 ~]# mkdir localsvn #創建本地目錄

[root@vipuser200 ~]# cd localsvn/

[root@vipuser200 localsvn]# touch 1.html 2.html #創建文件

[root@vipuser200 localsvn]# svn import /root/localsvn/ file:///svn/www.vipuser.club/ -m "v1.0"#第一次導入使用import,任何一個導入都必須添加註釋

Adding /root/localsvn/1.html

Adding /root/localsvn/2.html

Committed revision 1.

客戶端導入

[root@vipuser202 ~]# mkdir editwebsite

[root@vipuser202 ~]# cd editwebsite/

[root@vipuser202 editwebsite]# touch 3.html 4.html

[root@vipuser202 editwebsite]# svn import /root/editwebsite/ svn://172.27.35.200/www.vipuser.club/ -m "v2.0" #第一次導入需要import

Authentication realm: <svn://172.27.35.200:3690> My First Repository

Password for 'root': #直接回車可以切換用戶

Authentication realm: <svn://172.27.35.200:3690> My First Repository

Password for 'zlf03': #認證文件中只有zlf03有寫的許可權

-----------------------------------------------------------------------

ATTENTION! Your password for authentication realm:

<svn://172.27.35.200:3690> My First Repository

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)? no #是否存儲密碼為了測試填寫no

Adding /root/editwebsite/3.html

Adding /root/editwebsite/4.html

Committed revision 2.

4、 服務端取出

[root@vipuser200 conf]# svn checkout svn://172.27.35.200/www.vipuser.club/ downsource #checkout取出當前downsource目錄

Authentication realm: <svn://172.27.35.200:3690> My First Repository

Password for 'root':

Authentication realm: <svn://172.27.35.200:3690> My First Repository

Username: zlf01 #zlf01有讀的許可權

Password for 'zlf01':

-----------------------------------------------------------------------

ATTENTION! Your password for authentication realm:

<svn://172.27.35.200:3690> My First Repository

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)? no

A downsource/1.html

A downsource/2.html

A downsource/3.html

A downsource/4.html

Checked out revision 2. #只有提交的時候版本號才回疊加

查看

[root@vipuser200 conf]# ls

authz downsource passwd svnserve.conf

[root@vipuser200 conf]# cd downsource/

[root@vipuser200 downsource]# ls

1.html 2.html 3.html 4.html

客戶端取出

[root@vipuser202 ~]# svn checkout svn://172.27.35.200/www.vipuser.club/ downsource

Authentication realm: <svn://172.27.35.200:3690> My First Repository

Password for 'zlf03':

-----------------------------------------------------------------------

ATTENTION! Your password for authentication realm:

<svn://172.27.35.200:3690> My First Repository

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)? no

A downsource/1.html

A downsource/2.html

A downsource/3.html

A downsource/4.html

Checked out revision 2.

查看

[root@vipuser202 ~]# cd downsource/

[root@vipuser202 downsource]# ls

1.html 2.html 3.html 4.html

添加並推送

[root@vipuser202 downsource]# touch 5.html

[root@vipuser202 downsource]# svn add 5.html #添加並未推送

A 5.html

[root@vipuser202 downsource]# svn commit -m "v3.0" #推送

Authentication realm: <svn://172.27.35.200:3690> My First Repository

Password for 'zlf03':

-----------------------------------------------------------------------

ATTENTION! Your password for authentication realm:

<svn://172.27.35.200:3690> My First Repository

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)? no

Adding 5.html

Transmitting file data .

Committed revision 3. #版本為3

完成!

Advertisements

你可能會喜歡