linux SVN服务器部署――Subversion及web控制台Submin部署

一,服务端环境:centos6.6_x86_64

服务端subversion安装

1,安装SVN

# yum install subversion -y

2,查看安装版本

# svnserver --version

3,配置SVN

1) 建立根目录

# mkdir -p /data/svn

2) 建立资源仓库

# svnadmin create /data/svn/repos

# chown svn:svn /data/svn -R

# ls /data/svn/repos/

conf db format hooks locks README.txt 

3) 修改配置文件

# vim /data/svn/repos/conf/svnserve.conf

修改如下:

anon-access = none

auth-access = write

password-db = passwd

authz-db = authz

realm = yungtay svn repos #提示信息

4) 配置用户帐号

# vim /data/svn/repos/conf/passwd

在最后添加如下:

utest = 123456

5) 配置管理用户权限

# vim /data/svn/repos/conf/authz

在最后添加如下:

gp_rd01 = utest01,utest02   #建立组,并设置成员

gp_rd02 = utest02,utest02 #建立第二个组

[/] #对根目录设置权限,该根目录为启动svnserve时指定

utest01 = rw #utest01用户对根目录有读写权限

utest02 = #utest02用户对根目录没有任何权限

* = #其他所有人对根目录没有任何权限

[repos:/project01] #对版本库repos中的project01项目目录设置权限,亦可再添加

@gp_rd01 = rw

utest01 =

[repos:/project02]

@gp_rd02 = rw

utest02 = r

6) 建立svn启动用户并给予目录权限

  # useradd svn

# chown -R svn:svn /data/svn

4,启动SVN服务

1) 启动方式一,不要以系统自带的service启动

        以当前用户启动守护进程,默认启动端口号3690,指定根目录/data/svn

# svnserver -d -r /data/svn

2) 启动方式二(推荐)

        以svn用户启动

# su - svn -c "svnserve -d --listen-port 3690 -r /data/svn"

3) 检查启动状态

# netstat -tunlp | grep svn

如果显示以下信息说明启动成功

tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 25373/svnserve

4) 加入开机启动

vim /etc/rc.d/rc.local

添加

# su - svn -c "svnserve -d --listen-port 3690 -r /data/svn"

5,停止SVN服务

# killall svnserve

6,SVN的备份及恢复

1) 使用hotcopy备份,优点备份恢复速度快,缺点占空间大

# svnadmin hotcopy /data/svn/repos /tmp/repos --clean-logs

# cd /tmp;tar zcvf /tmp/svn_repos_bak.tgz /tmp/repos

# scp /tmp/svn_repos_bak.tgz 10.21.2.229:/tmp

2) 切至还原目标服务器

# mkdir /data/svn -p

# cd /tmp;tar zxvf /tmp/svn_repos_bak.tgz

# cd tmp;mv repos /data/svn/repos

3) 启动服务

# su - svn -c "svnserve -d --listen-port 3690 -r /data/svn/"


二,客户端

1) windows版TortoiseSVN客户端

官方下载地址:http://tortoisesvn.net/downloads.html

2) linux svn客户端命令工具

3) IDE集成插件,如

eclipse可安装插件 http://subclipse.tigris.org/update_1.6.x

修改好文件后更新服务器端,使用commit

从服务器端检查更新,使用checkout


三,配置SVN通过web方式访问

1 安装apache和svn的apache模块

# yum install httpd mod_dav_svn  -y

2 配置apache

# vim /etc/httpd/conf.d/subversion.conf

添加如下

<Location /svn>

    DAV svn

    SVNParentPath /data/svn/

    #SVNPath /data/svn/repos

    # Limit write permission to list of valid users.

    # <LimitExcept GET PROPFIND OPTIONS REPORT>

      # Require SSL connection for password protection.

      # SSLRequireSSL

      AuthType Basic

      AuthName "SVN repose Auth"

      AuthUserFile /data/svn/conf/htpasswd

      AuthzSVNAccessFile /data/svn/conf/authz

      Satisfy Any

      Require valid-user

    # </LimitExcept>

</Location>

3 赋予apache用户目录权限

# usermod -aG svn apache

# chmod g+rw /data/svn -R

# mkdir /data/svn/conf/ -p

拷贝权限配置文件,httpd访问方式的用户验证和权限验证均和svn方式的不同

# cp /data/svn/repos/conf/authz /data/svn/conf/authz

使用apache建立用户密码验证文件并添加test01用户

# htpasswd -cm /data/svn/conf/htpasswd test01

设置文件权限

# chown apache:apache /data/svn/conf/ -R

重启apache生效

# service httpd restart

4 关闭selinux

# vim /etc/selinux/config

修改

