liunx 搭建svn

yum install -y subversion  // 安装 svn 服务端
svn --version     // 查看 svn 版本

cd /opt mkdir svn svnadmin create /opt/svn/aj

配置 svn 账号
passwd
[users]
suxiaolong = 123456789

authz
[groups]
admins = suxiaolong
[aj:
/]
@admins
= rw
*=

svnserve.conf
[general]
anon-access = none
password
-db = passwd
authz
-db = authz

vim /etc/httpd/conf

Listen 802 // 设置 httpd 端口
LoadModule dav_svn_module modules
/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /aj>
DAV svn
#SVNListParentPath on
#SVNParentPath
/opt/svn123
SVNPath
/opt/svn/aj
AuthType Basic
AuthName
"Authorization Realm"
# AuthUserFile
/opt/svn123/aj123/conf/passwd
AuthUserFile
/etc/svn-auth-conf
# AuthzSVNAccessFile
/opt/svn123/aj123/conf/authz
AuthzSVNAccessFile
/etc/svn-accesspolicy
Satisfy Any
Require valid
-user
</Location>

htpasswd /etc/svn-auth-conf suxiaolong,设定密码

新建文件 /etc/svn-accesspolicy,文件内容如下:

[groups]
developers = suxiaolong

[/]
@developers
= rw

vim /etc/nginx/conf/svn.conf

server
{
listen 80;
server_name svn.xxx.com;
index index.html index.htm index.php;
root
/opt/svn;

   </span><span style="color: rgba(0, 0, 255, 1)">if</span> (-<span style="color: rgba(0, 0, 0, 1)">d $request_filename)
 {
   rewrite </span>^/(.*)([^/])$ http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">$host/$1$2/ permanent;</span>

}
error_page
405 =200 @405;
location @
405
{
root
/opt/svn;
}

  location </span>~ .*<span style="color: rgba(0, 0, 0, 1)">$ {
              proxy_pass   http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">127.0.0.1:802;</span>

proxy_set_header Host $host;
proxy_set_header X
-Real-IP $remote_addr;
proxy_set_header X
-Forwarded-For
$proxy_add_x_forwarded_for;
}
#access_log
/data1/logs/svn.log alog;
}


  // 启动 svn// 杀死已存在的 svn 服务
  ps -ef|grep svnserve
  root 4967 1 0 Aug23 ? 00:00:00 svnserve -d -r repository/
  这里 kill -9 4967 杀死进程, 此 4967 为进程号

  svnserve -d -r /opt/svn   // 启动 svn  其中 -d 表示守护进程, -r 表示在后台执行  /home/data/svn/  为 svn 的安装目录 


导入项目 svn import aj file:
///opt/svn/aj -m 'aj 2016-9-1'
cd /opt
svn co svn://192.168.xxx.xxx/aj   //剪出也可以
cd aj
svn up     //更新
svn co --username aj svn://xxx.xxx.xxx.xxx/aj // 切换 svn 用户 多个用户
admins = suxiaolong,aj
 
导代码
用 svn
svn://svn.xxx.com/aj

浏览器上浏览
svn.xxx.com/aj
 设置 svn 提交自动更新 
 vim /opt/svn/aj/hooks/post-commit

#!/bin/sh

REPOS="$1"
REV
="$2"

export LANG=zh_CN.UTF-8
svn update svn:
//192.xxx.xxx.xxx/aj /opt/aj3/aj --username=suxiaolong --password=123456

 

svn 开机启动
windos
sc create svnserve binPath= "\"C:\Program Files (x86)\VisualSVN\bin\svnserve.exe\" --service -r E:\svnserver" displayname= "Subversion Server" depend= Tcpip start= auto 

liunx
sc create svnserve binPath= ""C:\Program Files\Subversion\bin\svnserve.exe" --service --root d:\svnstore" displayname= "SVN Serve" depend= Tcpip start= auto

 

  其中,sc 是 windows 自带的服务配置程序,参数 binPath 表示 svnserve 可执行文件的安装路径,由于路径中的"Program Files"带有空格,因此整个路径需要用双引号引起来。而双引号本身是个特殊字符,需要进行转移,因此在路径前后的两个双引号都需要写成 <span style="color: rgba(128, 0, 0, 1)">"
  --service 参数表示以 windows 服务的形式运行,--root 指明 svn repository 的位置,service 参数与 root 参数都作为 binPath 的一部分,因此与 svnserve.exe 的路径一起被包含在一对双引号当中,而这对双引号不需要进行转义。

displayname 表示在 windows 服务列表中显示的名字, depend =Tcpip 表示 svnserve 服务的运行需要 tcpip 服务,start=auto 表示开机后自动运行。

  安装服务后,svnserve 要等下次开机时才会自动运行。

  若要卸载 svn 服务,则执行 sc delete svnserve 即可