linux下svn搭建以及服务器自动更新代码

第一步   安装SVN   学习资源分享地址
              yum -y install subversion
             输入svnserve --version 查看是否安装成功

第二步   创建版本库目录和版本库  firsttest为项目名称 学习资源分享地址
             cd /home/svn/ 
             svnadmin create firsttest

             安装好后会产生firsttest目录

第三步   修改auth,添加svn用户,假如我添加两个用户是user1和user2  学习资源分享地址

             cd firsttest/conf

             vi   authz

           以下是文件内容

             [groups]
             # harry_and_sally = harry,sally
            # harry_sally_and_joe = harry,sally,&joe
            admin=user1,user2  //增加分组

            # [repository:/baz/fuz]
            # @harry_and_sally = rw
            # * = r
            [firsttest:/]   //目录和项目名称对应 firsttest
           @admin=rw    分配权限

         修改完后保存退出  按esc后输入:wq

第四步 添加用户账户密码 学习资源分享地址

          vi passwd

           ### This file is an example password file for svnserve.
           ### 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
         user1=888888
         user2=888888

    

第五步 添加目录权限,修改svnserve.conf 学习资源分享地址​​​​​​​
          [general]
          ### These options control access to the repository for unauthenticated
          ### and authenticated users.  Valid values are "write", "read",
          ### and "none".  The sample settings below are the defaults.
          # anon-access = read         去掉#并修改为 anon-access=none
          # auth-access = write        去掉#

         ### If SASL is enabled (see below), this file will NOT be used.
         ### Uncomment the line below to use the default password file.
         #password-db = passwd         去掉#
         ### The authz-db option controls the location of the authorization
         ### rules for path-based access control.  Unless you specify a path
         ### starting with a /, the file's location is relative to the the
        ### directory containing this file.  If you don't specify an
        ### authz-db, no path-based access control is done.
        ### Uncomment the line below to use the default authorization file.
        #authz-db = authz          去掉#
        ### This option specifies the authentication realm of the repository.
        ### If two repositories have the same authentication realm, they should
        ### have the same password database, and vice versa.  The default realm
        ### is repository's uuid.
        realm = /home/svn/firsttest/ svn     

       到这里svn就已经安装完成了

       启动svn

       svnserve -d -r /home/svn/

       然后在客户端新建项目目录

      svn://你的服务器id/firsttest

linux下svn搭建以及服务器自动更新代码

输入账户密码后就更新完毕,随便创建文件上传一个到svn

然后回到服务器 你的项目目录/var/www/

cd /

svn co svn://你的服务器id/firsttest  /var/www/

之后输入用户名密码即可,恭喜搭建完成

      

第六步 安装服务器自动更新脚本  学习资源分享地址​​​​​​​

cd /home/svn/firsttest/hooks

vi post-commit

#!/bin/sh
S="$1"
REV="$2"
export LC_ALL="zh_CN.UTF-8"
export LANG="en_US.UTF-8"

SVN_PATH=/usr/bin                          #svn安装路径
WEB_PATH=/var/www/           #web项目所在
SVN_USER=user1                          #svn用户名
SVN_PASS=888888                          #svn密码
LOG_PATH=/tmp/svn.log
$SVN_PATH/svn update $WEB_PATH || exit 1
exit 0

到这步你已经实现完所有步骤

之前回到客户端上传文件,服务器也会同步更新了

溜溜溜,恭喜你又多掌握一项技能

学习资源分享地址​​​​​​​:http://dkfmsc.fun/