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;
   
       if (-d $request_filename)
     {
       rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
     }
       error_page 405 =200 @405;
       location @405
      {
           root /opt/svn;
       }
  
      location ~ .*$ {
                  proxy_pass   http://127.0.0.1:802;
                  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"带有空格,因此整个路径需要用双引号引起来。而双引号本身是个特殊字符,需要进行转移,因此在路径前后的两个双引号都需要写成\"

  --service参数表示以windows服务的形式运行,--root指明svn repository的位置,service参数与root参数都作为binPath的一部分,因此与svnserve.exe的路径一起被包含在一对双引号当中,而这对双引号不需要进行转义。

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

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

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

 

posted @ 2016-09-01 12:26  伊人世界  阅读(196)  评论(0编辑  收藏  举报
Fork me on GitHub