安裝httpd服務:spring
$ sudo yum install httpd
檢查httpd是否安裝成功:apache
$ httpd -version Server version: Apache/2.4.6 (CentOS) Server built: Jul 18 2016 15:30:14
安裝svnserve服務:服務器
$ sudo yum install subversion
檢查svnserve是否安裝成功:svn
$ svnserve --version svnserve, version 1.7.14 (r1542130) compiled Nov 20 2015, 19:25:09
mod_dav_svn是apache服務器訪問svn的一個模塊。經過yum安裝:ui
$ sudo yum install mod_dav_svn
安裝成功後,會有mod_dav_svn.so和mod_authz_svn.so兩個文件。spa
$ sudo find / -name mod_dav_svn.so /usr/lib64/httpd/modules/mod_dav_svn.so $ sudo find / -name mod_authz_svn.so /usr/lib64/httpd/modules/mod_authz_svn.so
$ sudo mkdir /var/www/svn $ sudo svnadmin create /var/www/svn/spring-hello-world $ ll /var/www/svn/ drwxr-xr-x. 6 root root 80 Nov 10 14:42 spring-hello-world $ ll /var/www/svn/spring-hello-world/ drwxr-xr-x. 2 root root 51 Nov 10 14:42 conf drwxr-sr-x. 6 root root 4096 Nov 10 14:42 db -r--r--r--. 1 root root 2 Nov 10 14:42 format drwxr-xr-x. 2 root root 4096 Nov 10 14:42 hooks drwxr-xr-x. 2 root root 39 Nov 10 14:42 locks -rw-r--r--. 1 root root 229 Nov 10 14:42 README.txt
修改svn倉庫的用戶組爲apache:code
$ sudo chown -R apache:apache /var/www/svn/spring-hello-world/
建立用戶文件passwd:orm
$ sudo touch /var/www/svn/passwd #建立用戶文件 $ sudo htpasswd /var/www/svn/passwd admin #建立用戶admin $ sudo htpasswd /var/www/svn/passwd guest #建立用戶guest $ cat /var/www/svn/passwd admin:$apr1$UCkPzZ2x$tnDk2rgZoiaURPzO2e57t0 guest:$apr1$vX1RIUq6$OKS1bqKZSptzsPDYUOJ5x.
建立權限文件authz:blog
$ sudo cp /var/www/svn/spring-hello-world/conf/authz /var/www/svn/authz $ cat /var/www/svn/authz [/] admin = rw guest = r
$ sudo touch /etc/httpd/conf.d/subversion.conf $ cat /etc/httpd/conf.d/subversion.conf <Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Authorization SVN" AuthzSVNAccessFile /var/www/svn/authz AuthUserFile /var/www/svn/passwd Require valid-user </Location>
$ sudo systemctl start httpd.service
客戶端使用http://192.168.12.59/svn/spring-hello-world就能夠訪問剛纔創建的svn倉庫了。 若是返回403錯誤,多是防火牆問題。增長防火牆規則:cmd
$ sudo firewall-cmd --permanent --add-service=http $ sudo firewall-cmd --permanent --add-service=https $ sudo firewall-cmd --reload