CentOS6 安裝svn


在安裝svn之前請確認已安裝好apache服務器。

一.環境說明:

          svn服務器,centos6.0 64位,ip地址,172.7.22.23,svn版本 subversion-1.6.11-2.el6.x86_64.rpm

          客戶端,windows sp3 32位,ip地址,172.7.22.22,svn客戶端版本 TortoiseSVN-1.6.12.20536-win32-svn-1.6.15.msi

二.安裝svn:

           由於我在官方下載的最新版本在安裝的時總出問題,所以決定安裝centos6光盤自帶svn,這樣會少些麻煩。首先要將yum源設置本地光盤。

然后使用:yum install svn這樣svn就會安裝到電腦上了。

三.配置使用svn

1.建立一個本地倉庫

mkdir /usr/share/park/  創建一個文件夾

運行創建版本庫的命令,指定數據存儲為FSFS,如果指定為Berkeley DB,則將fsfs修改為bdb

svnadmin create --fs-type fsfs /usr/share/park/test

//版本庫創建成功。

[root@centOS6-xie park]# cd test/

[root@centOS6-xie test]# ls -al

總用量 32

drwxr-xr-x. 6 root   root   4096 10月 14 11:43 .

drwxr-xr-x. 8 apache apache 4096 10月 14 11:43 ..

drwxr-xr-x. 2 root   root   4096 10月 14 11:43 conf

drwxr-sr-x. 6 root   root   4096 10月 14 11:43 db

-r--r--r--. 1 root   root      2 10月 14 11:43 format

drwxr-xr-x. 2 root   root   4096 10月 14 11:43 hooks

drwxr-xr-x. 2 root   root   4096 10月 14 11:43 locks

-rw-r--r--. 1 root   root    229 10月 14 11:43 README.txt

2.導入點內容看看

我們將把/software/flahget-1.0.3目錄下的所有內容導入到svn的park庫

[root@centOS6-xie test]# svn import /software/flashget-1.0.3 file:///usr/share/park/test/ --message "初始化版本"                                                                                       

增加           /software/flashget-1.0.3/install.sh

增加 (二進制)  /software/flashget-1.0.3/flashget.png

增加           /software/flashget-1.0.3/flashget.desktop

增加 (二進制)  /software/flashget-1.0.3/flashget

增加           /software/flashget-1.0.3/README

 

提交后的版本為 1。

查看導入文件:

[root@centOS6-xie test]# svn list --verbose file:///usr/share/park/test/

      1 root                  10月 14 11:48 ./

      1 root             3460 10月 14 11:48 README

      1 root          5759228 10月 14 11:48 flashget

      1 root              341 10月 14 11:48 flashget.desktop

      1 root             6045 10月 14 11:48 flashget.png

      1 root             1606 10月 14 11:48 install.sh

3.啟動svn服務:

svnserve -d -r /us         r/share/park/

查看是否正常啟動:

[root@centOS6-xie test]# netstat -tnl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State     

tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN     

tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN     

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:53664               0.0.0.0:*                   LISTEN     

tcp        0      0 :::48011                    :::*                        LISTEN     

tcp        0      0 :::111                      :::*                        LISTEN     

tcp        0      0 :::1521                     :::*                        LISTEN     

tcp        0      0 :::22                       :::*                        LISTEN     

tcp        0      0 ::1:631                     :::*                        LISTEN     

tcp        0      0 :::60798                    :::*                        LISTEN

3690端口以監聽,svn服務已經啟動。

4.訪問客戶端

在客戶端通過如下url訪問:

5.配合apache使用

除了服務器需要安裝apache之外,還給apache安裝2個svn的擴展插件

1.mod_dav_svn(使subversion與dav模塊通信的功能)

mod_dav_svn-1.6.11-2.el6.x86_64.rpm(光盤自帶)

2.mod_authz_svn(實現權限控制功能)

mod_authz_ldap-0.26-15.el6.x86_64.rpm(光盤自帶)

這2個模塊在CentOS6光盤都帶有,因此只要采用rpm -ivh安裝就可以了。當然你可以將光盤作為yum源,使用如下命令:

yum install mod_dav_svn

