歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

基於apache搭建svn


前言 或許現在大多數高級程序員都用github來做代碼管理工具,但是還有很多公司考慮到便於實施和人員接受能力的問題,還是會選擇svn作為代碼版本管理工具,下面介紹一下如何基於apache搭建svn版本庫   安裝svn相關模塊   www.2cto.com     安裝命令 [html]    sudo apt-get install subversion libapache2-svn    安裝成功後截圖
  www.2cto.com     配置svn版本庫   創建svn根目錄 [html]    mkdir -p /home/svn    創建所需要的版本庫   www.2cto.com   [html]    cd /home/svn/  sudo svnadmin create 版本庫的名字    修改版本庫目錄的權限 因為是通過apache訪問svn,所以目錄的屬主均為www-data即可 [html]    sudo chown -R www-data.www-data 版本庫名字    配置Apache 修改apache基於svn模塊的配置文件 [html]    sudo vim /etc/apache2/mods-available/dav_svn.conf    修改後配置文件內容如下 [html] # dav_svn.conf - Example Subversion/Apache configuration   #   # For details and further options see the Apache user manual and   # the Subversion book.   #   # NOTE: for a setup with multiple vhosts, you will want to do this   # configuration in /etc/apache2/sites-available/*, not here.      # <Location URL> ... </Location>   # URL controls how the repository appears to the outside world.   # In this example clients access the repository as http://hostname/svn/   # Note, a literal /svn should NOT exist in your document root.   <Location /svn>        # Uncomment this to enable the repository     DAV svn        # Set this to the path to your repository    # SVNPath /home/svn     # Alternatively, use SVNParentPath if you have multiple repositories under     # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).     # You need either SVNPath and SVNParentPath, but not both.     SVNListParentPath on     SVNParentPath /home/svn        # Access control is done at 3 levels: (1) Apache authentication, via     # any of several methods.  A "Basic Auth" section is commented out     # below.  (2) Apache <Limit> and <LimitExcept>, also commented out     # below.  (3) mod_authz_svn is a svn-specific authorization module     # which offers fine-grained read/write access control for paths     # within a repository.  (The first two layers are coarse-grained; you     # can only enable/disable access to an entire repository.)  Note that     # mod_authz_svn is noticeably slower than the other two layers, so if     # you don't need the fine-grained control, don't configure it.        # Basic Authentication is repository-wide.  It is not secure unless     # you are using https.  See the 'htpasswd' command to create and     # manage the password file - and the documentation for the     # 'auth_basic' and 'authn_file' modules, which you will need for this     # (enable them with 'a2enmod').     AuthType Basic     AuthName "Subversion Repository"     AuthUserFile /etc/apache2/dav_svn.passwd        # To enable authorization via mod_authz_svn     AuthzSVNAccessFile /etc/apache2/dav_svn.authz        # The following three lines allow anonymous read, but make     # committers authenticate themselves.  It requires the 'authz_user'     # module (enable it with 'a2enmod').     #<LimitExcept GET PROPFIND OPTIONS REPORT>       Require valid-user     #</LimitExcept>       </Location>     注意: <Location /svn>與</Location>成對出現 DAV svn開啟DAV模塊支持 SVNPath與SVNParentPath二選其一,不能同時出現,建議使用SVNParentPath,這樣可以在SVN的根目錄下創建多個svn版本庫 開啟BASIC認證 多讀一下英文注釋,很簡單的 創建svn賬戶 [html]    sudo htpasswd [-c] /etc/apache2/dav_svn.passwd $username    注意: /etc/apache2/dav_svn.passwd是在apache的dav_svn.conf裡AuthUserFile指定的文件 參數-c,當指定文件不存在時需要該參數創建文件,當指定文件存在時,不需要該參數,否則會覆蓋掉原有文件中記錄 訪問權限控制 修改AuthzSVNAccessFile指定文件 [html]    sudo vim /etc/apache2/dav_svn.authz    創建組並進行讀寫控制 示例文件配置   [html]    [groups]  haotest1-admin=wangzhengyi  haotest1-dev=wangzhengyi,chenshan    [haotest1:/]  @haotest1-dev=r  @haotest1-admin=rw    [haotest1:/trunk]  @haotest1-dev=rw    [haotest1:/tags]  @haotest1-admin=rw    www.2cto.com   參數說明 [groups]針對haotest1版本庫設置了兩個組,一個admin,一個dev [haotest1:/]這是haotest1版本庫的根目錄,針對dev組只有r權限,也就是只能檢出,
針對admin有rw權限,可以創建,刪除,修改等權限 點到為止,不明白的google一下,說多了就沒意思了   www.2cto.com   檢出測試 場景 遠程主機ip:192.168.1.1 檢出版本庫的路徑:/svn/haotest1   檢出命令 [html]    svn co http://192.168.1.1/svn/haozhaotest1 --username wangzhengyi    創建目錄並提交   www.2cto.com    
Copyright © Linux教程網 All Rights Reserved