1.查看系統環境 2.安裝軟體包和Apache SVN模塊 3. 驗證安裝 4.驗證Apache SVN模塊是否安裝成功,需要檢查mod_dav_svn.so和mod_authz_svn.so 5. 使用svnadmin命令創建SVN倉庫repos 6.修改repos目錄屬主和屬組 7. 複製/va ...
本文主要介紹如何在CentOS7環境下集成Apache和SVN,完成後可以通過瀏覽器訪問SVN倉庫.
1.查看系統環境,關閉防火牆和SELinux.
1 [root@Docker /]# systemctl status firewalld.service 2 ● firewalld.service - firewalld - dynamic firewall daemon 3 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) 4 Active: inactive (dead) 5 Docs: man:firewalld(1) 6 [root@Docker /]# getenforce 7 Disabled 8 [root@Docker /]# uname -a 9 Linux Docker 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux 10 [root@Docker /]# cat /etc/redhat-release 11 CentOS Linux release 7.4.1708 (Core) 12 [root@Docker /]#
2.安裝軟體包和Apache SVN模塊.
1 yum install httpd mod_dav_svn subversion
3. 驗證安裝結果.
1 [root@Docker /]# httpd -version 2 Server version: Apache/2.4.6 (CentOS) 3 Server built: Apr 20 2018 18:10:38 4 [root@Docker /]# svnserve --version 5 svnserve, version 1.7.14 (r1542130) 6 compiled Apr 11 2018, 02:40:28
4.驗證Apache SVN模塊是否安裝成功,需要檢查mod_dav_svn.so和mod_authz_svn.so文件.
1 [root@Docker modules]# pwd 2 /etc/httpd/modules 3 [root@Docker modules]# ll | egrep "mod_dav_svn.so|mod_authz_svn.so" 4 -rwxr-xr-x 1 root root 19504 Apr 11 10:44 mod_authz_svn.so 5 -rwxr-xr-x 1 root root 181344 Apr 11 10:44 mod_dav_svn.so
5.使用svnadmin命令創建SVN倉庫repos.
1 [root@Docker /]# mkdir /var/www/svn 2 [root@Docker /]# cd /var/www/svn/ 3 [root@Docker svn]# svnadmin create repos 4 [root@Docker svn]# tree -d repos/ 5 repos/ 6 ├── conf 7 ├── db 8 │ ├── revprops 9 │ │ └── 0 10 │ ├── revs 11 │ │ └── 0 12 │ ├── transactions 13 │ └── txn-protorevs 14 ├── hooks 15 └── locks 16 17 10 directories
6.修改repos目錄屬主和屬組為apache.
1 [root@Docker svn]# chown -R apache:apache repos/ 2 [root@Docker svn]# ll 3 total 4 4 drwxr-xr-x 6 apache apache 4096 May 15 16:57 repos
7.複製/var/www/svn/repos/conf 下的許可權管理文件authz到 /var/www/svn下,並創建用戶認證文件passwd,並且設置隱藏屬性.
1 [root@Docker svn]# cp /var/www/svn/repos/conf/authz /var/www/svn/ 2 [root@Docker svn]# cd /var/www/svn/repos 3 [root@Docker repos]# touch .passwd
8.通過htpasswd命令建立SVN用戶svnuser並將用戶信息保存在passwd文件中.
1 [root@Docker repos]# htpasswd ./.passwd svnuser 2 New password: 3 Re-type new password: 4 Adding password for user svnuser 5 [root@Docker repos]# cat .passwd 6 svnuser:$apr1$ThE7aO2O$CQo.OIs.8TOqUFaFr7b3H0
9.修改authz文件並設置相應許可權:
在[groups]下添加組
[/] 相當於/var/www/svn這個目錄,賦予許可權給用戶組
[repos:/] 是指repos庫
[repos:/desgin]是repos下的desgin目錄
rw是指可讀寫許可權
1 [root@Docker svn]# vim authz 2 [root@Docker svn]# grep -v "^#" authz 3 4 [groups] 5 admin_group=svnuser,svnuser2 6 project_group=svnuser3,svnuser4 7 project2_group=svnuser5,svnuser6 8 9 [/] 10 @admin_group=rw 11 12 [repos:/] 13 @project_group=rw 14 15 [repos:/desgin] 16 @project_group=rw 17 18 [repos2:/] 19 @project2_group=rw
10.關聯Apache與SVN,創建subversion.conf文件.Locaion後的名字可以自定義,不需要與倉庫名一致,這裡我們定義為/documents,這樣後面訪問時直接輸入http://x.x.x.x/documents即可打開倉庫
[root@Docker /]# vim /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location /documents> DAV svn SVNParentPath /var/www/svn SVNListParentPath On AuthType Basic AuthName "Project SVN" AuthUserFile /var/www/svn/repos/.passwd Require valid-user AuthzSVNAccessFile /var/www/svn/authz </Location>
11.啟動Apache,在瀏覽器中輸入http://x.x.x.x/documents彈出認證視窗,輸入用戶認證信息即可看到SVN倉庫repos.
1 [root@Docker /]# systemctl start httpd.service