Ubuntu下Apache+SVN搭建SVN服務多專案管理

來源:互聯網
上載者:User

標籤:svn   apache2   

一、系統內容

[email protected]:~# cat /etc/issue

Ubuntu 16.04.2 LTS \n \l

二、建立svn組和使用者

[email protected]:~# addgroup svnser

Adding group `svnser‘ (GID 1001) ...

Done.

[email protected]:~# useradd svnser -g svnser -m    #新增svnser使用者,-g並指定所在的組svnser,-m同時建立svnser使用者所在的家目錄

三、安裝Apache和svnserver

[email protected]:~# apt-get -y install apache2

[email protected]:~# apt-get -y install subversion  libapache2-svn

四、建立版本庫目錄

[email protected]:~# mkdir -p /data/svn

[email protected]:~# svnadmin create /data/svn/repos01

[email protected]:~# svnadmin create /data/svn/repos02

[email protected]:~# svnadmin create /data/svn/repos03

[email protected]:~# ls /data/svn/

repos01  repos02  repos03

[email protected]:~# ls /data/svn/repos01/

conf  db  format  hooks  locks  README.txt

五、建立項目目錄結構並匯入

[email protected]:~# mkdir -p test/{branches,tags,trunk}

匯入項目到版本庫(初始化):

[email protected]:/data/svn# svn import /root/test file:///data/svn/repos01 -m "test import" 

Adding         /root/test/branches

Adding         /root/test/tags

Adding         /root/test/trunk

Committing transaction...

Committed revision 1.

========================================================

/root/test   ----------------> 需要匯入的項目

file:///data/svn/repos01   -----> 表示一個項目的版本庫

六、將SVN配置到apache中通過web方式訪問

[email protected]:/etc/apache2# mkdir svn-repos

[email protected]:/etc/apache2/svn-repos# vim repos01.conf

<Location /svn/repos01>

    DAV svn

    SVNPath /data/svn/repos01

    AuthzSVNAccessFile /data/svn/repos01/conf/authz

    AuthType Basic

    AuthName "Subversion Repository"

    AuthUserFile /data/svn/repos01/conf/dev_passwd

    Require valid-user

</Location>

註:此設定檔告訴apache關於svn的訪問路徑已經相關設定檔,這裡注意訪問的根目錄。重啟apache伺服器,然後就可以通過http://192.168.0.66:8000/svn/repos01進行訪問  

###############################################

/etc/apache2/apache2.conf       <===========此檔案新增如下一行:

IncludeOptional svn-repos/*.conf

################################################

/etc/apache2/ports.conf        <===========此檔案修改Listen 80為:Listen 8000

################################################

/etc/apache2/sites-enabled/000-default.conf     <====此檔案修改<VirtualHost *:80>為:<VirtualHost 127.0.0.1:8000>  ,新增一行ServerName 127.0.0.1

重啟apache服務:/etc/init.d/apache2 restart


======================================


七、添加svn使用者

[email protected]:/data/svn/repos01/conf# htpasswd -m -b -c /data/svn/repos01/conf/dev_passwd  test01 ‘PWDtest‘      #第一次建立svn使用者需要通過-c參數,第二次增加使用者不用-c參數。

通過用戶端或者瀏覽器進行訪問輸入http://192.168.0.66:8000/svn/repos01 

命令列使用svn checkout http://192.168.0.66:8000/svn/repos01  --username test01 --password PWDtest

八、使用者權限設定

新增如下配置

[email protected]:/etc/apache2/mods-enabled# cat dav_svn.load


.........略

LoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.so

LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so

LoadModule dav_fs_module /usr/lib/apache2/modules/mod_dav_fs.so

LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so

LoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.so

使用者目錄使用權限設定:

[email protected]:~# cat /data/svn/repos01/conf/authz 


[groups]                           #設定組

admin = test01,test          #設定組使用者

[/]                              #項目版本庫根目錄,admin擁有讀寫權限

@admin = rw

* =                               # 其他使用者無任何許可權




可以通過nginx+proxy+allow 來控制使用者IP訪問限制

本文出自 “點滴集” 部落格,請務必保留此出處http://1606496.blog.51cto.com/1596496/1929869

Ubuntu下Apache+SVN搭建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.