Owen的酒楼

--酒楼上渡过的人生--
生命太短,人生太长,但愿别喝醉了。

导航

CentOS6 安装svn

Posted on 2012-03-22 15:26  Hicome  阅读(3867)  评论(0编辑  收藏  举报

在安装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客户端访问的用户名和密码。