Apache搭建SVN的一些說明

來源:互聯網
上載者:User

標籤:apache   svn   

本文啟動並執行環境是64位CentOS7


直接安裝Apache和Subversion

yum -y install httpd

yum -y install subverion

如果/usr/lib64/httpd/modules下面沒有mod_dav_svn.so和mod_authz_svn.so需要進行安裝

yum -y install mod_dav_svn

配置Apache:/etc/httpd/conf/httpd.conf

# 監聽連接埠

Listen 80

其他配置請參考Apache相關說明


在/etc/httpd/conf.d下建立subversion.conf (註:名字不重要.conf),內容如下:

LoadModule dav_svn_module     modules/mod_dav_svn.soLoadModule authz_svn_module   modules/mod_authz_svn.so<Location /svn>  DAV svn  SVNParentPath "/opt/svn/"# SVNPath /opt/svn/repos/  AuthType Basic  AuthName "SVN Repo"  AuthUserFile "/opt/svn/htpasswd"  AuthzSVNAccessFile "/opt/svn/authz"  Require valid-user</Location>
LoadModule dav_svn_module     modules/mod_dav_svn.soLoadModule authz_svn_module   modules/mod_authz_svn.so<Location /svn>  DAV svn  SVNParentPath "/opt/svn/"# SVNPath /opt/svn/repos/  AuthType Basic  AuthName "SVN Repo"  AuthUserFile "/opt/svn/htpasswd"  AuthzSVNAccessFile "/opt/svn/authz"  Require valid-user</Location>

其中Location /svn 為訪問路徑,如果寫成Location / 將覆蓋Apache預設首頁

SVNParentPath可以設定多個版本庫的父目錄,可以同時訪問多個版本庫。例如在/opt/svn下有兩個版本庫分別為dev和release那麼就可以通過URL:<URL>/svn/dev和<URL>/svn/release分別訪問

也可以單獨設定SVNPath到具體的一個版本庫,那<URL>/svn就訪問指定的這個版本庫

在/opt/svn下建立2個檔案分別為:htpasswd和authz

其中authz可以從版本庫中的conf目錄下複製出來,具體的配置跟SVN原生配置相同就不再多做說明

單獨說一下使用者檔案htpasswd,具體命令可以查詢htpasswd命令的用法,這裡只介紹幾個用到的語句

htpasswd -c htpasswd user1

建立一個使用者檔案並添件使用者user1

第一個htpasswd是命令,第二個是檔案名稱,可以使用別的名字,當然設定檔裡也要設定成對應的檔案名稱

htpasswd htpasswd user2

添加使用者user2

添加兩個使用者都需要在單獨行輸入密碼兩次進行確認,也可以一行命令執行

htpasswd -b htpasswd user3 123456

刪除使用者

htpasswd -D htpasswd user3


建立版本庫

svnadmin create repos

建立了以後通過<URL>/svn/repos訪問

這時候有可能出現db/txn-current-lock: Permission denied

執行

setsebool -P httpd_unified=1chcon -R -t httpd_sys_content_rw_t /opt/svn/repos

其中第一行只需要執行一次,第二行需要在每個版本庫執行,具體代碼的作用請查詢SELinux

這時候重新訪問有可能出現Could not open the requested SVN filesystem

執行

chmod -R 755 /opt/svn/repos

再訪問就沒有問題了

如果要大量建立版本庫,寫個小指令碼處理

if [ "$1" = "" ];  then echo ‘please input repo name‘else  svnadmin create $1  chcon -R -t httpd_sys_content_rw_t $1  chmod -R 755 $1  chown -R apache $1fi


本文出自 “MMX的沙羅雙樹園” 部落格,請務必保留此出處http://ohmmx.blog.51cto.com/12884864/1924660

Apache搭建SVN的一些說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.