yum install mod_authz_ldap

安裝好后,這2個模塊的加載配置在/etc/httpd/conf.d/subversion.conf中有加載,而在/etc/httpd/conf/httpd.conf中有這樣一句包含了它:

#

# Load config files from the config directory "/etc/httpd/conf.d".

#

Include conf.d/*.conf

給svn添加一個虛擬目錄

<Location /test>

DAV svn

SVNPath /usr/share/park/test

</Location>

啟動apache和改變svn組

service httpd restart

chwon -Rf apache:apache /usr/share/park

在客戶端輸入如下ip進行訪問:

這就證明svn可以通過apache訪問了。下面需要配置訪問權限。

6.對svn進行用戶密碼驗證

編輯httpd.conf如下:

<Location /test>

DAV svn

SVNPath /usr/share/park/test

AuthType Basic

AuthName "svn test"

AuthUserFile /usr/share/park/passtest

Require valid-user

</Location>

現在的設置是只有passtest文件中設定的用戶才能訪問版本庫了。我們使用htpasswd生成用戶文件,命令為:"htpasswd -c /usr/share/park/passtest admin"

[root@centOS6-xie conf]# htpasswd -c /usr/share/park/passtest admin

New password:

Re-type new password:

Adding password for user admin

[root@centOS6-xie conf]#

這個命令就是在/usr/share/park/目錄下建立了一個passtest文件並向該文件中添加了一個用戶admin,密碼為admin,如再添加第二個用戶就不加-c了,因為passtest文件已經存在了。

[root@centOS6-xie conf]# htpasswd /usr/share/park/passtest centre

New password:

Re-type new password:

Adding password for user centre

htpasswd默認生成用戶密碼是經過md5加密,比較安全

重啟apache服務,這時訪問就需要用戶驗證了。

7.設置權限,使apache加載mod_authz_svn模塊(先要確定apache已經加載了mod_authz_svn模塊)

命令如下:

[root@centOS6-xie conf]# httpd -M

Loaded Modules:

 core_module (static)

 mpm_prefork_module (static)

 http_module (static)

 so_module (static)

 auth_basic_module (shared)

 auth_digest_module (shared)

 authn_file_module (shared)

 authn_alias_module (shared)

 authn_anon_module (shared)

 authn_dbm_module (shared)

 authn_default_module (shared)

 authz_host_module (shared)

 authz_user_module (shared)

 authz_owner_module (shared)

 authz_groupfile_module (shared)

 authz_dbm_module (shared)

 authz_default_module (shared)

 ldap_module (shared)

 authnz_ldap_module (shared)

 include_module (shared)

 log_config_module (shared)

 logio_module (shared)

 env_module (shared)

 ext_filter_module (shared)

 mime_magic_module (shared)

 expires_module (shared)

 deflate_module (shared)

 headers_module (shared)

 usertrack_module (shared)

 setenvif_module (shared)

 mime_module (shared)

 dav_module (shared)

 status_module (shared)

 autoindex_module (shared)

 info_module (shared)

 dav_fs_module (shared)

 vhost_alias_module (shared)

 negotiation_module (shared)

 dir_module (shared)

 actions_module (shared)

 speling_module (shared)

 userdir_module (shared)

 alias_module (shared)

 substitute_module (shared)

 rewrite_module (shared)

 proxy_module (shared)

 proxy_balancer_module (shared)

 proxy_ftp_module (shared)

 proxy_http_module (shared)

 proxy_ajp_module (shared)

 proxy_connect_module (shared)

 cache_module (shared)

 suexec_module (shared)

 disk_cache_module (shared)

 cgi_module (shared)

 version_module (shared)

 authz_ldap_module (shared)

 dnssd_module (shared)

 dav_svn_module (shared)

 authz_svn_module (shared)

Syntax OK

修改Location

vim httpd.conf

<Location /test>

DAV svn

SVNPath /usr/share/park/test

AuthType Basic

AuthName "svn test"

AuthUserFile /usr/share/park/passtest

AuthzSVNAccessFile /usr/share/park/test/conf/authz

Require valid-user

Satisfy Any

</Location>

重啟apache服務

下面修改/usr/share/park/test/conf/svnserve.conf

去掉anon-access = read(任何人可讀)

Auth-access = write(任何權限認證可寫)

Authz-db = authz(使用指定密碼文件)

Password-db = passwd(使用指定權限驗證文件)

前面的#

修改svn的權限策略文件。

[root@centOS6-xie conf]# vim authz

### This file is an example authorization file for svnserve.

### Its format is identical to that of mod_authz_svn authorization

### files.

### As shown below each section defines authorizations for the path and

### (optional) repository specified by the section name.

### The authorizations follow. An authorization line can refer to:

###  - a single user,

###  - a group of users defined in a special [groups] section,

###  - an alias defined in a special [aliases] section,

###  - all authenticated users, using the '$authenticated' token,

###  - only anonymous users, using the '$anonymous' token,

###  - anyone, using the '*' wildcard.

###

### A match can be inverted by prefixing the rule with '~'. Rules can

### grant read ('r') access, read-write ('rw') access, or no access

### ('').

 

[aliases]

# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

 

[groups]

# harry_and_sally = harry,sally

# harry_sally_and_joe = harry,sally,&joe

 

# [/foo/bar]

# harry = rw

# &joe = r

# * =

admin = admin

user = centre

#建立2個組admin和user,每個組下有一個用戶

# [repository:/baz/fuz]

# @harry_and_sally = rw

# * = r

[/]

#跟目錄任何人可讀

* = r

#admin組下的用戶有可讀寫權限

@admin = rw

修改passwd文件,增加2個用戶

### Its format is similar to that of svnserve.conf. As shown in the

### example below it contains one section labelled [users].

### The name and password for each user follow, one account per line.

 

[users]

# harry = harryssecret

# sally = sallyssecret

admin = admin

centre =centre

這時,在ie中輸入ip:http://172.7.22.23/test將會要求輸入密碼

通過svn客戶端也需要密碼:

 

說明:passtest密碼文件,將指定web訪問需要的用戶名密碼

而passwd密碼,將指定svn客戶端訪問的用戶名和密碼。

在安裝svn之前請確認已安裝好apache服務器。

一.環境說明:

          svn服務器,centos6.0 64位,ip地址,172.7.22.23,svn版本 subversion-1.6.11-2.el6.x86_64.rpm

          客戶端,windows sp3 32位,ip地址,172.7.22.22,svn客戶端版本 TortoiseSVN-1.6.12.20536-win32-svn-1.6.15.msi

二.安裝svn:

           由於我在官方下載的最新版本在安裝的時總出問題,所以決定安裝centos6光盤自帶svn,這樣會少些麻煩。首先要將yum源設置本地光盤。

然后使用:yum install svn這樣svn就會安裝到電腦上了。

三.配置使用svn

1.建立一個本地倉庫

mkdir /usr/share/park/  創建一個文件夾

運行創建版本庫的命令,指定數據存儲為FSFS,如果指定為Berkeley DB,則將fsfs修改為bdb

svnadmin create --fs-type fsfs /usr/share/park/test

//版本庫創建成功。

[root@centOS6-xie park]# cd test/

[root@centOS6-xie test]# ls -al

總用量 32

drwxr-xr-x. 6 root   root   4096 10月 14 11:43 .

drwxr-xr-x. 8 apache apache 4096 10月 14 11:43 ..

drwxr-xr-x. 2 root   root   4096 10月 14 11:43 conf

drwxr-sr-x. 6 root   root   4096 10月 14 11:43 db

-r--r--r--. 1 root   root      2 10月 14 11:43 format

drwxr-xr-x. 2 root   root   4096 10月 14 11:43 hooks

drwxr-xr-x. 2 root   root   4096 10月 14 11:43 locks

-rw-r--r--. 1 root   root    229 10月 14 11:43 README.txt

2.導入點內容看看

我們將把/software/flahget-1.0.3目錄下的所有內容導入到svn的park庫

[root@centOS6-xie test]# svn import /software/flashget-1.0.3 file:///usr/share/park/test/ --message "初始化版本"                                                                                       

增加           /software/flashget-1.0.3/install.sh

增加 (二進制)  /software/flashget-1.0.3/flashget.png

增加           /software/flashget-1.0.3/flashget.desktop

增加 (二進制)  /software/flashget-1.0.3/flashget

增加           /software/flashget-1.0.3/README

 

提交后的版本為 1。

查看導入文件:

[root@centOS6-xie test]# svn list --verbose file:///usr/share/park/test/

      1 root                  10月 14 11:48 ./

      1 root             3460 10月 14 11:48 README

      1 root          5759228 10月 14 11:48 flashget

      1 root              341 10月 14 11:48 flashget.desktop

      1 root             6045 10月 14 11:48 flashget.png

      1 root             1606 10月 14 11:48 install.sh

3.啟動svn服務:

svnserve -d -r /us         r/share/park/

查看是否正常啟動:

[root@centOS6-xie test]# netstat -tnl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State     

tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN     

tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN     

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN     

tcp        0      0 0.0.0.0:53664               0.0.0.0:*                   LISTEN     

tcp        0      0 :::48011                    :::*                        LISTEN     

tcp        0      0 :::111                      :::*                        LISTEN     

tcp        0      0 :::1521                     :::*                        LISTEN     

tcp        0      0 :::22                       :::*                        LISTEN     

tcp        0      0 ::1:631                     :::*                        LISTEN     

tcp        0      0 :::60798                    :::*                        LISTEN

3690端口以監聽,svn服務已經啟動。

4.訪問客戶端

在客戶端通過如下url訪問:

5.配合apache使用

除了服務器需要安裝apache之外,還給apache安裝2個svn的擴展插件

1.mod_dav_svn(使subversion與dav模塊通信的功能)

mod_dav_svn-1.6.11-2.el6.x86_64.rpm(光盤自帶)

2.mod_authz_svn(實現權限控制功能)

mod_authz_ldap-0.26-15.el6.x86_64.rpm(光盤自帶)

這2個模塊在CentOS6光盤都帶有,因此只要采用rpm -ivh安裝就可以了。當然你可以將光盤作為yum源,使用如下命令:

yum install mod_dav_svn

yum install mod_authz_ldap

安裝好后,這2個模塊的加載配置在/etc/httpd/conf.d/subversion.conf中有加載,而在/etc/httpd/conf/httpd.conf中有這樣一句包含了它:

#

# Load config files from the config directory "/etc/httpd/conf.d".

#

Include conf.d/*.conf

給svn添加一個虛擬目錄

<Location /test>

DAV svn

SVNPath /usr/share/park/test

</Location>

啟動apache和改變svn組

service httpd restart

chwon -Rf apache:apache /usr/share/park

在客戶端輸入如下ip進行訪問:

這就證明svn可以通過apache訪問了。下面需要配置訪問權限。

6.對svn進行用戶密碼驗證

編輯httpd.conf如下:

<Location /test>

DAV svn

SVNPath /usr/share/park/test

AuthType Basic

AuthName "svn test"

AuthUserFile /usr/share/park/passtest

Require valid-user

</Location>

現在的設置是只有passtest文件中設定的用戶才能訪問版本庫了。我們使用htpasswd生成用戶文件,命令為:"htpasswd -c /usr/share/park/passtest admin"

[root@centOS6-xie conf]# htpasswd -c /usr/share/park/passtest admin

New password:

Re-type new password:

Adding password for user admin

[root@centOS6-xie conf]#

這個命令就是在/usr/share/park/目錄下建立了一個passtest文件並向該文件中添加了一個用戶admin,密碼為admin,如再添加第二個用戶就不加-c了,因為passtest文件已經存在了。

[root@centOS6-xie conf]# htpasswd /usr/share/park/passtest centre

New password:

Re-type new password:

Adding password for user centre

htpasswd默認生成用戶密碼是經過md5加密,比較安全

重啟apache服務,這時訪問就需要用戶驗證了。

7.設置權限,使apache加載mod_authz_svn模塊(先要確定apache已經加載了mod_authz_svn模塊)

命令如下:

[root@centOS6-xie conf]# httpd -M

Loaded Modules:

 core_module (static)

 mpm_prefork_module (static)

 http_module (static)

 so_module (static)

 auth_basic_module (shared)

 auth_digest_module (shared)

 authn_file_module (shared)

 authn_alias_module (shared)

 authn_anon_module (shared)

 authn_dbm_module (shared)

 authn_default_module (shared)

 authz_host_module (shared)

 authz_user_module (shared)

 authz_owner_module (shared)

 authz_groupfile_module (shared)

 authz_dbm_module (shared)

 authz_default_module (shared)

 ldap_module (shared)

 authnz_ldap_module (shared)

 include_module (shared)

 log_config_module (shared)

 logio_module (shared)

 env_module (shared)

 ext_filter_module (shared)

 mime_magic_module (shared)

 expires_module (shared)

 deflate_module (shared)

 headers_module (shared)

 usertrack_module (shared)

 setenvif_module (shared)

 mime_module (shared)

 dav_module (shared)

 status_module (shared)

 autoindex_module (shared)

 info_module (shared)

 dav_fs_module (shared)

 vhost_alias_module (shared)

 negotiation_module (shared)

 dir_module (shared)

 actions_module (shared)

 speling_module (shared)

 userdir_module (shared)

 alias_module (shared)

 substitute_module (shared)

 rewrite_module (shared)

 proxy_module (shared)

 proxy_balancer_module (shared)

 proxy_ftp_module (shared)

 proxy_http_module (shared)

 proxy_ajp_module (shared)

 proxy_connect_module (shared)

 cache_module (shared)

 suexec_module (shared)

 disk_cache_module (shared)

 cgi_module (shared)

 version_module (shared)

 authz_ldap_module (shared)

 dnssd_module (shared)

 dav_svn_module (shared)

 authz_svn_module (shared)

Syntax OK

修改Location

vim httpd.conf

<Location /test>

DAV svn

SVNPath /usr/share/park/test

AuthType Basic

AuthName "svn test"

AuthUserFile /usr/share/park/passtest

AuthzSVNAccessFile /usr/share/park/test/conf/authz

Require valid-user

Satisfy Any

</Location>

重啟apache服務

下面修改/usr/share/park/test/conf/svnserve.conf

去掉anon-access = read(任何人可讀)

Auth-access = write(任何權限認證可寫)

Authz-db = authz(使用指定密碼文件)

Password-db = passwd(使用指定權限驗證文件)

前面的#

修改svn的權限策略文件。

[root@centOS6-xie conf]# vim authz

### This file is an example authorization file for svnserve.

### Its format is identical to that of mod_authz_svn authorization

### files.

### As shown below each section defines authorizations for the path and

### (optional) repository specified by the section name.

### The authorizations follow. An authorization line can refer to:

###  - a single user,

###  - a group of users defined in a special [groups] section,

###  - an alias defined in a special [aliases] section,

###  - all authenticated users, using the '$authenticated' token,

###  - only anonymous users, using the '$anonymous' token,

###  - anyone, using the '*' wildcard.

###

### A match can be inverted by prefixing the rule with '~'. Rules can

### grant read ('r') access, read-write ('rw') access, or no access

### ('').

 

[aliases]

# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

 

[groups]

# harry_and_sally = harry,sally

# harry_sally_and_joe = harry,sally,&joe

 

# [/foo/bar]

# harry = rw

# &joe = r

# * =

admin = admin

user = centre

#建立2個組admin和user,每個組下有一個用戶

# [repository:/baz/fuz]

# @harry_and_sally = rw

# * = r

[/]

#跟目錄任何人可讀

* = r

#admin組下的用戶有可讀寫權限

@admin = rw

修改passwd文件,增加2個用戶

### Its format is similar to that of svnserve.conf. As shown in the

### example below it contains one section labelled [users].

### The name and password for each user follow, one account per line.

 

[users]

# harry = harryssecret

# sally = sallyssecret

admin = admin

centre =centre

這時,在ie中輸入ip:http://172.7.22.23/test將會要求輸入密碼

通過svn客戶端也需要密碼:

 

說明:passtest密碼文件,將指定web訪問需要的用戶名密碼

而passwd密碼,將指定svn客戶端訪問的用戶名和密碼。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM