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

輸入賬戶密碼後就更新完畢,隨便創建文件上傳一個到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/


 

 

 

        

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章