SELINUX=permissive

# setenforce 0

5 测试http访问

打开页面http://ip/svn/repos测试


四,使用submin进行web管理配置及http访问


1 删除冲突的subversion配置文件

# rm /etc/httpd/conf.d/subversion -f


2 下载submin 下载地址 http://supermind.nl/submin/current/

安装sqlite数据库

# yum install apr-util-sqlite

3 安装submin部署工具

# python2 setup.py install

4 运行submin命令,下面为安装过程详细步骤

# submin2-admin /data/submin initenv [email protected]


Submin can enable features for you automatically. Please answer which features

you want to enable. You can choose to enable: 'svn', 'git', 'trac', 'apache'

and 'nginx'.


Which features do you want to enable? [svn, git, apache, nginx]> svn,apache


Please provide a location for the Subversion repositories. For new Subversion

repositories, the default setting is ok. If the path is not absolute, it will

be relative to the submin environment. If you want to use an existing

repository, please provide the full pathname to the Subversion parent

directory (ie. /var/lib/svn).


Path to the repository? [svn]> /data/svn


Please provide a hostname that can be used to reach the web interface. This

hostname will be used in communication to the user (a link in email, links

in the web interface). The hostname should be a FQDN, so instead of 'foo' it

should be 'foo.example.com'. Please correct if the default is incorrect.


Hostname? [test-vm]> 10.21.2.229


The HTTP path tells Submin where the website is located relative to the root.

This is needed for proper working of the website. Submin will be accesible

from <http base>/submin, Subversion will be accessible from <http base>/svn.

If you use Trac, it will be accessible from <http base>/trac.


HTTP base? [/]> 


Submin will send emails for password resets and for commit message (if

enabled). You can set the sender email address that Submin will use. The

default might work in some places, but not all.

Email from envelope? [Submin <root@test-vm>]> SVN_Submin <[email protected]>

Apache files created:

/data/submin/conf/apache-webui-cgi.conf

/data/submin/conf/apache-webui-wsgi.conf

/data/submin/conf/apache-svn.conf

/data/submin/conf/apache-trac-modpython.conf

/data/submin/conf/apache-trac-cgi.conf

/data/submin/conf/apache-trac-modwsgi.conf

/data/submin/conf/apache-trac-fcgid.conf

/data/submin/conf/apache-trac-no-anonymous.conf

/data/submin/conf/apache-2.4-webui-cgi.conf

/data/submin/conf/apache-2.4-webui-wsgi.conf

/data/submin/conf/apache-2.4-svn.conf

/data/submin/conf/apache-2.4-trac-modpython.conf

/data/submin/conf/apache-2.4-trac-cgi.conf

/data/submin/conf/apache-2.4-trac-modwsgi.conf

/data/submin/conf/apache-2.4-trac-fcgid.conf

/data/submin/conf/apache-2.4-trac-no-anonymous.conf


   Please include ONE of the -webui- files and optionally -trac- and -svn-

   files (if you need/want that functionality). The -trac-no-anonymous.conf

   file can be used together with ONE other trac config file. The -2.4- files

   are for apache >= 2.4.


   Hint: cgi is simpler, but performs worse.


   Please read the instructions in the file for caveats and on how to include!


4 根据提示,将两个配置文件加入apache配置目录下

# ln -s /data/submin/conf/apache-webui-cgi.conf /etc/httpd/conf.d/

# ln -s /data/submin/conf/apache-svn.conf /etc/httpd/conf.d/

5 修改配置文件加入所需的模块

#vim /etc/httpd/conf.d/apache-svn.conf

添加如下

LoadModule dav_svn_module     modules/mod_dav_svn.so

LoadModule authz_svn_module   modules/mod_authz_svn.so

LoadModule dbd_module           modules/mod_dbd.so

LoadModule authn_dbd_module     modules/mod_authn_dbd.so

6 重启apache生效

service httpd restart

7 此时应该有收到邮件,点开其中链接即可访问submin,点击继续后进入users下更改管理员密码

测试访问地址为http://10.21.2.229/submin

8 可在web上点击Diagnostics检查系统,发现git内容有错误,不使用git的情况下将其关闭

# submin2-admin /data/submin config set vcs_plugins svn

刷新后所有设置都ok

9 使用submin添加用户和组

web页面左下角有3个添加图标,依次为添加用户,添加组,添加版本库

左侧边栏选择Repository下的版本库,选择目录,添加用户或组,再设置组或用户的权限即可使用

10 客户端http访问地址为http://10.21.2.229/svn/repos

11 submin的备份恢复

将/data/submin 整个打包备份即可,还原时还原到同一个路径下


你可能感兴趣的:(linux,SVN,subversion,submin)